repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,011 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Adjustment_Attributes;
package Matreshka.ODF_Style.Adjustment_Attributes is
type Style_Adjustment_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Adjustment_Attributes.ODF_Style_Adjustment_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Adjustment_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Adjustment_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Adjustment_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 5,686 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019-2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- Bit-bang a sequence of color LED values to a one-pin LED strip (WS2812B
-- or similar).
with System.Machine_Code; use System, System.Machine_Code;
with NRF_SVD.GPIO; use NRF_SVD.GPIO;
with MicroBit.Time;
package body MicroBit.IOs.NeoPixel is
-----------
-- Write --
-----------
procedure Write (Pin : Pin_Id; Values : UInt8_Array) is
Point : constant GPIO_Point := Points (Pin);
Mask : constant UInt32 := 2 ** Point.Pin;
EOL : constant String := ASCII.LF & ASCII.HT;
begin
-- Set pin to digital out mode and reset strip
Set (Pin, False);
MicroBit.Time.Delay_Ms (1);
-- The following loop is very time-sensitive. The bit frame is 1.25 Ás,
-- i.e. 20 cycles of the 16 MHz clock. So, we run it with IRQs disabled,
-- and carefully account for every cycle.
-- Code taken from:
-- https://github.com/Microsoft/pxt-ws2812b/blob/master/sendBuffer.asm
Asm (" cpsid i @ disable irq" & EOL &
" b .start" & EOL &
".nextbit: @ c0" & EOL &
" str %2, [%1, #0] @ pin := hi c2" & EOL &
" tst r6, r0 @ c3" & EOL &
" bne .islate @ c4" & EOL &
" str %2, [%0, #0] @ pin := lo c6" & EOL &
".islate:" & EOL &
" lsr r6, r6, #1 @ r6 >>= 1 c7" & EOL &
" bne .justbit @ c8" & EOL &
"@ not just a bit - need new byte" & EOL &
" add %3, #1 @ buf++ c9" & EOL &
" sub %4, #1 @ len-- c10" & EOL &
" bcc .stop @ if (len<0) goto .stop c11" & EOL &
".start:" & EOL &
" movs r6, #0x80 @ reset mask c12" & EOL &
" nop @ c13" & EOL &
".common: @ c13" & EOL &
" str %2, [%0, #0] @ pin := lo c15" & EOL &
" @ always re-load byte - it just fits with the" & EOL &
" @ cycles better this way." & EOL &
" ldrb r0, [%3, #0] @ r0 := *buf c17" & EOL &
" b .nextbit @ c20" & EOL &
".justbit: @ c10" & EOL &
" @ no nops, branch taken is already 3 cycles" & EOL &
" b .common @ c13" & EOL &
".stop:" & EOL &
" str %2, [%0, #0] @ pin := lo" & EOL &
" cpsie i @ enable irq",
Inputs => (Address'Asm_Input ("l", GPIO_Periph.OUTCLR'Address), -- %0
Address'Asm_Input ("l", GPIO_Periph.OUTSET'Address), -- %1
UInt32'Asm_Input ("l", Mask), -- %2
Address'Asm_Input ("l", Values'Address), -- %3
Natural'Asm_Input ("l", Values'Length)), -- %4
Volatile => True,
Clobber => "r0,r6");
end Write;
end MicroBit.IOs.NeoPixel;
|
zhmu/ananas | Ada | 576 | adb | package body Opt94_Pkg is
function Worker (S : String) return Integer;
pragma Pure_Function (Worker);
function Valid_Result (S : String) return Boolean is
begin
return Worker (S) > 0;
end;
function Result (S : String) return Integer is
R : constant Integer := Worker (S);
begin
if R > 0 then
return R;
else
raise Program_Error;
end if;
end;
function Worker (S : String) return Integer is
begin
return Character'Pos (S (S'First));
end;
function Get return String is
begin
return "";
end;
end Opt94_Pkg;
|
tyudosen/DualStack | Ada | 10,492 | adb | with RandFloat; use RandFloat;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Time_zones; use Ada.Calendar.Time_zones;
with Unchecked_Conversion;
with gstack;
procedure ArrivalForRepair is
package FloatIO is new Ada.Text_IO.Float_IO(float);
use FloatIO;
package IntIO is new Ada.Text_IO.Integer_IO(Integer);
use IntIO;
package Fix_IO is new Ada.Text_IO.Fixed_IO(DAY_DURATION);
use Fix_IO;
function intToChar is new Unchecked_Conversion(Integer, Character);
charStar, charTie : Character := 'A';
intStar, intTie : Integer := 64;
subtype getChar is Character range 'A'..'Z';
lastCharOfTie, lastCharOfStar : getChar := getChar'First;
type vehicle is
(Star_Destroyer, Tie_Fighter);
package vechileIO is new Ada.Text_IO.Enumeration_IO(vehicle);
type vName is
(Tie, Star);
package nameIO is new Ada.Text_IO.Enumeration_IO(vName);
-- Maintainance bay record
type garageBay is record
vehicleType : vehicle;
vehicleName: String(1..5);
time2Fix: integer;
startTime: Time;
finishTime: Time;
--elapsedTime: DAY_DURATION;
end record;
a : garageBay;
-- Function to determine if the arriving planes are Star or Tie
function StarOrTie(x: in out integer) return garageBay is
randNum: float;
z,b,c,d : garageBay;
e : Time := Clock;
--seed: integer;
begin
randNum := next_float(x); -- 0.0 <= randNumm <= 1.0.
if randNum <= 0.25 then
z := (vehicleType => Tie_Fighter, vehicleName => "Tie ", time2Fix => 0, startTime => e, finishTime => e);
return a; -- return tie
elsif randNum <= 0.5 then
b := (vehicleType => Tie_Fighter, vehicleName => "Tie ", time2Fix => 0, startTime => e, finishTime => e);
return b; -- return tie
elsif randNum <= 0.75 then
c := (vehicleType => Tie_Fighter, vehicleName => "Tie ", time2Fix => 0, startTime => e, finishTime => e);
return c; -- return tie
else
d := (vehicleType => Star_Destroyer, vehicleName => "Star ", time2Fix => 0, startTime => e, finishTime => e);
return d; -- return stsr
end if;
end StarOrTie;
-- Determine the number of new arrivals for Step 1 in the lab.
-- Either 1, 2, 3 or 4 uniformly distributed on each call.
function NumberNewArrivals(x: in out integer) return Integer is
randNum: float;
begin
randNum := next_float(x); -- 0.0 <= randNumm <= 1.0.
if randNum <= 0.25 then
return 1; -- return tie
elsif randNum <= 0.5 then
return 2; -- return tie
elsif
randNum <= 0.75 then
return 3; -- return tie
else
return 4; -- return stsr
end if;
end NumberNewArrivals;
Start,Finish, elapsed, secondus : DAY_DURATION;
StartTime, ArrivTime, departTime, ElapsTime : Time := clock;
-- Procedure to get start time
--function startTime return DAY_DURATION is
-- Year,Month,Day : INTEGER;
--Start : DAY_DURATION;
--Time_And_Date : TIME;
--begin
--Time_And_Date := Clock; -- gets system time
--Split(Time_And_Date,Year, Month,Day,Start);
--return Start; -- gets start time ( stores it in seconds in the variable Start)
--end startTime;
-- Procedure to get finish time
function finishTime return DAY_DURATION is
Year,Month,Day : INTEGER;
Finish : DAY_DURATION;
Time_And_Date : TIME;
begin
Time_And_Date := Clock; -- gets system time
Split(Time_And_Date,Year, Month,Day,Finish);
return Finish; -- gets start time ( stores it in seconds in the variable Start)
end finishTime;
numberArrivals,seed,upperbound,starKnt,tieKnt, dagobah, repairStar, repairTie: Integer := 0;
decision: garageBay;
ET: DAY_DURATION;
begin
-- Get upperbound of the stack.
put("Enter The Maximum Number Of Vehicles Allowed In The Garagebay:"); new_line;
get(upperbound);
declare
-- Instantiate the generic package for type garageBay.
package genericS is new gstack(upperbound, garageBay);
use genericS;
begin
-- Lab Step 0. write start time to service log.
--start := startTime;
--finish := finishTime;
--elapsed := finish - start;
--ET := elapsed;
startTime := clock;
put(Image(startTime, Time_Zone => -5*60) ); put(" Garagebay is open ");
new_line;
-- Seed the random number generator appropriately.
put("Seed the random number generator:"); new_line;
get(seed);
put("-----------------------------------------------------------------------------------");new_line;
-- do the operations
--numberArrivals := 3; -- Assuming 3 vehicles at open.
Loop
numberArrivals := NumberNewArrivals(seed);
put("Number of Arrivals: ");new_line;put(numberArrivals,0);new_line;
put("-----------------------------------------------------------------------------------");new_line;
for j in 1..numberArrivals
loop
--Determine if the arrival is a Tie Fighter or a Star Destroyer.
--Prepare the maintenance record and place it in the appropriate queue.
decision := StarOrTie(seed);
if decision.vehicleType = Star_Destroyer
then
intStar := intStar + 1;
if intStar = 91 then
intStar := 65;
end if;
charStar := intToChar(intStar);
decision.vehicleName(1..4) := "Star";
decision.vehicleName(5) := charStar;
decision.time2Fix := 7;
ArrivTime := clock;
decision.startTime := ArrivTime;
spush(decision);
---
--if dagobah > 0 then
--put("Dagobah Count: ");put(dagobah);new_line;
--put("-----------------------------------------------------------------------------------");new_line;
--end if;
---
starKnt := starKnt +1;
--put("Number of Arrivals: ");put(numberArrivals);new_line;
put(Image(startTime, Time_Zone => -5*60) );put(":");new_line;
put(decision.vehicleName & " Arrived");new_line(2);
-- put("-----------------------------------------------------------------------------------");new_line;
else
intTie := intTie + 1;
if intTie = 91 then
intTie := 65;
end if;
charTie := intToChar(intTie);
decision.vehicleName(4) := charTie;
decision.time2Fix := 3;
ArrivTime := clock;
decision.startTime := ArrivTime;
departTime := clock;
decision.finishTime := departTime;
tpush(decision);
--
--
tieKnt := tieKnt + 1;
put(Image(startTime, Time_Zone => -5*60) );put(":");new_line;
put(decision.vehicleName & " Arrived");new_line(2);
end if;
if tieKnt + starKnt > 20 then
dagobah := dagobah + 1;
end if;
if dagobah > 0 then
put("Dagobah Count: ");put(dagobah);new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
end loop;
--Lab Step 2.
if starKnt > 0 then
spop(decision); starKnt := starKnt - 1;repairStar:= repairStar+ 1;
delay 3.0;
put("-----------------------------------------------------------------------------------");new_line;
put("Vehicle Type: ");put(vehicle'image(decision.vehicleType));new_line;
put("Vehicle Name: " & decision.vehicleName);new_line;
put("Time to Fix: ");put(decision.time2Fix,0);new_line;
put("Start Time: ");put(Image(decision.startTime, Time_Zone => -5*60) );new_line;
departTime := clock;
--finishTime := departTime;
put("Finish Time: ");put(Image(departTime, Time_Zone => -5*60 ));new_line;
put("-----------------------------------------------------------------------------------");new_line;
--if dagobah > 0 then
-- put("Dagobah Count: ");put(dagobah);new_line;
--end if;
elsif starKnt = 0 then --and tieKnt > 0
tpop(decision); tieKnt := tieKnt - 1;repairTie := repairTie + 1;
delay 1.00;
put("-----------------------------------------------------------------------------------");new_line;
put("Vehicle Type: ");put(vehicle'image(decision.vehicleType));new_line;
--put("Vehicle Name: " & decision.vehicleName);new_line;
put("Vehicle Name: " & decision.vehicleName);new_line;
put("Time to Fix: ");put(decision.time2Fix,0);new_line;
put("Start Time: ");put(Image(decision.startTime, Time_Zone => -5*60) );new_line;
departTime := clock;
--finishTime := departTime;
put("Finish Time: ");put(Image(departTime, Time_Zone => -5*60));new_line;
--put("Start Time: ");put(Image(decision.startTime, Time_Zone => -5*60) );new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
-- do the operations.
--Lab Step 3.
-- do the operations.
--Lab Step 4.
-- do the operations, prepare for the vext repair operations.
if dagobah >= 5 then
put("Total Time Elpased: ");put(Duration'image(Clock - startTime));put(" Seconds");new_line;
put("No of Vehicles Repaired: ");put(repairStar + repairTie);put(" Vehicles");new_line;
--put("No of Vehicles Repaired: ");put(repairStar + repairTie);put(" Vehicles");new_line;
put("No of Star Destroyers Repaired: ");put(repairStar);new_line;
put("No of Tie Fighters Repaired: ");put(repairTie);new_line;
exit;
end if;
delay 2.0;
end loop;
-- Lab Step 5
--Five vehicles rejected.
--Calculate and print results
end;
end ArrivalForRepair; |
afrl-rq/OpenUxAS | Ada | 3,697 | adb | with GNAT.String_Split;
with Ada.Strings.Fixed;
package body UxAS.Comms.Data.Addressed is
----------------------
-- Is_Valid_Address --
----------------------
function Is_Valid_Address (Address : String) return Boolean is
Delimiter_Pos : Natural;
use Ada.Strings.Fixed;
begin
if Address'Length = 0 then
return False;
end if;
Delimiter_Pos := Index (Source => Address, Pattern => Address_Attributes_Delimiter);
if Delimiter_Pos /= 0 then -- found a delimiter
return False;
end if;
return True;
end Is_Valid_Address;
-----------------------------
-- Set_Address_And_Payload --
-----------------------------
procedure Set_Address_And_Payload
(This : in out Addressed_Message;
Address : String;
Payload : String;
Result : out Boolean)
is
begin
if not Is_Valid_Address (Address) or Payload'Length = 0 then
This.Is_Valid := False;
Result := False;
return;
end if;
Copy (Address, To => This.Address);
Copy (Payload, To => This.Payload);
Copy (Address & Address_Attributes_Delimiter & Payload, To => This.Content_String);
This.Is_Valid := True;
Result := True;
end Set_Address_And_Payload;
---------------------------------------------------
-- Set_Address_And_Payload_From_Delimited_String --
---------------------------------------------------
procedure Set_Address_And_Payload_From_Delimited_String
(This : in out Addressed_Message;
Delimited_String : String;
Result : out Boolean)
is
begin
if Delimited_String'Length >= Minimum_Delimited_Address_Message_String_Length then
Parse_Addressed_Message_String_And_Set_Fields (This, Delimited_String, Result);
else
This.Is_Valid := False;
Result := False;
end if;
end Set_Address_And_Payload_From_Delimited_String;
--------------
-- Is_Valid --
--------------
function Is_Valid (This : Addressed_Message) return Boolean is
(This.Is_Valid);
-------------
-- Address --
-------------
function Address (This : Addressed_Message) return String is
(Value (This.Address));
-------------
-- Payload --
-------------
function Payload (This : Addressed_Message) return String is
(Value (This.Payload));
--------------------
-- Content_String --
--------------------
function Content_String (This : Addressed_Message) return String is
(Value (This.Content_String));
---------------------------------------------------
-- Parse_Addressed_Message_String_And_Set_Fields --
---------------------------------------------------
procedure Parse_Addressed_Message_String_And_Set_Fields
(This : in out Addressed_Message;
Delimited_String : String;
Result : out Boolean)
is
use GNAT.String_Split;
Parts : Slice_Set;
begin
Create (Parts,
From => Delimited_String,
Separators => Address_Attributes_Delimiter,
Mode => Single); -- contiguous delimiters are NOT treated as a single delimiter;
This.Is_Valid := False;
Result := False;
if Slice_Count (Parts) /= 2 then
return;
elsif Slice (Parts, 1) = "" or Slice (Parts, 2) = "" then
return;
else
Set_Address_And_Payload
(This,
Address => Slice (Parts, 1),
Payload => Slice (Parts, 2),
Result => Result);
end if;
end Parse_Addressed_Message_String_And_Set_Fields;
end UxAS.Comms.Data.Addressed;
|
reznikmm/matreshka | Ada | 5,360 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
with XML.DOM.Nodes;
limited with XML.DOM.Elements;
package XML.DOM.Attributes is
pragma Preelaborate;
type DOM_Attribute is limited interface and XML.DOM.Nodes.DOM_Node;
type DOM_Attribute_Access is access all DOM_Attribute'Class
with Storage_Size => 0;
not overriding function Get_Name
(Self : not null access constant DOM_Attribute)
return League.Strings.Universal_String is abstract;
-- Returns the name of this attribute. If Node.localName is different from
-- null, this attribute is a qualified name.
not overriding function Get_Value
(Self : not null access constant DOM_Attribute)
return League.Strings.Universal_String is abstract;
not overriding procedure Set_Value
(Self : not null access DOM_Attribute;
New_Value : League.Strings.Universal_String) is abstract;
-- On retrieval, the value of the attribute is returned as a string.
-- Character and general entity references are replaced with their values.
-- See also the method getAttribute on the Element interface.
--
-- On setting, this creates a Text node with the unparsed contents of the
-- string, i.e. any characters that an XML processor would recognize as
-- markup are instead treated as literal text. See also the method
-- Element.setAttribute().
--
-- Some specialized implementations, such as some [SVG 1.1]
-- implementations, may do normalization automatically, even after
-- mutation; in such case, the value on retrieval may differ from the value
-- on setting.
--
-- Exceptions on setting
--
-- DOMException
--
-- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
not overriding function Get_Owner_Element
(Self : not null access constant DOM_Attribute)
return XML.DOM.Elements.DOM_Element_Access is abstract;
-- The Element node this attribute is attached to or null if this attribute
-- is not in use.
end XML.DOM.Attributes;
|
zhmu/ananas | Ada | 5,414 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . E X E C U T I O N _ T I M E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2009-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Windows native version of this package
with Ada.Task_Identification;
with Ada.Real_Time;
package Ada.Execution_Time with
SPARK_Mode
is
type CPU_Time is private;
CPU_Time_First : constant CPU_Time;
CPU_Time_Last : constant CPU_Time;
CPU_Time_Unit : constant := 0.000001;
CPU_Tick : constant Ada.Real_Time.Time_Span;
use type Ada.Task_Identification.Task_Id;
function Clock
(T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task)
return CPU_Time
with
Volatile_Function,
Global => Ada.Real_Time.Clock_Time,
Pre => T /= Ada.Task_Identification.Null_Task_Id;
function "+"
(Left : CPU_Time;
Right : Ada.Real_Time.Time_Span) return CPU_Time
with
Global => null;
function "+"
(Left : Ada.Real_Time.Time_Span;
Right : CPU_Time) return CPU_Time
with
Global => null;
function "-"
(Left : CPU_Time;
Right : Ada.Real_Time.Time_Span) return CPU_Time
with
Global => null;
function "-"
(Left : CPU_Time;
Right : CPU_Time) return Ada.Real_Time.Time_Span
with
Global => null;
function "<" (Left, Right : CPU_Time) return Boolean with
Global => null;
function "<=" (Left, Right : CPU_Time) return Boolean with
Global => null;
function ">" (Left, Right : CPU_Time) return Boolean with
Global => null;
function ">=" (Left, Right : CPU_Time) return Boolean with
Global => null;
procedure Split
(T : CPU_Time;
SC : out Ada.Real_Time.Seconds_Count;
TS : out Ada.Real_Time.Time_Span)
with
Global => null;
function Time_Of
(SC : Ada.Real_Time.Seconds_Count;
TS : Ada.Real_Time.Time_Span := Ada.Real_Time.Time_Span_Zero)
return CPU_Time
with
Global => null;
Interrupt_Clocks_Supported : constant Boolean := False;
Separate_Interrupt_Clocks_Supported : constant Boolean := False;
pragma Warnings (Off, "check will fail at run time");
function Clock_For_Interrupts return CPU_Time with
Volatile_Function,
Global => Ada.Real_Time.Clock_Time,
Pre => Interrupt_Clocks_Supported;
pragma Warnings (On, "check will fail at run time");
private
pragma SPARK_Mode (Off);
type CPU_Time is new Ada.Real_Time.Time;
CPU_Time_First : constant CPU_Time := CPU_Time (Ada.Real_Time.Time_First);
CPU_Time_Last : constant CPU_Time := CPU_Time (Ada.Real_Time.Time_Last);
CPU_Tick : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Tick;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
end Ada.Execution_Time;
|
aherd2985/Amass | Ada | 1,639 | ads | -- Copyright 2021 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 = "Crtsh"
type = "cert"
function start()
setratelimit(2)
end
function vertical(ctx, domain)
local resp
local cfg = datasrc_config()
-- Check if the response data is in the graph database
if (cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(domain, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request(ctx, {
['url']=buildurl(domain),
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
if (cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(domain, resp)
end
end
dec = json.decode(resp)
if (dec == nil or #dec == 0) then
return
end
for i, r in pairs(dec) do
local parts = split(r.name_value, "\n")
if #parts == 0 then
table.insert(parts, r.name_value)
end
for j, name in pairs(parts) do
newname(ctx, name)
end
end
end
function buildurl(domain)
return "https://crt.sh/?q=%25." .. domain .. "&output=json"
end
function split(str, delim)
local result = {}
local pattern = "[^%" .. delim .. "]+"
local matches = find(str, pattern)
if (matches == nil or #matches == 0) then
return result
end
for i, match in pairs(matches) do
table.insert(result, match)
end
return result
end
|
MinimSecure/unum-sdk | Ada | 799 | ads | -- Copyright 2011-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pck is
task Dummy_Task is
entry Start;
end Dummy_Task;
end Pck;
|
Fabien-Chouteau/samd51-hal | Ada | 19,086 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.EIC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Clock Selection
type CTRLA_CKSELSelect is
(-- Clocked by GCLK
CLK_GCLK,
-- Clocked by ULP32K
CLK_ULP32K)
with Size => 1;
for CTRLA_CKSELSelect use
(CLK_GCLK => 0,
CLK_ULP32K => 1);
-- Control A
type EIC_CTRLA_Register is record
-- Software Reset
SWRST : Boolean := False;
-- Enable
ENABLE : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Clock Selection
CKSEL : CTRLA_CKSELSelect := SAM_SVD.EIC.CLK_GCLK;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for EIC_CTRLA_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
CKSEL at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Non-Maskable Interrupt Sense Configuration
type NMICTRL_NMISENSESelect is
(-- No detection
NONE,
-- Rising-edge detection
RISE,
-- Falling-edge detection
FALL,
-- Both-edges detection
BOTH,
-- High-level detection
HIGH,
-- Low-level detection
LOW)
with Size => 3;
for NMICTRL_NMISENSESelect use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Asynchronous Edge Detection Mode
type NMICTRL_NMIASYNCHSelect is
(-- Edge detection is clock synchronously operated
SYNC,
-- Edge detection is clock asynchronously operated
ASYNC)
with Size => 1;
for NMICTRL_NMIASYNCHSelect use
(SYNC => 0,
ASYNC => 1);
-- Non-Maskable Interrupt Control
type EIC_NMICTRL_Register is record
-- Non-Maskable Interrupt Sense Configuration
NMISENSE : NMICTRL_NMISENSESelect := SAM_SVD.EIC.NONE;
-- Non-Maskable Interrupt Filter Enable
NMIFILTEN : Boolean := False;
-- Asynchronous Edge Detection Mode
NMIASYNCH : NMICTRL_NMIASYNCHSelect := SAM_SVD.EIC.SYNC;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for EIC_NMICTRL_Register use record
NMISENSE at 0 range 0 .. 2;
NMIFILTEN at 0 range 3 .. 3;
NMIASYNCH at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Non-Maskable Interrupt Flag Status and Clear
type EIC_NMIFLAG_Register is record
-- Non-Maskable Interrupt
NMI : Boolean := False;
-- unspecified
Reserved_1_15 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for EIC_NMIFLAG_Register use record
NMI at 0 range 0 .. 0;
Reserved_1_15 at 0 range 1 .. 15;
end record;
-- Synchronization Busy
type EIC_SYNCBUSY_Register is record
-- Read-only. Software Reset Synchronization Busy Status
SWRST : Boolean;
-- Read-only. Enable Synchronization Busy Status
ENABLE : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_SYNCBUSY_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype EIC_EVCTRL_EXTINTEO_Field is HAL.UInt16;
-- Event Control
type EIC_EVCTRL_Register is record
-- External Interrupt Event Output Enable
EXTINTEO : EIC_EVCTRL_EXTINTEO_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_EVCTRL_Register use record
EXTINTEO at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTENCLR_EXTINT_Field is HAL.UInt16;
-- Interrupt Enable Clear
type EIC_INTENCLR_Register is record
-- External Interrupt Enable
EXTINT : EIC_INTENCLR_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTENCLR_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTENSET_EXTINT_Field is HAL.UInt16;
-- Interrupt Enable Set
type EIC_INTENSET_Register is record
-- External Interrupt Enable
EXTINT : EIC_INTENSET_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTENSET_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTFLAG_EXTINT_Field is HAL.UInt16;
-- Interrupt Flag Status and Clear
type EIC_INTFLAG_Register is record
-- External Interrupt
EXTINT : EIC_INTFLAG_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTFLAG_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Asynchronous Edge Detection Mode
type ASYNCH_ASYNCHSelect is
(-- Edge detection is clock synchronously operated
SYNC,
-- Edge detection is clock asynchronously operated
ASYNC)
with Size => 16;
for ASYNCH_ASYNCHSelect use
(SYNC => 0,
ASYNC => 1);
-- External Interrupt Asynchronous Mode
type EIC_ASYNCH_Register is record
-- Asynchronous Edge Detection Mode
ASYNCH : ASYNCH_ASYNCHSelect := SAM_SVD.EIC.SYNC;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_ASYNCH_Register use record
ASYNCH at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Input Sense Configuration 0
type CONFIG_SENSE0Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE0Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 1
type CONFIG_SENSE1Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE1Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 2
type CONFIG_SENSE2Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE2Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 3
type CONFIG_SENSE3Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE3Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 4
type CONFIG_SENSE4Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE4Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 5
type CONFIG_SENSE5Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE5Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 6
type CONFIG_SENSE6Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE6Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 7
type CONFIG_SENSE7Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE7Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- External Interrupt Sense Configuration
type EIC_CONFIG_Register is record
-- Input Sense Configuration 0
SENSE0 : CONFIG_SENSE0Select := SAM_SVD.EIC.NONE;
-- Filter Enable 0
FILTEN0 : Boolean := False;
-- Input Sense Configuration 1
SENSE1 : CONFIG_SENSE1Select := SAM_SVD.EIC.NONE;
-- Filter Enable 1
FILTEN1 : Boolean := False;
-- Input Sense Configuration 2
SENSE2 : CONFIG_SENSE2Select := SAM_SVD.EIC.NONE;
-- Filter Enable 2
FILTEN2 : Boolean := False;
-- Input Sense Configuration 3
SENSE3 : CONFIG_SENSE3Select := SAM_SVD.EIC.NONE;
-- Filter Enable 3
FILTEN3 : Boolean := False;
-- Input Sense Configuration 4
SENSE4 : CONFIG_SENSE4Select := SAM_SVD.EIC.NONE;
-- Filter Enable 4
FILTEN4 : Boolean := False;
-- Input Sense Configuration 5
SENSE5 : CONFIG_SENSE5Select := SAM_SVD.EIC.NONE;
-- Filter Enable 5
FILTEN5 : Boolean := False;
-- Input Sense Configuration 6
SENSE6 : CONFIG_SENSE6Select := SAM_SVD.EIC.NONE;
-- Filter Enable 6
FILTEN6 : Boolean := False;
-- Input Sense Configuration 7
SENSE7 : CONFIG_SENSE7Select := SAM_SVD.EIC.NONE;
-- Filter Enable 7
FILTEN7 : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_CONFIG_Register use record
SENSE0 at 0 range 0 .. 2;
FILTEN0 at 0 range 3 .. 3;
SENSE1 at 0 range 4 .. 6;
FILTEN1 at 0 range 7 .. 7;
SENSE2 at 0 range 8 .. 10;
FILTEN2 at 0 range 11 .. 11;
SENSE3 at 0 range 12 .. 14;
FILTEN3 at 0 range 15 .. 15;
SENSE4 at 0 range 16 .. 18;
FILTEN4 at 0 range 19 .. 19;
SENSE5 at 0 range 20 .. 22;
FILTEN5 at 0 range 23 .. 23;
SENSE6 at 0 range 24 .. 26;
FILTEN6 at 0 range 27 .. 27;
SENSE7 at 0 range 28 .. 30;
FILTEN7 at 0 range 31 .. 31;
end record;
-- External Interrupt Sense Configuration
type EIC_CONFIG_Registers is array (0 .. 1) of EIC_CONFIG_Register;
subtype EIC_DEBOUNCEN_DEBOUNCEN_Field is HAL.UInt16;
-- Debouncer Enable
type EIC_DEBOUNCEN_Register is record
-- Debouncer Enable
DEBOUNCEN : EIC_DEBOUNCEN_DEBOUNCEN_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_DEBOUNCEN_Register use record
DEBOUNCEN at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Debouncer Prescaler
type DPRESCALER_PRESCALER0Select is
(-- EIC clock divided by 2
DIV2,
-- EIC clock divided by 4
DIV4,
-- EIC clock divided by 8
DIV8,
-- EIC clock divided by 16
DIV16,
-- EIC clock divided by 32
DIV32,
-- EIC clock divided by 64
DIV64,
-- EIC clock divided by 128
DIV128,
-- EIC clock divided by 256
DIV256)
with Size => 3;
for DPRESCALER_PRESCALER0Select use
(DIV2 => 0,
DIV4 => 1,
DIV8 => 2,
DIV16 => 3,
DIV32 => 4,
DIV64 => 5,
DIV128 => 6,
DIV256 => 7);
-- Debouncer number of states
type DPRESCALER_STATES0Select is
(-- 3 low frequency samples
LFREQ3,
-- 7 low frequency samples
LFREQ7)
with Size => 1;
for DPRESCALER_STATES0Select use
(LFREQ3 => 0,
LFREQ7 => 1);
-- Debouncer Prescaler
type DPRESCALER_PRESCALER1Select is
(-- EIC clock divided by 2
DIV2,
-- EIC clock divided by 4
DIV4,
-- EIC clock divided by 8
DIV8,
-- EIC clock divided by 16
DIV16,
-- EIC clock divided by 32
DIV32,
-- EIC clock divided by 64
DIV64,
-- EIC clock divided by 128
DIV128,
-- EIC clock divided by 256
DIV256)
with Size => 3;
for DPRESCALER_PRESCALER1Select use
(DIV2 => 0,
DIV4 => 1,
DIV8 => 2,
DIV16 => 3,
DIV32 => 4,
DIV64 => 5,
DIV128 => 6,
DIV256 => 7);
-- Debouncer number of states
type DPRESCALER_STATES1Select is
(-- 3 low frequency samples
LFREQ3,
-- 7 low frequency samples
LFREQ7)
with Size => 1;
for DPRESCALER_STATES1Select use
(LFREQ3 => 0,
LFREQ7 => 1);
-- Pin Sampler frequency selection
type DPRESCALER_TICKONSelect is
(-- Clocked by GCLK
CLK_GCLK_EIC,
-- Clocked by Low Frequency Clock
CLK_LFREQ)
with Size => 1;
for DPRESCALER_TICKONSelect use
(CLK_GCLK_EIC => 0,
CLK_LFREQ => 1);
-- Debouncer Prescaler
type EIC_DPRESCALER_Register is record
-- Debouncer Prescaler
PRESCALER0 : DPRESCALER_PRESCALER0Select := SAM_SVD.EIC.DIV2;
-- Debouncer number of states
STATES0 : DPRESCALER_STATES0Select := SAM_SVD.EIC.LFREQ3;
-- Debouncer Prescaler
PRESCALER1 : DPRESCALER_PRESCALER1Select := SAM_SVD.EIC.DIV2;
-- Debouncer number of states
STATES1 : DPRESCALER_STATES1Select := SAM_SVD.EIC.LFREQ3;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Pin Sampler frequency selection
TICKON : DPRESCALER_TICKONSelect := SAM_SVD.EIC.CLK_GCLK_EIC;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_DPRESCALER_Register use record
PRESCALER0 at 0 range 0 .. 2;
STATES0 at 0 range 3 .. 3;
PRESCALER1 at 0 range 4 .. 6;
STATES1 at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
TICKON at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype EIC_PINSTATE_PINSTATE_Field is HAL.UInt16;
-- Pin State
type EIC_PINSTATE_Register is record
-- Read-only. Pin State
PINSTATE : EIC_PINSTATE_PINSTATE_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_PINSTATE_Register use record
PINSTATE at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- External Interrupt Controller
type EIC_Peripheral is record
-- Control A
CTRLA : aliased EIC_CTRLA_Register;
-- Non-Maskable Interrupt Control
NMICTRL : aliased EIC_NMICTRL_Register;
-- Non-Maskable Interrupt Flag Status and Clear
NMIFLAG : aliased EIC_NMIFLAG_Register;
-- Synchronization Busy
SYNCBUSY : aliased EIC_SYNCBUSY_Register;
-- Event Control
EVCTRL : aliased EIC_EVCTRL_Register;
-- Interrupt Enable Clear
INTENCLR : aliased EIC_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased EIC_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased EIC_INTFLAG_Register;
-- External Interrupt Asynchronous Mode
ASYNCH : aliased EIC_ASYNCH_Register;
-- External Interrupt Sense Configuration
CONFIG : aliased EIC_CONFIG_Registers;
-- Debouncer Enable
DEBOUNCEN : aliased EIC_DEBOUNCEN_Register;
-- Debouncer Prescaler
DPRESCALER : aliased EIC_DPRESCALER_Register;
-- Pin State
PINSTATE : aliased EIC_PINSTATE_Register;
end record
with Volatile;
for EIC_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
NMICTRL at 16#1# range 0 .. 7;
NMIFLAG at 16#2# range 0 .. 15;
SYNCBUSY at 16#4# range 0 .. 31;
EVCTRL at 16#8# range 0 .. 31;
INTENCLR at 16#C# range 0 .. 31;
INTENSET at 16#10# range 0 .. 31;
INTFLAG at 16#14# range 0 .. 31;
ASYNCH at 16#18# range 0 .. 31;
CONFIG at 16#1C# range 0 .. 63;
DEBOUNCEN at 16#30# range 0 .. 31;
DPRESCALER at 16#34# range 0 .. 31;
PINSTATE at 16#38# range 0 .. 31;
end record;
-- External Interrupt Controller
EIC_Periph : aliased EIC_Peripheral
with Import, Address => EIC_Base;
end SAM_SVD.EIC;
|
VitalijBondarenko/adanls | Ada | 12,895 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (c) 2014-2022 Vitalii Bondarenko <[email protected]> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and/or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
-- The functions to access the information for the locale.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
package L10n.Localeinfo is
-- The record whose components contain information about how numeric and
-- monetary values should be formatted in the current locale.
type Lconv_Record is record
-- Numeric (non-monetary) information.
---------------------------------------
Decimal_Point : Unbounded_String;
-- The radix character used to format non-monetary quantities.
Thousands_Sep : Unbounded_String;
-- The character used to separate groups of digits before the
-- decimal-point character in formatted non-monetary quantities.
Grouping : Unbounded_String;
-- A string whose elements taken as one-byte integer values indicate the
-- size of each group of digits in formatted non-monetary quantities.
-- Use either Thousands_Sep to separate the digit groups.
-- Each element is the number of digits in each group;
-- elements with higher indices are farther left.
-- An element with value Interfaces.C.UCHAR_MAX means that no further
-- grouping is done.
-- An element with value 0 means that the previous element is used
-- for all groups farther left.
-- Monetary information.
-------------------------
Int_Curr_Symbol : Unbounded_String;
-- The international currency symbol applicable to the current locale.
-- The first three characters contain the alphabetic international
-- currency symbol in accordance with those specified in the
-- ISO 4217:1995 standard. The fourth character (immediately preceding
-- the null byte) is the character used to separate the international
-- currency symbol from the monetary quantity.
Currency_Symbol : Unbounded_String;
-- The local currency symbol applicable to the current locale.
Mon_Decimal_Point : Unbounded_String;
-- The radix character used to format monetary quantities.
Mon_Thousands_Sep : Unbounded_String;
-- The separator for groups of digits before the decimal-point in
-- formatted monetary quantities.
Mon_Grouping : Unbounded_String;
-- A string whose elements taken as one-byte integer values indicate the
-- size of each group of digits in formatted monetary quantities.
-- Use either Mon_Thousands_Sep to separate the digit groups.
-- Each element is the number of digits in each group;
-- elements with higher indices are farther left.
-- An element with value Interfaces.C.UCHAR_MAX means that no further
-- grouping is done.
-- An element with value 0 means that the previous element is used
-- for all groups farther left.
Positive_Sign : Unbounded_String;
-- The string used to indicate a non-negative valued formatted monetary
-- quantity.
Negative_Sign : Unbounded_String;
-- The string used to indicate a negative valued formatted monetary
-- quantity.
Int_Frac_Digits : Natural;
-- The number of fractional digits (those after the decimal-point) to be
-- displayed in an internationally formatted monetary quantity.
Frac_Digits : Natural;
-- The number of fractional digits (those after the decimal-point) to be
-- displayed in a formatted monetary quantity.
P_Cs_Precedes : Natural;
-- Set to 1 if the Currency_Symbol precedes the value for a non-negative
-- formatted monetary quantity.
-- Set to 0 if the symbol succeeds the value.
P_Sep_By_Space : Natural;
-- Set to a value indicating the separation of the Currency_Symbol, the
-- sign string, and the value for a non-negative formatted monetary
-- quantity.
-- 0 No space separates the currency symbol and value.
-- 1 If the currency symbol and sign string are adjacent, a space
-- separates them from the value; otherwise, a space separates the
-- currency symbol from the value.
-- 2 If the currency symbol and sign string are adjacent, a space
-- separates them; otherwise, a space separates the sign string from
-- the value.
N_Cs_Precedes : Natural;
-- Set to 1 if the Currency_Symbol precedes the value for a negative
-- formatted monetary quantity. Set to 0 if the symbol succeeds the
-- value.
N_Sep_By_Space : Natural;
-- Set to a value indicating the separation of the Currency_Symbol, the
-- sign string, and the value for a negative formatted monetary quantity.
-- 0 No space separates the currency symbol and value.
-- 1 If the currency symbol and sign string are adjacent, a space
-- separates them from the value; otherwise, a space separates the
-- currency symbol from the value.
-- 2 If the currency symbol and sign string are adjacent, a space
-- separates them; otherwise, a space separates the sign string from
-- the value.
P_Sign_Posn : Natural;
-- Set to a value indicating the positioning of the Positive_Sign for a
-- non-negative formatted monetary quantity.
-- 0 Parentheses surround the quantity and Currency_Symbol.
-- 1 The sign string precedes the quantity and Currency_Symbol.
-- 2 The sign string follows the quantity and Currency_Symbol.
-- 3 The sign string immediately precedes the Currency_Symbol.
-- 4 The sign string immediately follows the Currency_Symbol.
N_Sign_Posn : Natural;
-- Set to a value indicating the positioning of the negative_sign for a
-- negative formatted monetary quantity.
-- 0 Parentheses surround the quantity and Currency_Symbol.
-- 1 The sign string precedes the quantity and Currency_Symbol.
-- 2 The sign string follows the quantity and Currency_Symbol.
-- 3 The sign string immediately precedes the Currency_Symbol.
-- 4 The sign string immediately follows the Currency_Symbol.
Int_P_Cs_Precedes : Natural;
-- Set to 1 or 0 if the Int_Curr_Symbol respectively precedes or
-- succeeds the value for a non-negative internationally formatted
-- monetary quantity.
Int_P_Sep_By_Space : Natural;
-- Set to a value indicating the separation of the Int_Curr_Symbol, the
-- sign string, and the value for a negative internationally formatted
-- monetary quantity.
-- 0 No space separates the currency symbol and value.
-- 1 If the currency symbol and sign string are adjacent, a space
-- separates them from the value; otherwise, a space separates the
-- currency symbol from the value.
-- 2 If the currency symbol and sign string are adjacent, a space
-- separates them; otherwise, a space separates the sign string from
-- the value.
Int_N_Cs_Precedes : Natural;
-- Set to 1 or 0 if the Int_Curr_Symbol respectively precedes or
-- succeeds the value for a negative internationally formatted monetary
-- quantity.
Int_N_Sep_By_Space : Natural;
-- Set to a value indicating the separation of the Int_Curr_Symbol, the
-- sign string, and the value for a negative internationally formatted
-- monetary quantity.
-- 0 No space separates the currency symbol and value.
-- 1 If the currency symbol and sign string are adjacent, a space
-- separates them from the value; otherwise, a space separates the
-- currency symbol from the value.
-- 2 If the currency symbol and sign string are adjacent, a space
-- separates them; otherwise, a space separates the sign string from
-- the value.
Int_P_Sign_Posn : Natural;
-- Set to a value indicating the positioning of the Positive_Sign for a
-- non-negative internationally formatted monetary quantity.
-- 0 Parentheses surround the quantity and Int_Curr_Symbol.
-- 1 The sign string precedes the quantity and Int_Curr_Symbol.
-- 2 The sign string follows the quantity and Int_Curr_Symbol.
-- 3 The sign string immediately precedes the Int_Curr_Symbol.
-- 4 The sign string immediately follows the Int_Curr_Symbol.
Int_N_Sign_Posn : Natural;
-- Set to a value indicating the positioning of the Negative_Sign for a
-- negative internationally formatted monetary quantity.
-- 0 Parentheses surround the quantity and Int_Curr_Symbol.
-- 1 The sign string precedes the quantity and Int_Curr_Symbol.
-- 2 The sign string follows the quantity and Int_Curr_Symbol.
-- 3 The sign string immediately precedes the Int_Curr_Symbol.
-- 4 The sign string immediately follows the Int_Curr_Symbol.
end record;
type Lconv_Access is access all Lconv_Record;
function Localeconv return Lconv_Access;
-- Returns a record whose components contain information about how numeric
-- and monetary values should be formatted in the current locale.
-- Localeinfo in C-types
--
-- The record whose components contain information about how numeric and
-- monetary values should be formatted in the current locale.
type C_Lconv_Record is record
Decimal_Point : chars_ptr;
Thousands_Sep : chars_ptr;
Grouping : chars_ptr;
Int_Curr_Symbol : chars_ptr;
Currency_Symbol : chars_ptr;
Mon_Decimal_Point : chars_ptr;
Mon_Thousands_Sep : chars_ptr;
Mon_Grouping : chars_ptr;
Positive_Sign : chars_ptr;
Negative_Sign : chars_ptr;
Int_Frac_Digits : unsigned_char;
Frac_Digits : unsigned_char;
P_Cs_Precedes : unsigned_char;
P_Sep_By_Space : unsigned_char;
N_Cs_Precedes : unsigned_char;
N_Sep_By_Space : unsigned_char;
P_Sign_Posn : unsigned_char;
N_Sign_Posn : unsigned_char;
Int_P_Cs_Precedes : unsigned_char;
Int_P_Sep_By_Space : unsigned_char;
Int_N_Cs_Precedes : unsigned_char;
Int_N_Sep_By_Space : unsigned_char;
Int_P_Sign_Posn : unsigned_char;
Int_N_Sign_Posn : unsigned_char;
end record;
pragma Convention (C, C_Lconv_Record);
type C_Lconv_Access is access all C_Lconv_Record;
function C_Localeconv return C_Lconv_Access;
pragma Import (C, C_Localeconv, "wrap_localeconv");
end L10n.Localeinfo;
|
DrenfongWong/tkm-rpc | Ada | 269 | ads | with Tkmrpc.Request;
with Tkmrpc.Response;
package Tkmrpc.Operation_Handlers.Cfg.Tkm_Version is
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type);
-- Handler for the tkm_version operation.
end Tkmrpc.Operation_Handlers.Cfg.Tkm_Version;
|
Samsung/TizenRT | Ada | 3,958 | adb | --------------------------------------------------------------- -
-- ZLib for Ada thick binding. --
-- --
-- Copyright(C) 2002 - 2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: read.adb, v 1.8 2004 / 05 / 31 10:53:40 vagul Exp $
-- Test / demo program for the generic read interface.
with Ada.Numerics.Discrete_Random;
with Ada.Streams;
with Ada.Text_IO;
with ZLib;
procedure Read is
use Ada.Streams;
----------------------------------- -
-- Test configuration parameters --
------------------------------------
File_Size : Stream_Element_Offset : = 100_000;
Continuous :
constant Boolean :
= False;
- - If this constant is True, the test would be repeated again and again,
-- with increment File_Size for every iteration.
Header : constant ZLib.Header_Type : = ZLib.Default;
- - Do not use Header other than Default in ZLib versions 1.1.4 and older.
Init_Random : constant : = 8;
- - We are using the same random sequence, in case of we catch bug,
-- so we would be able to reproduce it.
-- End --
Pack_Size : Stream_Element_Offset;
Offset :
Stream_Element_Offset;
Filter :
ZLib.Filter_Type;
subtype Visible_Symbols
is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is new
Ada.Numerics.Discrete_Random(Visible_Symbols);
Gen :
Random_Elements.Generator;
Period :
constant Stream_Element_Offset :
= 200;
- - Period constant variable for random generator not to be very random.
-- Bigger period, harder random.
Read_Buffer : Stream_Element_Array(1 .. 2048);
Read_First :
Stream_Element_Offset;
Read_Last :
Stream_Element_Offset;
procedure Reset;
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
- - this procedure is for generic instantiation of
-- ZLib.Read
-- reading data from the File_In.
procedure Read is new ZLib.Read
(Read,
Read_Buffer,
Rest_First => Read_First,
Rest_Last => Read_Last);
--------- -
-- Read --
----------
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Last :
= Stream_Element_Offset'Min
(Item'Last,
Item'First + File_Size - Offset);
for J in Item'First .. Last loop
if J < Item'First + Period then
Item(J) : = Random_Elements.Random(Gen);
else
{
Item(J) : = Item(J - Period);
}
end if ;
Offset : = Offset + 1;
end loop;
end Read;
-----------
-- Reset --
---------- -
procedure Reset is
begin
Random_Elements.Reset(Gen, Init_Random);
Pack_Size : = 0;
Offset : = 1;
Read_First : = Read_Buffer'Last + 1;
Read_Last : = Read_Buffer'Last;
end Reset;
begin
Ada.Text_IO.Put_Line("ZLib " & ZLib.Version);
loop
for Level in ZLib.Compression_Level'Range loop
Ada.Text_IO.Put("Level ="
& ZLib.Compression_Level'Image (Level));
- - Deflate using generic instantiation.
ZLib.Deflate_Init
(Filter,
Level,
Header => Header);
Reset;
Ada.Text_IO.Put
(Stream_Element_Offset'Image (File_Size) & " ->");
loop
declare
Buffer : Stream_Element_Array(1 .. 1024);
Last : Stream_Element_Offset;
begin
Read(Filter, Buffer, Last);
Pack_Size : = Pack_Size + Last - Buffer'First + 1;
exit when Last < Buffer'Last;
end;
end loop;
Ada.Text_IO.Put_Line(Stream_Element_Offset'Image (Pack_Size));
ZLib.Close(Filter);
end loop;
exit when not Continuous;
File_Size : = File_Size + 1;
end loop;
end Read;
|
zhmu/ananas | Ada | 7,936 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (VxWorks 7 Version x86 for RTPs) --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package System is
pragma Pure;
-- Note that we take advantage of the implementation permission to make
-- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-- 2005, this is Pure in any case (AI-362).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := Standard'Max_Integer_Size - 1;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 1.0 / 60.0;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := 32;
Memory_Size : constant := 2 ** 32;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := Low_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
-- Ada priorities are mapped to VxWorks priorities using the following
-- transformation: 255 - Ada Priority
-- Ada priorities are used as follows:
-- 256 is reserved for the VxWorks kernel
-- 248 - 255 correspond to hardware interrupt levels 0 .. 7
-- 247 is a catchall default "interrupt" priority for signals,
-- allowing higher priority than normal tasks, but lower than
-- hardware priority levels. Protected Object ceilings can
-- override these values.
-- 246 is used by the Interrupt_Manager task
Max_Priority : constant Positive := 245;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 245;
subtype Interrupt_Priority is Any_Priority range 246 .. 255;
Default_Priority : constant Priority := 122;
private
pragma Linker_Options ("--specs=vxworks7-x86-rtp-base-link.spec");
-- Define the symbol wrs_rtp_base
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
Signed_Zeros : constant Boolean := True;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := True;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Atomic_Primitives : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := False;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := True;
Executable_Extension : constant String := ".vxe";
end System;
|
charlie5/cBound | Ada | 1,907 | 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_glx_get_color_table_parameteriv_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;
pad1 : aliased swig.int8_t_Array (0 .. 3);
n : aliased Interfaces.Unsigned_32;
datum : aliased Interfaces.Integer_32;
pad2 : aliased swig.int8_t_Array (0 .. 11);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_color_table_parameteriv_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_color_table_parameteriv_reply_t.Item,
Element_Array =>
xcb.xcb_glx_get_color_table_parameteriv_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_glx_get_color_table_parameteriv_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_color_table_parameteriv_reply_t.Pointer,
Element_Array =>
xcb.xcb_glx_get_color_table_parameteriv_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_color_table_parameteriv_reply_t;
|
DrenfongWong/tkm-rpc | Ada | 951 | ads | with Tkmrpc.Types;
with Tkmrpc.Operations.Cfg;
package Tkmrpc.Request.Cfg.Tkm_Limits is
Data_Size : constant := 0;
Padding_Size : constant := Request.Body_Size - Data_Size;
subtype Padding_Range is Natural range 1 .. Padding_Size;
subtype Padding_Type is Types.Byte_Sequence (Padding_Range);
type Request_Type is record
Header : Request.Header_Type;
Padding : Padding_Type;
end record;
for Request_Type use record
Header at 0 range 0 .. (Request.Header_Size * 8) - 1;
Padding at Request.Header_Size + Data_Size range
0 .. (Padding_Size * 8) - 1;
end record;
for Request_Type'Size use Request.Request_Size * 8;
Null_Request : constant Request_Type :=
Request_Type'
(Header =>
Request.Header_Type'(Operation => Operations.Cfg.Tkm_Limits,
Request_Id => 0),
Padding => Padding_Type'(others => 0));
end Tkmrpc.Request.Cfg.Tkm_Limits;
|
reznikmm/matreshka | Ada | 5,442 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A behavioral feature is a feature of a classifier that specifies an aspect
-- of the behavior of its instances.
------------------------------------------------------------------------------
with AMF.CMOF.Features;
limited with AMF.CMOF.Named_Elements;
with AMF.CMOF.Namespaces;
limited with AMF.CMOF.Parameters.Collections;
limited with AMF.CMOF.Types.Collections;
package AMF.CMOF.Behavioral_Features is
pragma Preelaborate;
type CMOF_Behavioral_Feature is limited interface
and AMF.CMOF.Features.CMOF_Feature
and AMF.CMOF.Namespaces.CMOF_Namespace;
type CMOF_Behavioral_Feature_Access is
access all CMOF_Behavioral_Feature'Class;
for CMOF_Behavioral_Feature_Access'Storage_Size use 0;
not overriding function Get_Owned_Parameter
(Self : not null access constant CMOF_Behavioral_Feature)
return AMF.CMOF.Parameters.Collections.Ordered_Set_Of_CMOF_Parameter is abstract;
-- Getter of BehavioralFeature::ownedParameter.
--
-- Specifies the ordered set of formal parameters of this
-- BehavioralFeature.
not overriding function Get_Raised_Exception
(Self : not null access constant CMOF_Behavioral_Feature)
return AMF.CMOF.Types.Collections.Set_Of_CMOF_Type is abstract;
-- Getter of BehavioralFeature::raisedException.
--
-- References the Types representing exceptions that may be raised during
-- an invocation of this feature.
overriding function Is_Distinguishable_From
(Self : not null access constant CMOF_Behavioral_Feature;
N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access;
Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access)
return Boolean is abstract;
-- Operation BehavioralFeature::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two
-- BehavioralFeatures may coexist in the same Namespace. It specifies that
-- they have to have different signatures.
end AMF.CMOF.Behavioral_Features;
|
reznikmm/matreshka | Ada | 4,027 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Cell_Protect_Attributes;
package Matreshka.ODF_Style.Cell_Protect_Attributes is
type Style_Cell_Protect_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Cell_Protect_Attributes.ODF_Style_Cell_Protect_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Cell_Protect_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Cell_Protect_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Cell_Protect_Attributes;
|
reznikmm/matreshka | Ada | 3,838 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.ODF_Attributes.Style.Text_Underline_Style is
type Style_Text_Underline_Style_Node is
new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record;
type Style_Text_Underline_Style_Access is
access all Style_Text_Underline_Style_Node'Class;
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Underline_Style_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Attributes.Style.Text_Underline_Style;
|
AdaCore/gpr | Ada | 59 | adb | procedure hello is
begin
declare begin null; end;
end;
|
reznikmm/matreshka | Ada | 4,591 | 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.Parallel_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Parallel_Attribute_Node is
begin
return Self : Draw_Parallel_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_Parallel_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Parallel_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Parallel_Attribute,
Draw_Parallel_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Parallel_Attributes;
|
reznikmm/matreshka | Ada | 3,690 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Remove_Structural_Feature_Value_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Remove_Structural_Feature_Value_Action, UML_Remove_Structural_Feature_Value_Action_Access);
|
AdaCore/Ada_Drivers_Library | Ada | 14,898 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with HAL.I2C; use HAL.I2C;
with HAL.Time;
package SGTL5000 is
type SGTL5000_DAC (Port : not null Any_I2C_Port;
Time : not null HAL.Time.Any_Delays) is
tagged limited private;
function Valid_Id (This : SGTL5000_DAC) return Boolean;
-- Glossary:
-- DAP : Digital Audio Processing
-- ZCD : Zero Cross Detector
-------------
-- Volumes --
-------------
subtype DAC_Volume is UInt8 range 16#3C# .. 16#F0#;
-- 16#3C# => 0 dB
-- 16#3D# => -0.5 dB
-- ...
-- 16#F0# => -90 dB
procedure Set_DAC_Volume (This : in out SGTL5000_DAC;
Left, Right : DAC_Volume);
subtype ADC_Volume is UInt4;
-- 16#0# => 0 dB
-- 16#1# => +1.5 dB
-- ...
-- 16#F# => +22.5 dB
procedure Set_ADC_Volume (This : in out SGTL5000_DAC;
Left, Right : ADC_Volume;
Minus_6db : Boolean);
subtype HP_Volume is UInt7;
-- 16#00# => +12 dB
-- 16#01# => +11.5 dB
-- 16#18# => 0 dB
-- ...
-- 16#7F# => -51.5 dB
procedure Set_Headphones_Volume (This : in out SGTL5000_DAC;
Left, Right : HP_Volume);
subtype Line_Out_Volume is UInt5;
procedure Set_Line_Out_Volume (This : in out SGTL5000_DAC;
Left, Right : Line_Out_Volume);
procedure Mute_Headphones (This : in out SGTL5000_DAC;
Mute : Boolean := True);
procedure Mute_Line_Out (This : in out SGTL5000_DAC;
Mute : Boolean := True);
procedure Mute_ADC (This : in out SGTL5000_DAC;
Mute : Boolean := True);
procedure Mute_DAC (This : in out SGTL5000_DAC;
Mute : Boolean := True);
-------------------
-- Power control --
-------------------
type Power_State is (On, Off);
procedure Set_Power_Control (This : in out SGTL5000_DAC;
ADC : Power_State;
DAC : Power_State;
DAP : Power_State;
I2S_Out : Power_State;
I2S_In : Power_State);
type Analog_Ground_Voltage is new UInt5;
-- 25mv steps
-- 16#00# => 0.800 V
-- 16#1F# => 1.575 V
type Current_Bias is new UInt3;
-- 16#0# => Nominal
-- 16#1#-16#3# => +12.5%
-- 16#4# => -12.5%
-- 16#5# => -25%
-- 16#6# => -37.5%
-- 16#7# => -50%
procedure Set_Reference_Control (This : in out SGTL5000_DAC;
VAG : Analog_Ground_Voltage;
Bias : Current_Bias;
Slow_VAG_Ramp : Boolean);
type Short_Detector_Level is new UInt3;
-- 16#3# => 25 mA
-- 16#2# => 50 mA
-- 16#1# => 75 mA
-- 16#0# => 100 mA
-- 16#4# => 125 mA
-- 16#5# => 150 mA
-- 16#6# => 175 mA
-- 16#7# => 200 mA
procedure Set_Short_Detectors (This : in out SGTL5000_DAC;
Right_HP : Short_Detector_Level;
Left_HP : Short_Detector_Level;
Center_HP : Short_Detector_Level;
Mode_LR : UInt2;
Mode_CM : UInt2);
type Linear_Regulator_Out_Voltage is new UInt4;
-- 16#0# => 1.60
-- 16#F# => 0.85
type Charge_Pump_Source is (VDDA, VDDIO);
procedure Set_Linereg_Control (This : in out SGTL5000_DAC;
Charge_Pump_Src_Override : Boolean;
Charge_Pump_Src : Charge_Pump_Source;
Linereg_Out_Voltage : Linear_Regulator_Out_Voltage);
type Lineout_Current is (C_0_18ma, C_0_27ma, C_0_36ma, C_0_45ma, C_0_54ma)
with Size => 4;
for Lineout_Current use (C_0_18ma => 0,
C_0_27ma => 1,
C_0_36ma => 3,
C_0_45ma => 7,
C_0_54ma => 15);
procedure Set_Lineout_Control (This : in out SGTL5000_DAC;
Out_Current : Lineout_Current;
Amp_Analog_GND_Voltage : UInt6);
-- Amp_Analog_GND_Voltage (15mV steps), usually VDDIO/2:
-- 0x00 = 0.800 V
-- ...
-- 0x1F = 1.575 V
-- ...
-- 0x23 = 1.675 V
-- 0x24-0x3F are invalid
procedure Set_Analog_Power (This : in out SGTL5000_DAC;
DAC_Mono : Boolean := False;
Linreg_Simple_PowerUp : Boolean := False;
Startup_PowerUp : Boolean := False;
VDDC_Charge_Pump_PowerUp : Boolean := False;
PLL_PowerUp : Boolean := False;
Linereg_D_PowerUp : Boolean := False;
VCOAmp_PowerUp : Boolean := False;
VAG_PowerUp : Boolean := False;
ADC_Mono : Boolean := False;
Reftop_PowerUp : Boolean := False;
Headphone_PowerUp : Boolean := False;
DAC_PowerUp : Boolean := False;
Capless_Headphone_PowerUp : Boolean := False;
ADC_PowerUp : Boolean := False;
Linout_PowerUp : Boolean := False);
-----------------
-- I2S control --
-----------------
type Rate_Mode is (SYS_FS,
Half_SYS_FS,
Quarter_SYS_FS,
Sixth_SYS_FS);
type SYS_FS_Freq is (SYS_FS_32kHz,
SYS_FS_44kHz,
SYS_FS_48kHz,
SYS_FS_96kHz);
type MCLK_Mode is (MCLK_256FS,
MCLK_384FS,
MCLK_512FS,
Use_PLL);
procedure Set_Clock_Control (This : in out SGTL5000_DAC;
Rate : Rate_Mode;
FS : SYS_FS_Freq;
MCLK : MCLK_Mode);
procedure Set_PLL (This : in out SGTL5000_DAC;
PLL_Output_Freq : Natural;
MCLK_Freq : Natural);
-- If sampling frequency = 44.1kHz then PLL_Output_Freq should be 180.6336
-- MHz else PLL_Output_Freq should be 196.608 MHz
type SCLKFREQ_Mode is (SCLKFREQ_64FS,
SCLKFREQ_32FS);
type Data_Len_Mode is (Data_32b,
Data_24b,
Data_20b,
Data_16b);
type I2S_Mode is (I2S_Left_Justified,
Right_Justified,
PCM);
procedure Set_I2S_Control (This : in out SGTL5000_DAC;
SCLKFREQ : SCLKFREQ_Mode;
Invert_SCLK : Boolean;
Master_Mode : Boolean;
Data_Len : Data_Len_Mode;
I2S : I2S_Mode;
LR_Align : Boolean;
LR_Polarity : Boolean);
------------------
-- Audio Switch --
------------------
type ADC_Source is (Microphone, Line_In);
type DAP_Source is (ADC, I2S_In);
type DAP_Mix_Source is (ADC, I2S_In);
type DAC_Source is (ADC, I2S_In, DAP);
type HP_Source is (Line_In, DAC);
type I2S_Out_Source is (ADC, I2S_In, DAP);
procedure Select_ADC_Source (This : in out SGTL5000_DAC;
Source : ADC_Source;
Enable_ZCD : Boolean);
procedure Select_DAP_Source (This : in out SGTL5000_DAC;
Source : DAP_Source);
procedure Select_DAP_Mix_Source (This : in out SGTL5000_DAC;
Source : DAP_Mix_Source);
procedure Select_DAC_Source (This : in out SGTL5000_DAC;
Source : DAC_Source);
procedure Select_HP_Source (This : in out SGTL5000_DAC;
Source : HP_Source;
Enable_ZCD : Boolean);
procedure Select_I2S_Out_Source (This : in out SGTL5000_DAC;
Source : I2S_Out_Source);
private
SGTL5000_Chip_ID : constant := 16#A000#;
SGTL5000_QFN20_I2C_Addr : constant I2C_Address := 20;
type SGTL5000_DAC (Port : not null Any_I2C_Port;
Time : not null HAL.Time.Any_Delays) is
tagged limited null record;
procedure I2C_Write (This : in out SGTL5000_DAC;
Reg : UInt16;
Value : UInt16);
function I2C_Read (This : SGTL5000_DAC;
Reg : UInt16)
return UInt16;
procedure Modify (This : in out SGTL5000_DAC;
Reg : UInt16;
Mask : UInt16;
Value : UInt16);
------------------------
-- Register addresses --
------------------------
Chip_ID_Reg : constant := 16#0000#;
DIG_POWER_REG : constant := 16#0002#;
CLK_CTRL_REG : constant := 16#0004#;
I2S_CTRL_REG : constant := 16#0006#;
SSS_CTRL_REG : constant := 16#000A#;
ADCDAC_CTRL_REG : constant := 16#000E#;
DAC_VOL_REG : constant := 16#0010#;
PAD_STRENGTH_REG : constant := 16#0014#;
ANA_ADC_CTRL_REG : constant := 16#0020#;
ANA_HP_CTRL_REG : constant := 16#0022#;
ANA_CTRL_REG : constant := 16#0024#;
LINREG_CTRL_REG : constant := 16#0026#;
REF_CTRL_REG : constant := 16#0028#;
MIC_CTRL_REG : constant := 16#002A#;
LINE_OUT_CTRL_REG : constant := 16#002C#;
LINE_OUT_VOL_REG : constant := 16#002E#;
ANA_POWER_REG : constant := 16#0030#;
PLL_CTRL_REG : constant := 16#0032#;
CLK_TOP_CTRL_REG : constant := 16#0034#;
ANA_STATUS_REG : constant := 16#0036#;
ANA_TEST1_REG : constant := 16#0038#;
ANA_TEST2_REG : constant := 16#003A#;
SHORT_CTRL_REG : constant := 16#003C#;
DAP_CONTROL_REG : constant := 16#0100#;
DAP_PEQ_REG : constant := 16#0102#;
DAP_BASS_ENHANCE_REG : constant := 16#0104#;
DAP_BASS_ENHANCE_CTRL_REG : constant := 16#0106#;
DAP_AUDIO_EQ_REG : constant := 16#0108#;
DAP_SGTL_SURROUND_REG : constant := 16#010A#;
DAP_FILTER_COEF_ACCESS_REG : constant := 16#010C#;
DAP_COEF_WR_B0_MSB_REG : constant := 16#010E#;
DAP_COEF_WR_B0_LSB_REG : constant := 16#0110#;
DAP_AUDIO_EQ_BASS_BAND0_REG : constant := 16#0116#;
DAP_AUDIO_EQ_BAND1_REG : constant := 16#0118#;
DAP_AUDIO_EQ_BAND2_REG : constant := 16#011A#;
DAP_AUDIO_EQ_BAND3_REG : constant := 16#011C#;
DAP_AUDIO_EQ_TREBLE_BAND4_REG : constant := 16#011E#;
DAP_MAIN_CHAN_REG : constant := 16#0120#;
DAP_MIX_CHAN_REG : constant := 16#0122#;
DAP_AVC_CTRL_REG : constant := 16#0124#;
DAP_AVC_THRESHOLD_REG : constant := 16#0126#;
DAP_AVC_ATTACK_REG : constant := 16#0128#;
DAP_AVC_DECAY_REG : constant := 16#012A#;
DAP_COEF_WR_B1_MSB_REG : constant := 16#012C#;
DAP_COEF_WR_B1_LSB_REG : constant := 16#012E#;
DAP_COEF_WR_B2_MSB_REG : constant := 16#0130#;
DAP_COEF_WR_B2_LSB_REG : constant := 16#0132#;
DAP_COEF_WR_A1_MSB_REG : constant := 16#0134#;
DAP_COEF_WR_A1_LSB_REG : constant := 16#0136#;
DAP_COEF_WR_A2_MSB_REG : constant := 16#0138#;
DAP_COEF_WR_A2_LSB_REG : constant := 16#013A#;
end SGTL5000;
|
reznikmm/matreshka | Ada | 3,674 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This is hash function compatible with standard containers.
------------------------------------------------------------------------------
with Ada.Containers;
function League.Strings.Hash
(Item : Universal_String) return Ada.Containers.Hash_Type;
pragma Preelaborate (League.Strings.Hash);
pragma Inline (League.Strings.Hash);
|
shintakezou/drake | Ada | 4,511 | adb | with Ada.Containers.Array_Sorting;
with System.Long_Long_Integer_Types;
procedure Ada.Containers.Generic_Constrained_Array_Sort (
Container : in out Array_Type)
is
subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer;
begin
if Index_Type'Pos (Index_Type'First) in
Long_Long_Integer (Word_Integer'First) ..
Long_Long_Integer (Word_Integer'Last)
and then Index_Type'Pos (Index_Type'Last) in
Long_Long_Integer (Word_Integer'First) ..
Long_Long_Integer (Word_Integer'Last)
then
declare
type Context_Type is limited record
Container : not null access Array_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
begin
return Context.Container (Left_Index) <
Context.Container (Right_Index);
end LT;
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address);
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address)
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
Temp : constant Element_Type := Context.Container (Left_Index);
begin
Context.Container (Left_Index) := Context.Container (Right_Index);
Context.Container (Right_Index) := Temp;
end Swap;
Context : Context_Type :=
(Container => Container'Unrestricted_Access);
begin
Array_Sorting.In_Place_Merge_Sort (
Index_Type'Pos (Container'First),
Index_Type'Pos (Container'Last),
Context'Address,
LT => LT'Access,
Swap => Swap'Access);
end;
else
declare
type Context_Type is limited record
Container : not null access Array_Type;
Offset : Long_Long_Integer;
end record;
pragma Suppress_Initialization (Context_Type);
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Left) + Context.Offset);
Right_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Right) + Context.Offset);
begin
return Context.Container (Left_Index) <
Context.Container (Right_Index);
end LT;
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address);
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address)
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Left) + Context.Offset);
Right_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Right) + Context.Offset);
Temp : constant Element_Type := Context.Container (Left_Index);
begin
Context.Container (Left_Index) := Context.Container (Right_Index);
Context.Container (Right_Index) := Temp;
end Swap;
Offset : constant Long_Long_Integer :=
Index_Type'Pos (Container'First);
Context : Context_Type := (Container'Unrestricted_Access, Offset);
begin
Array_Sorting.In_Place_Merge_Sort (
0,
Word_Integer (Index_Type'Pos (Container'Last) - Offset),
Context'Address,
LT => LT'Access,
Swap => Swap'Access);
end;
end if;
end Ada.Containers.Generic_Constrained_Array_Sort;
|
AdaCore/libadalang | Ada | 224 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Foo is
#if X'Defined then
procedure $X is
begin
Put_Line ("$X");
end $X;
#else
procedure Bar is null;
#end if;
begin
Bar;
pragma Test_Statement;
end Foo;
|
tum-ei-rcs/StratoX | Ada | 3,948 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . E X C E P T I O N S --
-- (Version for No Exception Handlers/No_Exception_Propagation) --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2014, 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. --
-- --
-- --
-- --
-- --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Version is for use when there are no handlers in the partition (i.e. either
-- of Restriction No_Exception_Handlers or No_Exception_Propagation is set).
with System;
package Ada.Exceptions is
pragma Preelaborate;
-- In accordance with Ada 2005 AI-362
type Exception_Id is private;
pragma Preelaborable_Initialization (Exception_Id);
Null_Id : constant Exception_Id;
procedure Raise_Exception (E : Exception_Id; Message : String := "");
pragma No_Return (Raise_Exception);
-- Unconditionally call __gnat_last_chance_handler. Message should be a
-- null terminated string. Note that the exception is still raised even
-- if E is the null exception id. This is a deliberate simplification for
-- this profile (the use of Raise_Exception with a null id is very rare in
-- any case, and this way we avoid introducing Raise_Exception_Always and
-- we also avoid the if test in Raise_Exception).
private
------------------
-- Exception_Id --
------------------
type Exception_Id is access all System.Address;
Null_Id : constant Exception_Id := null;
pragma Inline_Always (Raise_Exception);
end Ada.Exceptions;
|
reznikmm/matreshka | Ada | 3,659 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Attributes.Style.Country_Asian is
type ODF_Style_Country_Asian is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_Style_Country_Asian is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Style.Country_Asian;
|
AdaCore/gpr | Ada | 22 | ads | package PkgA is end;
|
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.Chart_Include_Hidden_Cells_Attributes is
pragma Preelaborate;
type ODF_Chart_Include_Hidden_Cells_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Include_Hidden_Cells_Attribute_Access is
access all ODF_Chart_Include_Hidden_Cells_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Include_Hidden_Cells_Attributes;
|
strenkml/EE368 | Ada | 797 | ads |
with Ada.Containers.Vectors; use Ada.Containers;
with Ada.Finalization; use Ada.Finalization;
with Benchmark; use Benchmark;
with Memory; use Memory;
package Benchmark_Runner is
type Runner_Type is new Limited_Controlled with private;
procedure Register_Benchmark(runner : in out Runner_Type;
benchmark : in Benchmark_Pointer);
procedure Run(runner : in out Runner_Type;
mem : in Memory_Pointer);
private
package Benchmark_Vectors is new Vectors(Natural, Benchmark_Pointer);
type Runner_Type is new Limited_Controlled with record
benchmarks : Benchmark_Vectors.Vector;
end record;
overriding
procedure Finalize(runner : in out Runner_Type);
end Benchmark_Runner;
|
persan/gprTools | Ada | 4,228 | adb | with GNAT.Spitbol; use GNAT.Spitbol;
with Ada.Strings.Unbounded;
with GNAT.Expect;
with GNATCOLL.Projects;
with GNATCOLL.Utils;
with GNAT.OS_Lib; use GNAT.OS_Lib;
use GNAT.Expect;
with Ada.Unchecked_Deallocation;
package body GPR_Tools.Gprslaves.DB is
use GNAT.Spitbol.Table_VString;
use type Ada.Strings.Unbounded.Unbounded_String;
--------------
-- Register --
--------------
procedure Register
(Self : in out Table;
Host : Host_Address;
Keys : GNAT.Spitbol.Table_VString.Table)
is
begin
for I of Self.Hosts loop
if I.Host = Host then
I.Keys := Keys;
return;
end if;
end loop;
Self.Hosts.Append (Info_Struct'(Host, Keys));
end Register;
----------
-- Find --
----------
function Find
(Self : Table;
Keys : GNAT.Spitbol.Table_VString.Table)
return Host_Info_Vectors.Vector
is
begin
return Ret : Host_Info_Vectors.Vector do
for Candidate of Self.Hosts loop
declare
Search_Keys : constant Table_Array := Convert_To_Array (Keys);
OK : Boolean := True;
begin
for I of Search_Keys loop
if Present (Candidate.Keys, I.Name) then
if Get (Candidate.Keys, I.Name) /= I.Value then
OK := False;
end if;
else
OK := False;
end if;
if OK then
Ret.Append (Candidate.Host);
end if;
end loop;
end;
end loop;
end return;
end Find;
procedure Append (Self : in out Info_Struct;
Key_Name : String;
Key_Value : String) is
begin
Set (Self.Keys, Key_Name, V (Key_Value));
end Append;
function Get_Free_Port (Default : GNAT.Sockets.Port_Type := 8484) return GNAT.Sockets.Port_Type is
S : GNAT.Sockets.Socket_Type;
A : GNAT.Sockets.Sock_Addr_Type;
begin
A.Addr := GNAT.Sockets.Any_Inet_Addr;
A.Port := Default;
GNAT.Sockets.Create_Socket (S);
begin
GNAT.Sockets.Bind_Socket (S, A);
GNAT.Sockets.Close_Socket (S);
exception
when others =>
A.Port := GNAT.Sockets.Any_Port;
GNAT.Sockets.Bind_Socket (S, A);
A := GNAT.Sockets.Get_Socket_Name (S);
GNAT.Sockets.Close_Socket (S);
end;
return A.Port;
end Get_Free_Port;
function Get_Gnat_Version return String is
Env : GNATCOLL.Projects.Project_Environment_Access;
Fd : GNAT.Expect.Process_Descriptor_Access;
Gnatls_Args : GNAT.OS_Lib.Argument_List_Access :=
Argument_String_To_List ("gnatls" & " -v");
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Process_Descriptor'Class, Process_Descriptor_Access);
begin
GNATCOLL.Projects.Initialize (Env);
GNATCOLL.Projects.Spawn_Gnatls (Self => Env.all, Fd => Fd, Gnatls_Args => Gnatls_Args, Errors => null);
if Fd /= null then
declare
S : constant String := GNATCOLL.Utils.Get_Command_Output (Fd);
Index : Integer := S'First;
First : Integer;
Last : Integer;
begin
GNATCOLL.Utils.Skip_To_String (S, Index, "GNATLS");
while S (Index) /= ' ' loop
Index := Index + 1;
end loop;
GNATCOLL.Utils.Skip_Blanks (S, Index);
First := Index;
Last := GNATCOLL.Utils.Line_End (S, Index);
Unchecked_Free (Fd);
return S (First .. Last);
end;
end if;
Free (Gnatls_Args);
return "--";
end Get_Gnat_Version;
procedure Initialize (Self : in out Info_Struct;
HostName : String := GNAT.Sockets.Host_Name;
Port : GNAT.Sockets.Port_Type := Get_Free_Port) is
begin
Self.Host := (V (HostName), Port);
Self.Append ("GNAT", Get_Gnat_Version);
end Initialize;
end GPR_Tools.Gprslaves.DB;
|
io7m/coreland-openal-ada | Ada | 3,463 | adb | with OpenAL.Thin;
with Interfaces.C;
with Interfaces.C.Strings;
package body OpenAL.Global is
package C renames Interfaces.C;
package C_Strings renames Interfaces.C.Strings;
function Get_String (Parameter : Types.Enumeration_t) return C_Strings.chars_ptr;
pragma Import (C, Get_String, "alGetString");
type Map_From_Distance_Model_t is array (Distance_Model_t) of Types.Enumeration_t;
Map_From_Distance_Model : constant Map_From_Distance_Model_t :=
(None => Thin.AL_NONE,
Inverse_Distance => Thin.AL_INVERSE_DISTANCE,
Inverse_Distance_Clamped => Thin.AL_INVERSE_DISTANCE_CLAMPED,
Linear_Distance => Thin.AL_LINEAR_DISTANCE,
Linear_Distance_Clamped => Thin.AL_LINEAR_DISTANCE_CLAMPED,
Exponent_Distance => Thin.AL_EXPONENT_DISTANCE,
Exponent_Distance_Clamped => Thin.AL_EXPONENT_DISTANCE_CLAMPED,
Unknown_Distance_Model => 0);
function Extensions return String is
begin
return C_Strings.Value (Get_String (Thin.AL_EXTENSIONS));
end Extensions;
--
-- Get_*
--
function Get_Distance_Model return Distance_Model_t is
Value : Types.Integer_t;
Return_Value : Distance_Model_t;
begin
Value := Thin.Get_Integer (Thin.AL_DISTANCE_MODEL);
case Value is
when Thin.AL_NONE => Return_Value := None;
when Thin.AL_INVERSE_DISTANCE => Return_Value := Inverse_Distance;
when Thin.AL_INVERSE_DISTANCE_CLAMPED => Return_Value := Inverse_Distance_Clamped;
when Thin.AL_LINEAR_DISTANCE => Return_Value := Linear_Distance;
when Thin.AL_LINEAR_DISTANCE_CLAMPED => Return_Value := Linear_Distance_Clamped;
when Thin.AL_EXPONENT_DISTANCE => Return_Value := Exponent_Distance;
when Thin.AL_EXPONENT_DISTANCE_CLAMPED => Return_Value := Exponent_Distance_Clamped;
when others => Return_Value := Unknown_Distance_Model;
end case;
return Return_Value;
end Get_Distance_Model;
function Get_Doppler_Factor return Types.Natural_Float_t is
begin
return Thin.Get_Float (Thin.AL_DOPPLER_FACTOR);
end Get_Doppler_Factor;
function Get_Speed_Of_Sound return Types.Positive_Float_t is
begin
return Thin.Get_Float (Thin.AL_SPEED_OF_SOUND);
end Get_Speed_Of_Sound;
--
-- Is_Extension_Present
--
function Is_Extension_Present (Name : in String) return Boolean is
C_Name : aliased C.char_array := C.To_C (Name);
begin
return Boolean (Thin.Is_Extension_Present (C_Name (C_Name'First)'Address));
end Is_Extension_Present;
function Renderer return String is
begin
return C_Strings.Value (Get_String (Thin.AL_RENDERER));
end Renderer;
--
-- Set_*
--
procedure Set_Distance_Model (Model : in Valid_Distance_Model_t) is
begin
Thin.Distance_Model (Map_From_Distance_Model (Model));
end Set_Distance_Model;
procedure Set_Doppler_Factor (Factor : in Types.Natural_Float_t) is
begin
Thin.Doppler_Factor (Factor);
end Set_Doppler_Factor;
procedure Set_Speed_Of_Sound (Factor : in Types.Positive_Float_t) is
begin
Thin.Speed_Of_Sound (Factor);
end Set_Speed_Of_Sound;
function Vendor return String is
begin
return C_Strings.Value (Get_String (Thin.AL_VENDOR));
end Vendor;
function Version return String is
begin
return C_Strings.Value (Get_String (Thin.AL_VERSION));
end Version;
end OpenAL.Global;
|
AdaCore/Ada_Drivers_Library | Ada | 4,656 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, 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. --
-- --
------------------------------------------------------------------------------
-- This program demonstrates reading the VBat (battery voltage) value from
-- an ADC unit, using interrupts.
-- Note that you will likely need to reset the board manually after loading.
with ADC_Interrupt_Handling;
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with STM32.Device; use STM32.Device;
with STM32.Board; use STM32.Board;
with HAL; use HAL;
with STM32.ADC; use STM32.ADC;
with STM32.GPIO; use STM32.GPIO;
with LCD_Std_Out;
procedure Demo_ADC_VBat_Interrupts is
All_Regular_Conversions : constant Regular_Channel_Conversions :=
(1 => (Channel => VBat.Channel, Sample_Time => Sample_15_Cycles));
Counts : UInt32;
Voltage : UInt32; -- in millivolts
procedure Print (X, Y : Natural; Value : UInt32; Suffix : String := "");
-----------
-- Print --
-----------
procedure Print (X, Y : Natural; Value : UInt32; Suffix : String := "") is
Value_Image : constant String := Value'Img;
begin
LCD_Std_Out.Put (X, Y, Value_Image (2 .. Value_Image'Last) & Suffix & " ");
end Print;
begin
Initialize_LEDs;
Enable_Clock (VBat.ADC.all);
Configure_Common_Properties
(Mode => Independent,
Prescalar => PCLK2_Div_2,
DMA_Mode => Disabled,
Sampling_Delay => Sampling_Delay_5_Cycles);
Configure_Unit
(VBat.ADC.all,
Resolution => ADC_Resolution_12_Bits,
Alignment => Right_Aligned);
Configure_Regular_Conversions
(VBat.ADC.all,
Continuous => False,
Trigger => Software_Triggered,
Enable_EOC => True,
Conversions => All_Regular_Conversions);
Enable_Interrupts (VBat.ADC.all, Regular_Channel_Conversion_Complete);
Enable (VBat.ADC.all);
loop
Start_Conversion (VBat.ADC.all);
Suspend_Until_True (ADC_Interrupt_Handling.Regular_Channel_EOC);
Counts := UInt32 (Conversion_Value (VBat.ADC.all));
Print (0, 0, Counts);
Voltage := ((Counts * VBat_Bridge_Divisor) * ADC_Supply_Voltage) / 16#FFF#;
-- 16#FFF# because we are using 12-bit conversion resolution
Print (0, 24, Voltage, "mv");
Green_LED.Toggle;
end loop;
end Demo_ADC_VBat_Interrupts;
|
reznikmm/matreshka | Ada | 3,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.Elements;
package ODF.DOM.Text_User_Defined_Elements is
pragma Preelaborate;
type ODF_Text_User_Defined is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_User_Defined_Access is
access all ODF_Text_User_Defined'Class
with Storage_Size => 0;
end ODF.DOM.Text_User_Defined_Elements;
|
PhiTheta/ADLAS_Ada_System | Ada | 3,089 | adb | ------------------------------------------------------------------------------------------------------------------------
--------------------------------------- File Details -------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
-- Project: Project_System
-- File name: <File_Name>
-- Description: This is the description of the test file
--
--
--
------------------------------------------------------------------------------------------------------------------------
--------------------------------------- Change History: ----------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
--
-- Version Date Author Description
-- ------- ---- ------ -----------
-- 1.0 22/08/17 S.Crowther Initial version
------------------------------------------------------------------------------------------------------------------------
--------------------------------------- Parameters: --------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
--
-- Name Direction Description
-- ---- --------- ----
-- Input_1 Input Template array
-- Output_1 Output Template array
--
------------------------------------------------------------------------------------------------------------------------
--------------------------------------- Function Details: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
--
-- Function name: <Function_Name>
-- Description:
--
--
-- Equation Logic: If x = 1 then
-- If template_variable = 1 then
-- Test_Failed
-- else
-- Test Passed
-- end if
-- Else
-- Test Passed
-- End if
--
-- Return:
-- Boolean Value
------------------------------------------------------------------------------------------------------------------------
--------------------------------------- Code: --------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
package body Cbit is
end Cbit;
|
reznikmm/matreshka | Ada | 4,232 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Application;
with League.Strings;
procedure Case_Conversion_Test is
use League.Strings;
-- This is a testcase for Final_Sigma context. \u03A3 translated to \u03C3
-- when there is no Final_Sigma context and to \u03C2 in Final_Sigma
-- context.
S1S : Universal_String
:= To_Universal_String
('A' & Wide_Wide_Character'Val (16#03A3#) & 'Z');
S1E : constant Wide_Wide_String
:= 'a' & Wide_Wide_Character'Val (16#03C3#) & 'z';
S2S : Universal_String
:= To_Universal_String
('A' & Wide_Wide_Character'Val (16#03A3#));
S2E : constant Wide_Wide_String
:= 'a' & Wide_Wide_Character'Val (16#03C2#);
begin
if S1S.To_Lowercase.To_Wide_Wide_String /= S1E then
raise Program_Error;
end if;
if S2S.To_Lowercase.To_Wide_Wide_String /= S2E then
raise Program_Error;
end if;
end Case_Conversion_Test;
|
reznikmm/matreshka | Ada | 3,669 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_C_Attributes is
pragma Preelaborate;
type ODF_Text_C_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_C_Attribute_Access is
access all ODF_Text_C_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_C_Attributes;
|
tum-ei-rcs/StratoX | Ada | 12,487 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.DCMI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------
-- CR_Register --
-----------------
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;
-----------------
-- SR_Register --
-----------------
-- 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;
------------------
-- RIS_Register --
------------------
-- 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;
------------------
-- IER_Register --
------------------
-- 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;
------------------
-- MIS_Register --
------------------
-- 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;
------------------
-- ICR_Register --
------------------
-- 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;
-------------------
-- ESCR_Register --
-------------------
subtype ESCR_FSC_Field is HAL.Byte;
subtype ESCR_LSC_Field is HAL.Byte;
subtype ESCR_LEC_Field is HAL.Byte;
subtype ESCR_FEC_Field is HAL.Byte;
-- 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;
-------------------
-- ESUR_Register --
-------------------
subtype ESUR_FSU_Field is HAL.Byte;
subtype ESUR_LSU_Field is HAL.Byte;
subtype ESUR_LEU_Field is HAL.Byte;
subtype ESUR_FEU_Field is HAL.Byte;
-- 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;
---------------------
-- CWSTRT_Register --
---------------------
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;
---------------------
-- CWSIZE_Register --
---------------------
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_Register --
-----------------
-- DR_Byte array element
subtype DR_Byte_Element is HAL.Byte;
-- 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.Word;
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 : CR_Register;
-- status register
SR : SR_Register;
-- raw interrupt status register
RIS : RIS_Register;
-- interrupt enable register
IER : IER_Register;
-- masked interrupt status register
MIS : MIS_Register;
-- interrupt clear register
ICR : ICR_Register;
-- embedded synchronization code register
ESCR : ESCR_Register;
-- embedded synchronization unmask register
ESUR : ESUR_Register;
-- crop window start
CWSTRT : CWSTRT_Register;
-- crop window size
CWSIZE : CWSIZE_Register;
-- data register
DR : DR_Register;
end record
with Volatile;
for DCMI_Peripheral use record
CR at 0 range 0 .. 31;
SR at 4 range 0 .. 31;
RIS at 8 range 0 .. 31;
IER at 12 range 0 .. 31;
MIS at 16 range 0 .. 31;
ICR at 20 range 0 .. 31;
ESCR at 24 range 0 .. 31;
ESUR at 28 range 0 .. 31;
CWSTRT at 32 range 0 .. 31;
CWSIZE at 36 range 0 .. 31;
DR at 40 range 0 .. 31;
end record;
-- Digital camera interface
DCMI_Periph : aliased DCMI_Peripheral
with Import, Address => DCMI_Base;
end STM32_SVD.DCMI;
|
zhangkaizhao/completely-unscientific-benchmarks | Ada | 2,495 | adb | with Ada.Unchecked_Deallocation;
package body Tree_Naive_Pointers is
procedure initialize is
begin
Reset(g);
end;
procedure make_node(n: out NodePtr; x: Integer) is
begin
n := new Node;
n.x := x;
n.y := Random(g);
end make_node;
procedure delete_node(n: in out NodePtr) is
procedure free is new Ada.Unchecked_Deallocation(Object => Node, Name => NodePtr);
begin
if n /= null then
if n.left /= null then delete_node(n.left); end if;
if n.right /= null then delete_node(n.right); end if;
free(n);
end if;
end delete_node;
function merge(lower, greater: NodePtr) return NodePtr is
begin
if lower = null then return greater; end if;
if greater = null then return lower; end if;
if lower.y < greater.y then
lower.right := merge(lower.right, greater);
return lower;
else
greater.left := merge(lower, greater.left);
return greater;
end if;
end merge;
function merge(lower, equal, greater: NodePtr) return NodePtr is
begin
return merge(merge(lower, equal), greater);
end merge;
procedure split(orig: NodePtr; lower, greaterOrEqual: in out NodePtr; val: Integer) is
begin
if orig = null then
lower := null;
greaterOrEqual := null;
return;
end if;
if orig.x < val then
lower := orig;
split(lower.right, lower.right, greaterOrEqual, val);
else
greaterOrEqual := orig;
split(greaterOrEqual.left, lower, greaterOrEqual.left, val);
end if;
end split;
procedure split(orig: NodePtr; lower, equal, greater: in out NodePtr; val: Integer) is
equalOrGreater: NodePtr;
begin
split(orig, lower, equalOrGreater, val);
split(equalOrGreater, equal, greater, val + 1);
end split;
function hasValue(t: in out Tree; x: Integer) return Boolean is
lower, equal, greater: NodePtr;
result: Boolean;
begin
split(t.root, lower, equal, greater, x);
result := equal /= null;
t.root := merge(lower, equal, greater);
return result;
end hasValue;
procedure insert(t: in out Tree; x: Integer) is
lower, equal, greater: NodePtr;
begin
split(t.root, lower, equal, greater, x);
if equal = null then make_node(equal, x); end if;
t.root := merge(lower, equal, greater);
end insert;
procedure erase(t: in out Tree; x: Integer) is
lower, equal, greater: NodePtr;
begin
split(t.root, lower, equal, greater, x);
t.root := merge(lower, greater);
-- commenting out the following line
-- doesn't seem to affect running time by much, if at all
delete_node(equal);
end erase;
end Tree_Naive_Pointers;
|
reznikmm/matreshka | Ada | 3,724 | 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.Form_Apply_Filter_Attributes is
pragma Preelaborate;
type ODF_Form_Apply_Filter_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Apply_Filter_Attribute_Access is
access all ODF_Form_Apply_Filter_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Apply_Filter_Attributes;
|
reznikmm/matreshka | Ada | 4,803 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A class that defines the core logic or control flow for one or more
-- auxiliary classes that support it. Support classes may be defined
-- explicitly using Auxiliary classes or implicitly as clients of dependency
-- relationships whose supplier is a focus class. Focus classes are typically
-- used together with one or more Auxiliary classes, and are particularly
-- useful for specifying the core business logic or control flow of
-- components during design. See also: «Auxiliary».
------------------------------------------------------------------------------
limited with AMF.UML.Classes;
package AMF.Standard_Profile_L2.Focuses is
pragma Preelaborate;
type Standard_Profile_L2_Focus is limited interface;
type Standard_Profile_L2_Focus_Access is
access all Standard_Profile_L2_Focus'Class;
for Standard_Profile_L2_Focus_Access'Storage_Size use 0;
not overriding function Get_Base_Class
(Self : not null access constant Standard_Profile_L2_Focus)
return AMF.UML.Classes.UML_Class_Access is abstract;
-- Getter of Focus::base_Class.
--
not overriding procedure Set_Base_Class
(Self : not null access Standard_Profile_L2_Focus;
To : AMF.UML.Classes.UML_Class_Access) is abstract;
-- Setter of Focus::base_Class.
--
end AMF.Standard_Profile_L2.Focuses;
|
OneWingedShark/Risi | Ada | 1,627 | ads | With
Risi_Script.Types.Internals;
Private With
Risi_Script.Types.Implementation;
Private Package Risi_Script.Types.Implementation.Creators is
Package Internal renames Risi_Script.Types.Internals;
Function Create ( Item : Internal.Integer_Type ) return Representation;
-- Function Create ( Item : Internal.Array_Type ) return Representation;
-- Function Create ( Item : Internal.Hash_Type ) return Representation;
-- Function Create ( Item : Internal.String_Type ) return Representation;
Function Create ( Item : Internal.Real_Type ) return Representation;
Function Create ( Item : Internal.Pointer_Type ) return Representation;
-- Function Create ( Item : Internal.Reference_Type) return Representation;
Function Create ( Item : Internal.Fixed_Type ) return Representation;
Function Create ( Item : Internal.Boolean_Type ) return Representation;
Function Create ( Item : Internal.Func_Type ) return Representation;
Private
Function Create ( Item : Internal.Integer_Type ) return Representation
renames Internal_Create;
Function Create ( Item : Internal.Real_Type ) return Representation
renames Internal_Create;
Function Create ( Item : Internal.Pointer_Type ) return Representation
renames Internal_Create;
Function Create ( Item : Internal.Fixed_Type ) return Representation
renames Internal_Create;
Function Create ( Item : Internal.Boolean_Type ) return Representation
renames Internal_Create;
Function Create ( Item : Internal.Func_Type ) return Representation
renames Internal_Create;
End Risi_Script.Types.Implementation.Creators;
|
wookey-project/ewok-legacy | Ada | 1,018 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.tasks_shared;
package ewok.syscalls.reset
with spark_mode => off
is
procedure sys_reset
(caller_id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode);
end ewok.syscalls.reset;
|
reznikmm/matreshka | Ada | 3,699 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Svg_Font_Face_Format_Elements is
pragma Preelaborate;
type ODF_Svg_Font_Face_Format is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Svg_Font_Face_Format_Access is
access all ODF_Svg_Font_Face_Format'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Font_Face_Format_Elements;
|
AdaCore/training_material | Ada | 1,931 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package bmiintrin_h is
-- Copyright (C) 2010-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3, or (at your option)
-- any later version.
-- GCC is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- Under Section 7 of GPL version 3, you are granted additional
-- permissions described in the GCC Runtime Library Exception, version
-- 3.1, as published by the Free Software Foundation.
-- You should have received a copy of the GNU General Public License and
-- a copy of the GCC Runtime Library Exception along with this program;
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-- <http://www.gnu.org/licenses/>.
-- skipped func __tzcnt_u16
-- skipped func __andn_u32
-- skipped func __bextr_u32
-- skipped func _bextr_u32
-- skipped func __blsi_u32
-- skipped func _blsi_u32
-- skipped func __blsmsk_u32
-- skipped func _blsmsk_u32
-- skipped func __blsr_u32
-- skipped func _blsr_u32
-- skipped func __tzcnt_u32
-- skipped func _tzcnt_u32
-- skipped func __andn_u64
-- skipped func __bextr_u64
-- skipped func _bextr_u64
-- skipped func __blsi_u64
-- skipped func _blsi_u64
-- skipped func __blsmsk_u64
-- skipped func _blsmsk_u64
-- skipped func __blsr_u64
-- skipped func _blsr_u64
-- skipped func __tzcnt_u64
-- skipped func _tzcnt_u64
end bmiintrin_h;
|
zhmu/ananas | Ada | 3,895 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 7 4 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 74
package System.Pack_74 is
pragma Preelaborate;
Bits : constant := 74;
type Bits_74 is mod 2 ** Bits;
for Bits_74'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_74
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_74 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_74
(Arr : System.Address;
N : Natural;
E : Bits_74;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
function GetU_74
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_74 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned. This version
-- is used when Arr may represent an unaligned address.
procedure SetU_74
(Arr : System.Address;
N : Natural;
E : Bits_74;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value. This version
-- is used when Arr may represent an unaligned address
end System.Pack_74;
|
reznikmm/matreshka | Ada | 6,998 | 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.File_Based_Database_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_File_Based_Database_Element_Node is
begin
return Self : Db_File_Based_Database_Element_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Db_File_Based_Database_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Db_File_Based_Database
(ODF.DOM.Db_File_Based_Database_Elements.ODF_Db_File_Based_Database_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_File_Based_Database_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.File_Based_Database_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_File_Based_Database_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Db_File_Based_Database
(ODF.DOM.Db_File_Based_Database_Elements.ODF_Db_File_Based_Database_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Db_File_Based_Database_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Db_File_Based_Database
(Visitor,
ODF.DOM.Db_File_Based_Database_Elements.ODF_Db_File_Based_Database_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.File_Based_Database_Element,
Db_File_Based_Database_Element_Node'Tag);
end Matreshka.ODF_Db.File_Based_Database_Elements;
|
AdaCore/training_material | Ada | 1,412 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
with System;
package SDL_SDL_version_h is
SDL_MAJOR_VERSION : constant := 1; -- ../include/SDL/SDL_version.h:42
SDL_MINOR_VERSION : constant := 2; -- ../include/SDL/SDL_version.h:43
SDL_PATCHLEVEL : constant := 15; -- ../include/SDL/SDL_version.h:44
-- arg-macro: procedure SDL_VERSION (X)
-- { (X).major := SDL_MAJOR_VERSION; (X).minor := SDL_MINOR_VERSION; (X).patch := SDL_PATCHLEVEL; }
-- arg-macro: function SDL_VERSIONNUM (X, Y, Z)
-- return (X)*1000 + (Y)*100 + (Z);
-- unsupported macro: SDL_COMPILEDVERSION SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
-- arg-macro: function SDL_VERSION_ATLEAST (X, Y, Z)
-- return SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z);
type SDL_version is record
major : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:48
minor : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:49
patch : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_version.h:50
end record;
pragma Convention (C_Pass_By_Copy, SDL_version); -- ../include/SDL/SDL_version.h:47
function SDL_Linked_Version return System.Address; -- ../include/SDL/SDL_version.h:83
pragma Import (C, SDL_Linked_Version, "SDL_Linked_Version");
end SDL_SDL_version_h;
|
reznikmm/matreshka | Ada | 3,763 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body FastCGI.Replies.Internals is
------------
-- Create --
------------
function Create
(Descriptor : Matreshka.FastCGI.Descriptor_Access)
return Reply is
begin
return
(Descriptor => Descriptor,
Out_Stream =>
new Output_Stream'
(Ada.Streams.Root_Stream_Type with Descriptor => Descriptor));
end Create;
end FastCGI.Replies.Internals;
|
reznikmm/matreshka | Ada | 4,767 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Nodes.Collections is
pragma Preelaborate;
package UML_Node_Collections is
new AMF.Generic_Collections
(UML_Node,
UML_Node_Access);
type Set_Of_UML_Node is
new UML_Node_Collections.Set with null record;
Empty_Set_Of_UML_Node : constant Set_Of_UML_Node;
type Ordered_Set_Of_UML_Node is
new UML_Node_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Node : constant Ordered_Set_Of_UML_Node;
type Bag_Of_UML_Node is
new UML_Node_Collections.Bag with null record;
Empty_Bag_Of_UML_Node : constant Bag_Of_UML_Node;
type Sequence_Of_UML_Node is
new UML_Node_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Node : constant Sequence_Of_UML_Node;
private
Empty_Set_Of_UML_Node : constant Set_Of_UML_Node
:= (UML_Node_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Node : constant Ordered_Set_Of_UML_Node
:= (UML_Node_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Node : constant Bag_Of_UML_Node
:= (UML_Node_Collections.Bag with null record);
Empty_Sequence_Of_UML_Node : constant Sequence_Of_UML_Node
:= (UML_Node_Collections.Sequence with null record);
end AMF.UML.Nodes.Collections;
|
AdaCore/training_material | Ada | 1,173 | adb | with Ada.Calendar; use Ada.Calendar;
with Base_Types;
with Odometer;
with Sender;
package body Odometer_Task is
use type Base_Types.Meters_T;
Last_Reading : Base_Types.Meters_T;
Last_Clock : Ada.Calendar.Time;
task body Monitor is
begin
accept Initialize do
Last_Reading := Odometer.Read;
Last_Clock := Ada.Calendar.Clock;
end Initialize;
loop
select
accept Finalize;
exit;
else
delay 0.5;
declare
Reading : Base_Types.Meters_T := Odometer.Read;
Clock : Ada.Calendar.Time := Ada.Calendar.Clock;
Speed : Base_Types.Meters_Per_Second_T :=
Base_Types.Speed
(Reading - Last_Reading,
Base_Types.Time_T (Clock - Last_Clock));
begin
Sender.Send
(Message =>
(Clock,
Speed));
Last_Reading := Reading;
Last_Clock := Clock;
end;
end select;
end loop;
end Monitor;
end Odometer_Task;
|
RREE/ada-util | Ada | 4,984 | ads | -----------------------------------------------------------------------
-- util-streams -- Stream utilities
-- Copyright (C) 2010, 2016, 2018, 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
-- = Streams =
-- The `Util.Streams` package provides several types and operations to allow the
-- composition of input and output streams. Input streams can be chained together so that
-- they traverse the different stream objects when the data is read from them. Similarly,
-- output streams can be chained and the data that is written will traverse the different
-- streams from the first one up to the last one in the chain. During such traversal, the
-- stream object is able to bufferize the data or make transformations on the data.
--
-- The `Input_Stream` interface represents the stream to read data. It only provides a
-- `Read` procedure. The `Output_Stream` interface represents the stream to write data.
-- It provides a `Write`, `Flush` and `Close` operation.
--
-- To use the packages described here, use the following GNAT project:
--
-- with "utilada_sys";
--
-- @include util-streams-buffered.ads
-- @include util-streams-texts.ads
-- @include util-streams-files.ads
-- @include util-streams-pipes.ads
-- @include util-streams-sockets.ads
-- @include util-streams-raw.ads
-- @include util-streams-base16.ads
-- @include util-streams-base64.ads
-- @include util-streams-aes.ads
package Util.Streams is
pragma Preelaborate;
-- -----------------------
-- Output stream
-- -----------------------
-- The <b>Output_Stream</b> is an interface that accepts output bytes
-- and sends them to a sink.
type Output_Stream is limited interface;
type Output_Stream_Access is access all Output_Stream'Class;
-- Write the buffer array to the output stream.
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is abstract;
-- Flush the buffer (if any) to the sink.
procedure Flush (Stream : in out Output_Stream) is null;
-- Close the sink.
procedure Close (Stream : in out Output_Stream) is null;
-- -----------------------
-- Input stream
-- -----------------------
-- The <b>Input_Stream</b> is the interface that reads input bytes
-- from a source and returns them.
type Input_Stream is limited interface;
type Input_Stream_Access is access all Input_Stream'Class;
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
procedure Read (Stream : in out Input_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is abstract;
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class);
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String);
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array);
-- Write a raw string on the stream.
procedure Write (Stream : in out Output_Stream'Class;
Item : in Character);
procedure Write (Stream : in out Output_Stream'Class;
Item : in String);
-- Write a wide character on the stream using a UTF-8 sequence.
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_Character);
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_String);
-- Notes:
-- ------
-- The <b>Ada.Streams.Root_Stream_Type</b> implements the <b>Output_Stream</b>
-- and <b>Input_Stream</b>. It is however not easy to use for composing various
-- stream behaviors.
end Util.Streams;
|
stcarrez/ada-ado | Ada | 2,040 | adb | -----------------------------------------------------------------------
-- ADO Dialects -- Driver support for basic SQL Generation
-- Copyright (C) 2010, 2011, 2012, 2015, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ADO.Dialects is
-- ------------------------------
-- Append the item in the buffer escaping some characters if necessary.
-- The default implementation only escapes the single quote ' by doubling them.
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in String) is
pragma Unreferenced (D);
C : Character;
begin
Append (Buffer, ''');
for I in Item'Range loop
C := Item (I);
if C = ''' then
Append (Buffer, ''');
end if;
Append (Buffer, C);
end loop;
Append (Buffer, ''');
end Escape_Sql;
-- ------------------------------
-- Append the boolean item in the buffer.
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in Boolean) is
pragma Unreferenced (D);
begin
Append (Buffer, (if Item then '1' else '0'));
end Escape_Sql;
end ADO.Dialects;
|
sungyeon/drake | Ada | 308 | ads | pragma License (Unrestricted);
with Ada.Strings.Generic_Unbounded.Generic_Hash;
with Ada.Strings.Wide_Wide_Hash;
function Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash is
new Unbounded_Wide_Wide_Strings.Generic_Hash (Wide_Wide_Hash);
pragma Preelaborate (Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash);
|
zhmu/ananas | Ada | 7,741 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
generic
type Real is digits <>;
package Ada.Numerics.Generic_Complex_Types is
pragma Pure;
type Complex is record
Re, Im : Real'Base;
end record;
pragma Complex_Representation (Complex);
type Imaginary is private;
pragma Preelaborable_Initialization (Imaginary);
i : constant Imaginary;
j : constant Imaginary;
function Re (X : Complex) return Real'Base;
function Im (X : Complex) return Real'Base;
function Im (X : Imaginary) return Real'Base;
procedure Set_Re (X : in out Complex; Re : Real'Base);
procedure Set_Im (X : in out Complex; Im : Real'Base);
procedure Set_Im (X : out Imaginary; Im : Real'Base);
function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
function Compose_From_Cartesian (Re : Real'Base) return Complex;
function Compose_From_Cartesian (Im : Imaginary) return Complex;
function Modulus (X : Complex) return Real'Base;
function "abs" (Right : Complex) return Real'Base renames Modulus;
function Argument (X : Complex) return Real'Base;
function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
function Compose_From_Polar (
Modulus, Argument : Real'Base)
return Complex;
function Compose_From_Polar (
Modulus, Argument, Cycle : Real'Base)
return Complex;
function "+" (Right : Complex) return Complex;
function "-" (Right : Complex) return Complex;
function Conjugate (X : Complex) return Complex;
function "+" (Left, Right : Complex) return Complex;
function "-" (Left, Right : Complex) return Complex;
function "*" (Left, Right : Complex) return Complex;
function "/" (Left, Right : Complex) return Complex;
function "**" (Left : Complex; Right : Integer) return Complex;
function "+" (Right : Imaginary) return Imaginary;
function "-" (Right : Imaginary) return Imaginary;
function Conjugate (X : Imaginary) return Imaginary renames "-";
function "abs" (Right : Imaginary) return Real'Base;
function "+" (Left, Right : Imaginary) return Imaginary;
function "-" (Left, Right : Imaginary) return Imaginary;
function "*" (Left, Right : Imaginary) return Real'Base;
function "/" (Left, Right : Imaginary) return Real'Base;
function "**" (Left : Imaginary; Right : Integer) return Complex;
function "<" (Left, Right : Imaginary) return Boolean;
function "<=" (Left, Right : Imaginary) return Boolean;
function ">" (Left, Right : Imaginary) return Boolean;
function ">=" (Left, Right : Imaginary) return Boolean;
function "+" (Left : Complex; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Real'Base) return Complex;
function "*" (Left : Real'Base; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Real'Base) return Complex;
function "/" (Left : Real'Base; Right : Complex) return Complex;
function "+" (Left : Complex; Right : Imaginary) return Complex;
function "+" (Left : Imaginary; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Imaginary) return Complex;
function "/" (Left : Imaginary; Right : Complex) return Complex;
function "+" (Left : Imaginary; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "*" (Left : Real'Base; Right : Imaginary) return Imaginary;
function "/" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "/" (Left : Real'Base; Right : Imaginary) return Imaginary;
private
type Imaginary is new Real'Base;
i : constant Imaginary := 1.0;
j : constant Imaginary := 1.0;
pragma Inline ("+");
pragma Inline ("-");
pragma Inline ("*");
pragma Inline ("<");
pragma Inline ("<=");
pragma Inline (">");
pragma Inline (">=");
pragma Inline ("abs");
pragma Inline (Compose_From_Cartesian);
pragma Inline (Conjugate);
pragma Inline (Im);
pragma Inline (Re);
pragma Inline (Set_Im);
pragma Inline (Set_Re);
end Ada.Numerics.Generic_Complex_Types;
|
zhmu/ananas | Ada | 3,237 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 0 3 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 103
package System.Pack_103 is
pragma Preelaborate;
Bits : constant := 103;
type Bits_103 is mod 2 ** Bits;
for Bits_103'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_103
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_103 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_103
(Arr : System.Address;
N : Natural;
E : Bits_103;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_103;
|
zhmu/ananas | Ada | 8,399 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- F N A M E --
-- --
-- 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body Fname is
function Has_Internal_Extension (Fname : String) return Boolean;
pragma Inline (Has_Internal_Extension);
-- True if the extension is appropriate for an internal/predefined unit.
-- That means ".ads" or ".adb" for source files, and ".ali" for ALI files.
function Has_Prefix (X, Prefix : String) return Boolean;
pragma Inline (Has_Prefix);
-- True if Prefix is at the beginning of X. For example,
-- Has_Prefix ("a-filename.ads", Prefix => "a-") is True.
----------------------------
-- Has_Internal_Extension --
----------------------------
function Has_Internal_Extension (Fname : String) return Boolean is
begin
if Fname'Length >= 4 then
declare
S : String renames Fname (Fname'Last - 3 .. Fname'Last);
begin
return S = ".ads" or else S = ".adb" or else S = ".ali";
end;
end if;
return False;
end Has_Internal_Extension;
----------------
-- Has_Prefix --
----------------
function Has_Prefix (X, Prefix : String) return Boolean is
begin
if X'Length >= Prefix'Length then
declare
S : String renames X (X'First .. X'First + Prefix'Length - 1);
begin
return S = Prefix;
end;
end if;
return False;
end Has_Prefix;
-----------------------
-- Is_GNAT_File_Name --
-----------------------
function Is_GNAT_File_Name (Fname : String) return Boolean is
begin
-- Check for internal extensions before checking prefixes, so we don't
-- think (e.g.) "gnat.adc" is internal.
if not Has_Internal_Extension (Fname) then
return False;
end if;
-- Definitely internal if prefix is g-
if Has_Prefix (Fname, "g-") then
return True;
end if;
-- See the note in Is_Predefined_File_Name for the rationale
return Fname'Length = 8 and then Has_Prefix (Fname, "gnat");
end Is_GNAT_File_Name;
function Is_GNAT_File_Name (Fname : File_Name_Type) return Boolean is
Result : constant Boolean :=
Is_GNAT_File_Name (Get_Name_String (Fname));
begin
return Result;
end Is_GNAT_File_Name;
---------------------------
-- Is_Internal_File_Name --
---------------------------
function Is_Internal_File_Name
(Fname : String;
Renamings_Included : Boolean := True) return Boolean
is
begin
if Is_Predefined_File_Name (Fname, Renamings_Included) then
return True;
end if;
return Is_GNAT_File_Name (Fname);
end Is_Internal_File_Name;
function Is_Internal_File_Name
(Fname : File_Name_Type;
Renamings_Included : Boolean := True) return Boolean
is
Result : constant Boolean :=
Is_Internal_File_Name
(Get_Name_String (Fname), Renamings_Included);
begin
return Result;
end Is_Internal_File_Name;
-----------------------------
-- Is_Predefined_File_Name --
-----------------------------
function Is_Predefined_File_Name
(Fname : String;
Renamings_Included : Boolean := True) return Boolean
is
begin
-- Definitely false if longer than 12 characters (8.3), except for the
-- Interfaces packages and also the implementation units of the 128-bit
-- types under System.
if Fname'Length > 12
and then Fname (Fname'First .. Fname'First + 1) /= "i-"
and then Fname (Fname'First .. Fname'First + 1) /= "s-"
then
return False;
end if;
if not Has_Internal_Extension (Fname) then
return False;
end if;
-- Definitely predefined if prefix is a- i- or s-
if Fname'Length >= 2 then
declare
S : String renames Fname (Fname'First .. Fname'First + 1);
begin
if S = "a-" or else S = "i-" or else S = "s-" then
return True;
end if;
end;
end if;
-- We include the "." in the prefixes below, so we don't match (e.g.)
-- adamant.ads. So the first line matches "ada.ads", "ada.adb", and
-- "ada.ali". But that's not necessary if they have 8 characters.
if Has_Prefix (Fname, "ada.") -- Ada
or else Has_Prefix (Fname, "interfac") -- Interfaces
or else Has_Prefix (Fname, "system.a") -- System
then
return True;
end if;
-- If instructed and the name has 8+ characters, check for renamings
if Renamings_Included
and then Is_Predefined_Renaming_File_Name (Fname)
then
return True;
end if;
return False;
end Is_Predefined_File_Name;
function Is_Predefined_File_Name
(Fname : File_Name_Type;
Renamings_Included : Boolean := True) return Boolean
is
Result : constant Boolean :=
Is_Predefined_File_Name
(Get_Name_String (Fname), Renamings_Included);
begin
return Result;
end Is_Predefined_File_Name;
--------------------------------------
-- Is_Predefined_Renaming_File_Name --
--------------------------------------
function Is_Predefined_Renaming_File_Name
(Fname : String) return Boolean
is
subtype Str8 is String (1 .. 8);
Renaming_Names : constant array (1 .. 8) of Str8 :=
("calendar", -- Calendar
"machcode", -- Machine_Code
"unchconv", -- Unchecked_Conversion
"unchdeal", -- Unchecked_Deallocation
"directio", -- Direct_IO
"ioexcept", -- IO_Exceptions
"sequenio", -- Sequential_IO
"text_io."); -- Text_IO
begin
-- Definitely false if longer than 12 characters (8.3)
if Fname'Length in 8 .. 12 then
declare
S : String renames Fname (Fname'First .. Fname'First + 7);
begin
for J in Renaming_Names'Range loop
if S = Renaming_Names (J) then
return True;
end if;
end loop;
end;
end if;
return False;
end Is_Predefined_Renaming_File_Name;
function Is_Predefined_Renaming_File_Name
(Fname : File_Name_Type) return Boolean is
Result : constant Boolean :=
Is_Predefined_Renaming_File_Name (Get_Name_String (Fname));
begin
return Result;
end Is_Predefined_Renaming_File_Name;
end Fname;
|
AdaCore/training_material | Ada | 587 | ads | package Employee_Data is
type Employee_T is limited private;
type Hourly_Rate_T is new Integer; -- better implementation
type Id_T is new Integer; -- better implementation
function Create
(Name : Name_T;
Rate : Hourly_Rate_T)
return Employee_T;
function Id
(Employee : Employee_T)
return Id_T;
function Name
(Employee : Employee_T)
return Name_T;
function Rate
(Employee : Employee_T)
return Hourly_Rate_T;
private
-- finish implementation
type Employee_T is limited null record;
end Employee_Data;
|
AdaCore/libadalang | Ada | 297 | adb | procedure Test is
function Foo (X : Integer) return Integer is
pragma Pre (X > 0);
pragma Precondition (X < 10);
pragma Post (Foo'Result > 0);
pragma Postcondition (Foo'Result < X);
begin
return X - 1;
end Foo;
pragma Test_Block;
begin
null;
end Test;
|
reznikmm/matreshka | Ada | 26,638 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Action_Input_Pins is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Action_Input_Pin
(AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Action_Input_Pin
(AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Action_Input_Pin_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.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Action_Input_Pin
(Visitor,
AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access (Self),
Control);
end if;
end Visit_Element;
---------------------
-- Get_From_Action --
---------------------
overriding function Get_From_Action
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Actions.UML_Action_Access is
begin
return
AMF.UML.Actions.UML_Action_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_From_Action
(Self.Element)));
end Get_From_Action;
---------------------
-- Set_From_Action --
---------------------
overriding procedure Set_From_Action
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Actions.UML_Action_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_From_Action
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_From_Action;
--------------------
-- Get_Is_Control --
--------------------
overriding function Get_Is_Control
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Control
(Self.Element);
end Get_Is_Control;
--------------------
-- Set_Is_Control --
--------------------
overriding procedure Set_Is_Control
(Self : not null access UML_Action_Input_Pin_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Control
(Self.Element, To);
end Set_Is_Control;
------------------
-- Get_In_State --
------------------
overriding function Get_In_State
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.States.Collections.Set_Of_UML_State is
begin
return
AMF.UML.States.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_State
(Self.Element)));
end Get_In_State;
-------------------------
-- Get_Is_Control_Type --
-------------------------
overriding function Get_Is_Control_Type
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Control_Type
(Self.Element);
end Get_Is_Control_Type;
-------------------------
-- Set_Is_Control_Type --
-------------------------
overriding procedure Set_Is_Control_Type
(Self : not null access UML_Action_Input_Pin_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Control_Type
(Self.Element, To);
end Set_Is_Control_Type;
------------------
-- Get_Ordering --
------------------
overriding function Get_Ordering
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.UML_Object_Node_Ordering_Kind is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Ordering
(Self.Element);
end Get_Ordering;
------------------
-- Set_Ordering --
------------------
overriding procedure Set_Ordering
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.UML_Object_Node_Ordering_Kind) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Ordering
(Self.Element, To);
end Set_Ordering;
-------------------
-- Get_Selection --
-------------------
overriding function Get_Selection
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access is
begin
return
AMF.UML.Behaviors.UML_Behavior_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Selection
(Self.Element)));
end Get_Selection;
-------------------
-- Set_Selection --
-------------------
overriding procedure Set_Selection
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Selection
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Selection;
---------------------
-- Get_Upper_Bound --
---------------------
overriding function Get_Upper_Bound
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
begin
return
AMF.UML.Value_Specifications.UML_Value_Specification_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Upper_Bound
(Self.Element)));
end Get_Upper_Bound;
---------------------
-- Set_Upper_Bound --
---------------------
overriding procedure Set_Upper_Bound
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Upper_Bound
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Upper_Bound;
------------------
-- Get_Activity --
------------------
overriding function Get_Activity
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activities.UML_Activity_Access is
begin
return
AMF.UML.Activities.UML_Activity_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity
(Self.Element)));
end Get_Activity;
------------------
-- Set_Activity --
------------------
overriding procedure Set_Activity
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Activities.UML_Activity_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Activity;
------------------
-- Get_In_Group --
------------------
overriding function Get_In_Group
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is
begin
return
AMF.UML.Activity_Groups.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group
(Self.Element)));
end Get_In_Group;
---------------------------------
-- Get_In_Interruptible_Region --
---------------------------------
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is
begin
return
AMF.UML.Interruptible_Activity_Regions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region
(Self.Element)));
end Get_In_Interruptible_Region;
----------------------
-- Get_In_Partition --
----------------------
overriding function Get_In_Partition
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is
begin
return
AMF.UML.Activity_Partitions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition
(Self.Element)));
end Get_In_Partition;
----------------------------
-- Get_In_Structured_Node --
----------------------------
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
begin
return
AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node
(Self.Element)));
end Get_In_Structured_Node;
----------------------------
-- Set_In_Structured_Node --
----------------------------
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_In_Structured_Node;
------------------
-- Get_Incoming --
------------------
overriding function Get_Incoming
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming
(Self.Element)));
end Get_Incoming;
------------------
-- Get_Outgoing --
------------------
overriding function Get_Outgoing
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing
(Self.Element)));
end Get_Outgoing;
------------------------
-- Get_Redefined_Node --
------------------------
overriding function Get_Redefined_Node
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is
begin
return
AMF.UML.Activity_Nodes.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node
(Self.Element)));
end Get_Redefined_Node;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access UML_Action_Input_Pin_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Action_Input_Pin_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Action_Input_Pin_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Action_Input_Pin_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Namespace";
return Namespace (Self);
end Namespace;
---------------------
-- Compatible_With --
---------------------
overriding function Compatible_With
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Compatible_With";
return Compatible_With (Self, Other);
end Compatible_With;
--------------------------
-- Includes_Cardinality --
--------------------------
overriding function Includes_Cardinality
(Self : not null access constant UML_Action_Input_Pin_Proxy;
C : Integer)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Includes_Cardinality unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Includes_Cardinality";
return Includes_Cardinality (Self, C);
end Includes_Cardinality;
---------------------------
-- Includes_Multiplicity --
---------------------------
overriding function Includes_Multiplicity
(Self : not null access constant UML_Action_Input_Pin_Proxy;
M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Includes_Multiplicity unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Includes_Multiplicity";
return Includes_Multiplicity (Self, M);
end Includes_Multiplicity;
---------
-- Iss --
---------
overriding function Iss
(Self : not null access constant UML_Action_Input_Pin_Proxy;
Lowerbound : Integer;
Upperbound : Integer)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Iss unimplemented");
raise Program_Error with "Unimplemented procedure UML_Action_Input_Pin_Proxy.Iss";
return Iss (Self, Lowerbound, Upperbound);
end Iss;
end AMF.Internals.UML_Action_Input_Pins;
|
Gabriel-Degret/adalib | Ada | 724 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
generic
type Source (<>) is limited private;
type Target (<>) is limited private;
function Ada.Unchecked_Conversion (S : Source) return Target;
pragma Convention (Intrinsic, Ada.Unchecked_Conversion);
pragma Pure (Ada.Unchecked_Conversion);
|
peterfrankjohnson/compiler | Ada | 144 | adb | --
-- A simple Hello World test program
--
with Ada.Text_IO; use Ada.Text_IO;
procedure helloworld is
begin
Put_Line ("Hello World!");
end; |
godunko/cga | Ada | 995 | ads | --
-- Copyright (C) 2023, Vadim Godunko <[email protected]>
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Vector in 2D space.
with CGK.Primitives.Points_2D;
private with CGK.Primitives.XYs;
with CGK.Reals;
package CGK.Primitives.Vectors_2D is
pragma Pure;
type Vector_2D is private;
function Create_Vector_2D
(X : CGK.Reals.Real; Y : CGK.Reals.Real) return Vector_2D;
function Create_Vector_2D
(Point_1 : CGK.Primitives.Points_2D.Point_2D;
Point_2 : CGK.Primitives.Points_2D.Point_2D) return Vector_2D;
-- Creates a vector from two points.
function X (Self : Vector_2D) return CGK.Reals.Real with Inline;
-- Returns X coordinate.
function Y (Self : Vector_2D) return CGK.Reals.Real with Inline;
-- Returns Y coordinate.
function "-" (Self : Vector_2D) return Vector_2D with Inline;
private
type Vector_2D is record
Coordinates : CGK.Primitives.XYs.XY;
end record;
end CGK.Primitives.Vectors_2D;
|
emilybache/GildedRose-Refactoring-Kata | Ada | 1,857 | adb | with Ada.Text_IO;
use Ada.Text_IO;
with Items;
use Items;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Gilded_Rose;
use Gilded_Rose;
procedure Program is
Things : Item_Vecs.Vector;
begin
Things.Append(New_Item =>
(Name => To_Unbounded_String("+5 Dexterity Vest"),
Sell_In => 10,
Quality => 20));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Aged Brie"),
Sell_In => 2,
Quality => 0));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Elixir of the Mongoose"),
Sell_In => 5,
Quality => 7));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"),
Sell_In => 0,
Quality => 80));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"),
Sell_In => -1,
Quality => 80));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"),
Sell_In => 15,
Quality => 20));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"),
Sell_In => 10,
Quality => 49));
Things.Append(New_Item =>
(Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"),
Sell_In => 5,
Quality => 49));
-- this conjured item does not work properly yet
Things.Append(New_Item =>
(Name => To_Unbounded_String("Conjured Mana Cake"),
Sell_In => 3,
Quality => 6));
declare
App : Gilded_Rose.Gilded_Rose := (Items => Things);
begin
Put_Line("OMGHAI!");
for I in 0 .. 30 loop
Put_Line("-------- day" & Integer'Image(I) & " --------");
Put_Line("name, sellIn, quality");
for Each of App.Items loop
Put_Line(To_String(Each));
end loop;
Put_Line("");
Update_Quality(App);
end loop;
end;
end;
|
stcarrez/dynamo | Ada | 28,116 | adb | -----------------------------------------------------------------------
-- gen-model-packages -- Packages holding model, query representation
-- Copyright (C) 2009 - 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings;
with Ada.Strings.Maps;
with Gen.Utils;
with Gen.Model.Enums;
with Gen.Model.Stypes;
with Gen.Model.Tables;
with Gen.Model.Queries;
with Gen.Model.Beans;
with Gen.Model.Operations;
with Util.Strings;
with Util.Strings.Transforms;
with Util.Log.Loggers;
package body Gen.Model.Packages is
use Ada.Strings.Unbounded;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Gen.Model.Packages");
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Package_Definition;
Name : in String) return UBO.Object is
begin
if Name = "name" then
return UBO.To_Object (From.Name);
elsif Name = "package" then
return UBO.To_Object (From.Base_Name);
elsif Name = "tables" then
return From.Tables_Bean;
elsif Name = "enums" then
return From.Enums_Bean;
elsif Name = "types" then
return From.Stypes_Bean;
elsif Name = "queries" then
return From.Queries_Bean;
elsif Name = "beans" then
return From.Beans_Bean;
elsif Name = "usedSpecTypes" then
return From.Used_Spec;
elsif Name = "usedBodyTypes" then
return From.Used_Body;
elsif Name = "useCalendarTime" then
return UBO.To_Object (From.Uses_Calendar_Time);
else
return Definition (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Find the type identified by the name.
-- ------------------------------
function Find_Type (From : in Package_Definition;
Name : in UString)
return Gen.Model.Mappings.Mapping_Definition_Access is
Pos : Mappings.Cursor;
begin
if Index (Name, ".") > 0 then
Pos := From.Types.Find (Name);
if not Mappings.Mapping_Maps.Has_Element (Pos) then
return From.Model.Find_Type (Name);
end if;
else
Pos := From.Types.Find (From.Name & "." & Name);
end if;
if Mappings.Mapping_Maps.Has_Element (Pos) then
return Mappings.Mapping_Maps.Element (Pos);
else
return null;
end if;
end Find_Type;
-- ------------------------------
-- Get the model which contains all the package definitions.
-- ------------------------------
function Get_Model (From : in Package_Definition)
return Model_Definition_Access is
begin
return From.Model;
end Get_Model;
-- ------------------------------
-- Returns True if the package is a pre-defined package and must not be generated.
-- ------------------------------
function Is_Predefined (From : in Package_Definition) return Boolean is
begin
return From.Is_Predefined;
end Is_Predefined;
-- ------------------------------
-- Set the package as a pre-defined package.
-- ------------------------------
procedure Set_Predefined (From : in out Package_Definition) is
begin
From.Is_Predefined := True;
end Set_Predefined;
-- ------------------------------
-- Register the declaration of the given enum in the model.
-- ------------------------------
procedure Register_Enum (O : in out Model_Definition;
Enum : access Gen.Model.Enums.Enum_Definition'Class) is
Name : constant String := Enum.Get_Name;
begin
Log.Info ("Registering enum {0}", Name);
O.Register_Package (Enum.Pkg_Name, Enum.Package_Def);
if Enum.Package_Def.Enums.Find (Name) /= null then
raise Name_Exist with "Enum '" & Name & "' already defined";
end if;
Enum.Package_Def.Enums.Append (Enum.all'Access);
Enum.Package_Def.Types.Include (Enum.Name, Enum.all'Access);
O.Enums.Append (Enum.all'Access);
Gen.Model.Mappings.Register_Type (Enum.Get_Name, Enum.all'Access,
Gen.Model.Mappings.T_ENUM);
end Register_Enum;
-- ------------------------------
-- Register the declaration of the given data type in the model.
-- ------------------------------
procedure Register_Stype (O : in out Model_Definition;
Stype : access Gen.Model.Stypes.Stype_Definition'Class) is
use type Mappings.Mapping_Definition_Access;
Name : constant String := Stype.Get_Name;
Result : Gen.Model.Mappings.Mapping_Definition_Access := null;
Kind : Mappings.Basic_Type := Mappings.T_INTEGER;
begin
Log.Info ("Registering simple data type {0}", Name);
O.Register_Package (Stype.Pkg_Name, Stype.Package_Def);
if Stype.Package_Def.Stypes.Find (Name) /= null then
raise Name_Exist with "Data type '" & Name & "' already defined";
end if;
Stype.Package_Def.Stypes.Append (Stype.all'Access);
Stype.Package_Def.Types.Include (Stype.Name, Stype.all'Access);
O.Stypes.Append (Stype.all'Access);
if Length (Stype.Parent_Type) > 0 then
Result := Gen.Model.Mappings.Find_Type (Stype.Parent_Type, False);
if Result /= null then
Kind := Result.Kind;
end if;
end if;
Gen.Model.Mappings.Register_Type (Stype.Get_Name, Stype.all'Access,
Kind);
end Register_Stype;
-- ------------------------------
-- Register the declaration of the given table in the model.
-- ------------------------------
procedure Register_Table (O : in out Model_Definition;
Table : access Gen.Model.Tables.Table_Definition'Class) is
Name : constant String := Table.Get_Name;
begin
Log.Info ("Registering table {0}", Name);
O.Register_Package (Table.Pkg_Name, Table.Package_Def);
if Table.Package_Def.Tables.Find (Name) /= null then
raise Name_Exist with "Table '" & Name & "' already defined";
end if;
Table.Package_Def.Tables.Append (Table.all'Access);
Table.Package_Def.Types.Include (Table.Name, Table.all'Access);
if O.Is_Generation_Enabled (To_String (Table.Pkg_Name)) then
O.Tables.Append (Table.all'Access);
end if;
end Register_Table;
-- ------------------------------
-- Register the declaration of the given query in the model.
-- ------------------------------
procedure Register_Query (O : in out Model_Definition;
Table : access Gen.Model.Queries.Query_File_Definition'Class) is
begin
O.Register_Package (Table.Pkg_Name, Table.Package_Def);
Table.Package_Def.Queries.Append (Table.all'Access);
O.Queries.Append (Table.all'Access);
end Register_Query;
-- ------------------------------
-- Register the declaration of the given bean in the model.
-- ------------------------------
procedure Register_Bean (O : in out Model_Definition;
Bean : access Gen.Model.Beans.Bean_Definition'Class) is
begin
O.Register_Package (Bean.Pkg_Name, Bean.Package_Def);
Bean.Package_Def.Beans.Append (Bean.all'Access);
Bean.Package_Def.Types.Include (Bean.Name, Bean.all'Access);
O.Queries.Append (Bean.all'Access);
end Register_Bean;
-- ------------------------------
-- Register or find the package knowing its name
-- ------------------------------
procedure Register_Package (O : in out Model_Definition;
Name : in UString;
Result : out Package_Definition_Access) is
Pkg : constant String := Util.Strings.Transforms.To_Upper_Case (To_String (Name));
Key : constant UString := To_UString (Pkg);
Pos : constant Package_Map.Cursor := O.Packages.Find (Key);
begin
if not Package_Map.Has_Element (Pos) then
declare
Map : Ada.Strings.Maps.Character_Mapping;
Base_Name : UString;
begin
Map := Ada.Strings.Maps.To_Mapping (From => ".", To => "-");
Base_Name := Translate (Name, Map);
Result := new Package_Definition;
Result.Set_Name (Name);
Result.Model := O'Unchecked_Access;
Result.Tables_Bean := UBO.To_Object (Result.Tables'Access, UBO.STATIC);
Util.Strings.Transforms.To_Lower_Case (To_String (Base_Name),
Result.Base_Name);
O.Packages.Insert (Key, Result);
Log.Debug ("Ada package '{0}' registered", Name);
end;
else
Result := Package_Map.Element (Pos);
end if;
end Register_Package;
-- ------------------------------
-- Returns True if the model contains at least one package.
-- ------------------------------
function Has_Packages (O : in Model_Definition) return Boolean is
begin
return not O.Packages.Is_Empty;
end Has_Packages;
-- ------------------------------
-- Enable the generation of the Ada package given by the name. By default all the Ada
-- packages found in the model are generated. When called, this enables the generation
-- only for the Ada packages registered here.
-- ------------------------------
procedure Enable_Package_Generation (Model : in out Model_Definition;
Name : in String) is
begin
Model.Gen_Packages.Include (Util.Strings.Transforms.To_Upper_Case (Name));
end Enable_Package_Generation;
-- ------------------------------
-- Returns True if the generation is enabled for the given package name.
-- ------------------------------
function Is_Generation_Enabled (Model : in Model_Definition;
Name : in String) return Boolean is
Upper_Name : constant String := Util.Strings.Transforms.To_Upper_Case (Name);
Key : constant UString := To_UString (Upper_Name);
begin
return not Model.Packages.Element (Key).Is_Predefined
and then (Model.Gen_Packages.Is_Empty or else Model.Gen_Packages.Contains (Upper_Name));
end Is_Generation_Enabled;
-- ------------------------------
-- Iterate over the model tables.
-- ------------------------------
procedure Iterate_Tables (Model : in Model_Definition;
Process : not null access
procedure (Item : in out Tables.Table_Definition)) is
procedure Process_Definition (Item : in Definition_Access);
procedure Process_Definition (Item : in Definition_Access) is
begin
Process (Tables.Table_Definition (Item.all));
end Process_Definition;
begin
Model.Tables.Iterate (Process_Definition'Access);
end Iterate_Tables;
-- ------------------------------
-- Iterate over the model enums.
-- ------------------------------
procedure Iterate_Enums (Model : in Model_Definition;
Process : not null access
procedure (Item : in out Enums.Enum_Definition)) is
procedure Process_Definition (Item : in Definition_Access);
procedure Process_Definition (Item : in Definition_Access) is
begin
Process (Enums.Enum_Definition (Item.all));
end Process_Definition;
begin
Model.Enums.Iterate (Process_Definition'Access);
end Iterate_Enums;
-- ------------------------------
-- Prepare the generation of the package:
-- o identify the column types which are used
-- o build a list of package for the with clauses.
-- ------------------------------
overriding
procedure Prepare (O : in out Package_Definition) is
use Gen.Model.Tables;
procedure Prepare_Operations (List : in Operation_List.List_Definition);
procedure Prepare_Table (Table : in Table_Definition_Access);
procedure Prepare_Definition (Def : in Definition_Access);
procedure Collect_Dependencies (Table : in Definition_Access);
procedure Set_Used_Packages (Into : in out List_Object;
Used_Types : in Gen.Utils.String_Set.Set);
Used_Spec_Types : Gen.Utils.String_Set.Set;
Used_Body_Types : Gen.Utils.String_Set.Set;
-- ------------------------------
-- Look at the operations used to add the necessary with clauses for parameters.
-- ------------------------------
procedure Prepare_Operations (List : in Tables.Operation_List.List_Definition) is
use type Operations.Operation_Type;
Iter : Operation_List.Cursor := List.First;
begin
while Operation_List.Has_Element (Iter) loop
case Operation_List.Element (Iter).Get_Type is
when Operations.UNKNOWN =>
null;
when Operations.ASF_ACTION =>
Used_Spec_Types.Include (To_UString ("Util.Beans.Methods"));
Used_Body_Types.Include (To_UString ("ASF.Events.Faces.Actions"));
when Operations.ASF_UPLOAD =>
Used_Spec_Types.Include (To_UString ("Util.Beans.Methods"));
Used_Spec_Types.Include (To_UString ("ASF.Parts"));
Used_Body_Types.Include (To_UString ("ASF.Parts.Upload_Method"));
when Operations.AWA_EVENT =>
Used_Spec_Types.Include (To_UString ("Util.Beans.Methods"));
Used_Spec_Types.Include (To_UString ("AWA.Events"));
Used_Body_Types.Include (To_UString ("AWA.Events.Action_Method"));
end case;
Operation_List.Next (Iter);
end loop;
end Prepare_Operations;
procedure Prepare_Table (Table : in Table_Definition_Access) is
C : Column_List.Cursor := Table.Members.First;
begin
Table.Prepare;
-- Walk the columns to get their type.
while Column_List.Has_Element (C) loop
declare
use type Model.Mappings.Basic_Type;
use type Model.Mappings.Mapping_Definition_Access;
Col : constant Column_Definition_Access := Column_List.Element (C);
T : constant Model.Mappings.Mapping_Definition_Access := Col.Get_Type_Mapping;
Name : constant String := To_String (Col.Type_Name);
Pkg : constant String := Gen.Utils.Get_Package_Name (Name);
begin
if T = null then
Log.Error ("Column {0} has null type in table {1} - type is name {2}",
Col.Get_Name, Table.Get_Name, Name);
else
case T.Kind is
when Model.Mappings.T_DATE =>
O.Uses_Calendar_Time := True;
when Model.Mappings.T_ENUM | Model.Mappings.T_BEAN | Model.Mappings.T_TABLE =>
if Pkg'Length > 0
and then Pkg /= O.Name
and then not Col.Use_Foreign_Key_Type
then
Used_Spec_Types.Include (To_UString (Pkg));
end if;
when others =>
if T.Kind /= Model.Mappings.T_DATE
and then Name in "Date" | "DateTime" | "Time"
then
Log.Error ("Date type {0} is invalid in table {1} - type is name {2}",
Model.Mappings.Basic_Type'Image (T.Kind), Table.Get_Name,
Name);
end if;
end case;
end if;
end;
Column_List.Next (C);
end loop;
Prepare_Operations (Table.Operations);
-- If the table is using serialization, add the Serializable.IO package.
if Table.Is_Serializable then
Used_Spec_Types.Include (To_UString ("Util.Serialize.IO"));
Used_Body_Types.Include (To_UString ("ADO.Utils.Serialize"));
end if;
if Table.Is_Auditable then
Used_Spec_Types.Include (To_UString ("ADO.Audits"));
end if;
end Prepare_Table;
procedure Prepare_Definition (Def : in Definition_Access) is
begin
if Def.all in Table_Definition'Class then
Prepare_Table (Table_Definition_Access (Def));
else
Def.Prepare;
end if;
end Prepare_Definition;
procedure Collect_Dependencies (Table : in Definition_Access) is
begin
if Table.all in Table_Definition'Class then
Table_Definition'Class (Table.all).Collect_Dependencies;
end if;
end Collect_Dependencies;
procedure Set_Used_Packages (Into : in out List_Object;
Used_Types : in Gen.Utils.String_Set.Set) is
P : Gen.Utils.String_Set.Cursor := Used_Types.First;
begin
while Gen.Utils.String_Set.Has_Element (P) loop
declare
Name : constant UString := Gen.Utils.String_Set.Element (P);
begin
Log.Info ("with {0}", Name);
Into.Values.Append (UBO.To_Object (Name));
end;
Gen.Utils.String_Set.Next (P);
end loop;
end Set_Used_Packages;
begin
Log.Info ("Preparing package {0}", O.Name);
O.Used_Spec_Types.Row := 0;
O.Used_Spec_Types.Values.Clear;
O.Used_Body_Types.Row := 0;
O.Used_Body_Types.Values.Clear;
O.Uses_Calendar_Time := False;
O.Enums.Sort;
O.Queries.Sort;
O.Enums.Iterate (Process => Prepare_Definition'Access);
O.Tables.Iterate (Process => Prepare_Definition'Access);
O.Queries.Iterate (Process => Prepare_Definition'Access);
O.Beans.Iterate (Process => Prepare_Definition'Access);
-- Collect the table dependencies and sort the tables so that tables that depend on
-- others are processed at the end.
O.Tables.Iterate (Process => Collect_Dependencies'Access);
Dependency_Sort (O.Tables);
Set_Used_Packages (O.Used_Spec_Types, Used_Spec_Types);
Set_Used_Packages (O.Used_Body_Types, Used_Body_Types);
end Prepare;
-- ------------------------------
-- Validate the definition by checking and reporting problems to the logger interface.
-- ------------------------------
overriding
procedure Validate (Def : in out Package_Definition;
Log : in out Util.Log.Logging'Class) is
procedure Validate_Definition (Def : in Definition_Access);
procedure Validate_Definition (Def : in Definition_Access) is
begin
Def.Validate (Log);
end Validate_Definition;
begin
Def.Tables.Iterate (Process => Validate_Definition'Access);
Def.Beans.Iterate (Process => Validate_Definition'Access);
end Validate;
-- ------------------------------
-- Initialize the package instance
-- ------------------------------
overriding
procedure Initialize (O : in out Package_Definition) is
begin
O.Enums_Bean := UBO.To_Object (O.Enums'Unchecked_Access, UBO.STATIC);
O.Stypes_Bean := UBO.To_Object (O.Stypes'Unchecked_Access, UBO.STATIC);
O.Tables_Bean := UBO.To_Object (O.Tables'Unchecked_Access, UBO.STATIC);
O.Queries_Bean := UBO.To_Object (O.Queries'Unchecked_Access, UBO.STATIC);
O.Beans_Bean := UBO.To_Object (O.Beans'Unchecked_Access, UBO.STATIC);
O.Used_Spec := UBO.To_Object (O.Used_Spec_Types'Unchecked_Access, UBO.STATIC);
O.Used_Body := UBO.To_Object (O.Used_Body_Types'Unchecked_Access, UBO.STATIC);
end Initialize;
-- ------------------------------
-- Get the number of elements in the list.
-- ------------------------------
overriding
function Get_Count (From : List_Object) return Natural is
begin
Log.Debug ("Length {0}", Natural'Image (Natural (From.Values.Length)));
return Natural (From.Values.Length);
end Get_Count;
-- ------------------------------
-- Set the current row index. Valid row indexes start at 1.
-- ------------------------------
overriding
procedure Set_Row_Index (From : in out List_Object;
Index : in Natural) is
begin
Log.Debug ("Setting row {0}", Natural'Image (Index));
From.Row := Index;
end Set_Row_Index;
-- ------------------------------
-- Get the element at the current row index.
-- ------------------------------
overriding
function Get_Row (From : List_Object) return UBO.Object is
begin
Log.Debug ("Getting row {0}", Natural'Image (From.Row));
return From.Values.Element (From.Row);
end Get_Row;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in List_Object;
Name : in String) return UBO.Object is
pragma Unreferenced (From);
pragma Unreferenced (Name);
begin
return UBO.Null_Object;
end Get_Value;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Model_Definition;
Name : in String) return UBO.Object is
begin
if Name = "tables" then
return From.Tables_Bean;
elsif Name = "dirname" then
return UBO.To_Object (From.Dir_Name);
else
return Definition (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Set the directory name associated with the model. This directory name allows to
-- save and build a model in separate directories for the application, the unit tests
-- and others.
-- ------------------------------
procedure Set_Dirname (O : in out Model_Definition;
Target_Dir : in String;
Model_Dir : in String) is
begin
O.Dir_Name := To_UString (Target_Dir);
O.DB_Name := To_UString (Model_Dir);
end Set_Dirname;
-- ------------------------------
-- Get the directory name associated with the model.
-- ------------------------------
function Get_Dirname (O : in Model_Definition) return String is
begin
return To_String (O.Dir_Name);
end Get_Dirname;
-- ------------------------------
-- Get the directory name which contains the model.
-- ------------------------------
function Get_Model_Directory (O : in Model_Definition) return String is
begin
return To_String (O.DB_Name);
end Get_Model_Directory;
-- ------------------------------
-- Initialize the model definition instance.
-- ------------------------------
overriding
procedure Initialize (O : in out Model_Definition) is
T : constant Util.Beans.Basic.Readonly_Bean_Access := O.Tables'Unchecked_Access;
begin
O.Tables_Bean := UBO.To_Object (T, UBO.STATIC);
O.Dir_Name := To_UString ("src");
end Initialize;
-- ------------------------------
-- Prepare the generation of the package:
-- o identify the column types which are used
-- o build a list of package for the with clauses.
-- ------------------------------
overriding
procedure Prepare (O : in out Model_Definition) is
begin
for P of O.Packages loop
P.Prepare;
end loop;
O.Tables.Sort;
end Prepare;
-- ------------------------------
-- Validate the definition by checking and reporting problems to the logger interface.
-- ------------------------------
overriding
procedure Validate (Def : in out Model_Definition;
Log : in out Util.Log.Logging'Class) is
begin
for P of Def.Packages loop
P.Validate (Log);
end loop;
end Validate;
-- ------------------------------
-- Get the first package of the model definition.
-- ------------------------------
function First (From : Model_Definition) return Package_Cursor is
begin
return From.Packages.First;
end First;
-- ------------------------------
-- Register a type mapping. The <b>From</b> type describes a type in the XML
-- configuration files (hibernate, query, ...) and the <b>To</b> represents the
-- corresponding Ada type.
-- ------------------------------
procedure Register_Type (O : in out Model_Definition;
From : in String;
To : in String) is
begin
null;
end Register_Type;
-- ------------------------------
-- Returns False if the <tt>Left</tt> table does not depend on <tt>Right</tt>.
-- Returns True if the <tt>Left</tt> table depends on the <tt>Right</tt> table.
-- ------------------------------
function Dependency_Compare (Left, Right : in Definition_Access) return Boolean is
use Gen.Model.Tables;
T_Left : constant Table_Definition_Access := Table_Definition'Class (Left.all)'Access;
T_Right : constant Table_Definition_Access := Table_Definition'Class (Right.all)'Access;
begin
Log.Info ("Table {0} and {1} do not depend on each other",
To_String (Left.Name), To_String (Right.Name));
case Gen.Model.Tables.Depends_On (T_Left, T_Right) is
when FORWARD =>
return False;
when BACKWARD =>
return True;
when others =>
-- Two tables that don't depend on each other are sorted on their name.
return Left.Name < Right.Name;
end case;
end Dependency_Compare;
-- ------------------------------
-- Find the type identified by the name.
-- ------------------------------
function Find_Type (From : in Model_Definition;
Name : in UString)
return Gen.Model.Mappings.Mapping_Definition_Access is
N : constant Natural := Ada.Strings.Unbounded.Index (Name, ".", Ada.Strings.Backward);
L : constant Natural := Ada.Strings.Unbounded.Length (Name);
begin
if N = 0 then
return null;
end if;
declare
Pkg_Name : constant String := Ada.Strings.Unbounded.Slice (Name, 1, N - 1);
Base_Name : constant String := Ada.Strings.Unbounded.Slice (Name, N + 1, L);
Key : constant String := Util.Strings.Transforms.To_Upper_Case (Pkg_Name);
Pos : constant Package_Map.Cursor := From.Packages.Find (To_UString (Key));
begin
if Package_Map.Has_Element (Pos) then
return Package_Map.Element (Pos).Find_Type (To_UString (Base_Name));
else
return null;
end if;
end;
end Find_Type;
end Gen.Model.Packages;
|
charlie5/lace | Ada | 902 | ads | with
openGL.Geometry;
package openGL.Model.capsule.textured
--
-- Models a lit and textured capsule.
--
is
type Item is new Model.capsule.item with private;
type View is access all Item'Class;
---------
--- Forge
--
function new_Capsule (Radius : in Real;
Height : in Real;
Image : in asset_Name := null_Asset) return View;
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views;
private
type Item is new Model.capsule.item with
record
Radius : Real;
Height : Real;
Image : asset_Name := null_Asset;
end record;
end openGL.Model.capsule.textured;
|
charlie5/cBound | Ada | 627 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with gmp_c.Pointers;
with Interfaces.C;
package gmp_c.mp_srcptr is
-- Item
--
subtype Item is gmp_c.Pointers.mp_limb_t_Pointer;
-- Items
--
type Items is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mp_srcptr.Item;
-- Pointer
--
type Pointer is access all gmp_c.mp_srcptr.Item;
-- Pointers
--
type Pointers is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mp_srcptr.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all gmp_c.mp_srcptr.Pointer;
end gmp_c.mp_srcptr;
|
reznikmm/matreshka | Ada | 4,186 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Test program to help to test access to arguments and environment.
------------------------------------------------------------------------------
with Ada.Wide_Wide_Text_IO;
with League.Application;
with League.Strings;
with League.String_Vectors;
procedure Arguments_Environment_Test is
use League.Strings;
Args : constant League.String_Vectors.Universal_String_Vector
:= League.Application.Arguments;
begin
if Args.Element (1) /= To_Universal_String ("проверка") then
raise Program_Error;
end if;
for J in 1 .. Args.Length loop
Ada.Wide_Wide_Text_IO.Put_Line (Args.Element (J).To_Wide_Wide_String);
end loop;
Ada.Wide_Wide_Text_IO.Put_Line
(League.Application.Environment.Value
(League.Strings.To_Universal_String ("PATH")).To_Wide_Wide_String);
end Arguments_Environment_Test;
|
AdaCore/gpr | Ada | 3,522 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Calendar;
with Ada.Directories;
with Ada.Exceptions;
with Ada.Text_IO;
with GPR2;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Tree;
with GPR2.Project.Source;
with GPR2.Project.Source.Artifact;
with GPR2.Project.Source.Set;
with GPR2.Unit;
with GPR2.Source_Info.Parser.Ada_Language;
procedure Main is
use Ada;
use GPR2;
Tree : Project.Tree.Object;
Ctx : Context.Object;
procedure Print (S : Project.Source.Object);
-- Print source information and remove dependency files if exists
-----------
-- Print --
-----------
procedure Print (S : Project.Source.Object) is
Dep : Path_Name.Object;
procedure Print_Dependency
(Src : Project.Source.Object;
Unit : GPR2.Unit.Object;
Timestamp : Ada.Calendar.Time);
----------------------
-- Print_Dependency --
----------------------
procedure Print_Dependency
(Src : Project.Source.Object;
Unit : GPR2.Unit.Object;
Timestamp : Ada.Calendar.Time)
is
pragma Unreferenced (Timestamp);
begin
Text_IO.Put_Line
(" dependency unit " & String (Unit.Name) & ' ' & Unit.Kind'Img
& " in " & String (Src.Path_Name.Simple_Name)
& (if Src.Has_Single_Unit then ""
else " at" & Unit.Index'Img));
end Print_Dependency;
begin
Text_IO.Put_Line (String (S.Path_Name.Simple_Name));
Text_IO.Put_Line (" single-unit = "
& S.Has_Single_Unit'Image);
Text_IO.Put_Line (" has naming exception = "
& S.Has_Naming_Exception'Image);
for CU of S.Units loop
Text_IO.Put_Line (" - compilation unit at" & CU.Index'Image);
Text_IO.Put_Line (" unit name = " & String (CU.Name));
Text_IO.Put_Line (" kind = " & CU.Kind'Image);
if not CU.Dependencies.Is_Empty then
Text_IO.Put (" withed units = { ");
for W of CU.Dependencies loop
Text_IO.Put (String (W) & " ");
end loop;
Text_IO.Put_Line ("}");
end if;
if S.Artifacts.Has_Dependency (CU.Index) then
Dep := S.Artifacts.Dependency (CU.Index);
Text_IO.Put_Line
(" object file = " & String (Dep.Simple_Name));
S.Dependencies
(CU.Index, Print_Dependency'Access, Closure => True);
end if;
end loop;
for CU of S.Units loop
Dep := GPR2.Project.Source.Artifact.Dependency
(S, CU.Index, Actual_File => True);
if Dep.Is_Defined then
Directories.Delete_File (Dep.Value);
end if;
end loop;
end Print;
begin
-- Source_Info.Parser.Ada_Language.Unregister;
Tree.Load (Filename => Project.Create ("files/p.gpr"),
Context => Ctx);
for S of Tree.Root_Project.Sources loop
Print (S);
end loop;
-- First iteration over the sources removes dependency files, i.e. next
-- source parsing going to be with Ada_Language parser.
Tree.Invalidate_Sources;
for S of Tree.Root_Project.Sources loop
Print (S);
end loop;
exception
when E : others =>
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
for M of Tree.Log_Messages.all loop
Text_IO.Put_Line (M.Format);
end loop;
end Main;
|
stcarrez/ada-util | Ada | 10,876 | ads | -----------------------------------------------------------------------
-- util-processes -- Process creation and control
-- Copyright (C) 2011, 2012, 2016, 2018, 2021, 2022, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Streams;
with Util.Systems.Types;
with Util.Systems.Os;
with Util.Strings.Vectors;
with Ada.Finalization;
with Ada.Strings.Unbounded;
package Util.Processes is
Invalid_State : exception;
Process_Error : exception;
-- The optional process pipes:
-- <dl>
-- <dt>NONE</dt>
-- <dd>the process will inherit the standard input, output and error.</dd>
-- <dt>READ</dt>
-- <dd>a pipe is created to read the process standard output.</dd>
-- <dt>READ_ERROR</dt>
-- <dd>a pipe is created to read the process standard error. The output and input are
-- inherited.</dd>
-- <dt>READ_ALL</dt>
-- <dd>similar to READ the same pipe is used for the process standard error.</dd>
-- <dt>WRITE</dt>
-- <dd>a pipe is created to write on the process standard input.</dd>
-- <dt>READ_WRITE</dt>
-- <dd>Combines the <b>READ</b> and <b>WRITE</b> modes.</dd>
-- <dt>READ_WRITE_ALL</dt>
-- <dd>Combines the <b>READ_ALL</b> and <b>WRITE</b> modes.</dd>
-- <dt>READ_WRITE_ALL_SEPARATE</dt>
-- <dd>3 pipes are created for the input, output and error</dd>
-- </dl>
type Pipe_Mode is (NONE, READ, READ_ERROR, READ_ALL, WRITE,
READ_WRITE, READ_WRITE_ALL, READ_WRITE_ALL_SEPARATE);
subtype String_Access is Ada.Strings.Unbounded.String_Access;
subtype File_Type is Util.Systems.Types.File_Type;
type Argument_List is array (Positive range <>) of String_Access;
subtype Process_Identifier is Util.Systems.Os.Process_Identifier;
use type Util.Systems.Os.Process_Identifier;
-- ------------------------------
-- Process
-- ------------------------------
type Process is limited private;
-- Before launching the process, redirect the input stream of the process
-- to the specified file.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Input_Stream (Proc : in out Process;
File : in String);
-- Set the output stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Output_Stream (Proc : in out Process;
File : in String;
Append : in Boolean := False);
-- Set the error stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Error_Stream (Proc : in out Process;
File : in String;
Append : in Boolean := False);
-- Set the working directory that the process will use once it is created.
-- The directory must exist or the <b>Invalid_Directory</b> exception will be raised.
procedure Set_Working_Directory (Proc : in out Process;
Path : in String);
-- Set the shell executable path to use to launch a command. The default on Unix is
-- the /bin/sh command. Argument splitting is done by the /bin/sh -c command.
-- When setting an empty shell command, the argument splitting is done by the
-- <tt>Spawn</tt> procedure.
procedure Set_Shell (Proc : in out Process;
Shell : in String);
-- Closes the given file descriptor in the child process before executing the command.
procedure Add_Close (Proc : in out Process;
Fd : in File_Type);
-- Append the argument to the current process argument list.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Append_Argument (Proc : in out Process;
Arg : in String);
-- Set the environment variable to be used by the process before its creation.
procedure Set_Environment (Proc : in out Process;
Name : in String;
Value : in String);
procedure Set_Environment (Proc : in out Process;
Iterate : not null access
procedure
(Process : not null access procedure
(Name : in String;
Value : in String)));
-- Import the default environment variables from the current process.
procedure Set_Default_Environment (Proc : in out Process);
-- Spawn a new process with the given command and its arguments. The standard input, output
-- and error streams are either redirected to a file or to a stream object.
procedure Spawn (Proc : in out Process;
Command : in String;
Arguments : in Argument_List;
Mode : in Pipe_Mode := NONE);
procedure Spawn (Proc : in out Process;
Arguments : in Util.Strings.Vectors.Vector;
Mode : in Pipe_Mode := NONE);
procedure Spawn (Proc : in out Process;
Command : in String;
Mode : in Pipe_Mode := NONE);
procedure Spawn (Proc : in out Process;
Mode : in Pipe_Mode := NONE);
-- Wait for the process to terminate.
procedure Wait (Proc : in out Process);
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
procedure Stop (Proc : in out Process;
Signal : in Positive := 15);
-- Get the process exit status.
function Get_Exit_Status (Proc : in Process) return Integer;
-- Get the process identifier.
function Get_Pid (Proc : in Process) return Process_Identifier;
-- Returns True if the process is running.
function Is_Running (Proc : in Process) return Boolean;
-- Get the process input stream allowing to write on the process standard input.
function Get_Input_Stream (Proc : in Process) return Util.Streams.Output_Stream_Access;
-- Get the process output stream allowing to read the process standard output.
function Get_Output_Stream (Proc : in Process) return Util.Streams.Input_Stream_Access;
-- Get the process error stream allowing to read the process standard output.
function Get_Error_Stream (Proc : in Process) return Util.Streams.Input_Stream_Access;
private
type File_Type_Array is array (Positive range <>) of File_Type;
type File_Type_Array_Access is access all File_Type_Array;
-- The <b>System_Process</b> interface is specific to the system. On Unix, it holds the
-- process identifier. On Windows, more information is necessary, including the process
-- and thread handles. It's a little bit overkill to setup an interface for this but
-- it looks cleaner than having specific system fields here.
type System_Process is limited interface;
type System_Process_Access is access all System_Process'Class;
type Process is new Ada.Finalization.Limited_Controlled with record
Pid : Process_Identifier := -1;
Sys : System_Process_Access := null;
Exit_Value : Integer := -1;
Dir : Ada.Strings.Unbounded.Unbounded_String;
In_File : Ada.Strings.Unbounded.Unbounded_String;
Out_File : Ada.Strings.Unbounded.Unbounded_String;
Err_File : Ada.Strings.Unbounded.Unbounded_String;
Shell : Ada.Strings.Unbounded.Unbounded_String;
Out_Append : Boolean := False;
Err_Append : Boolean := False;
Output : Util.Streams.Input_Stream_Access := null;
Input : Util.Streams.Output_Stream_Access := null;
Error : Util.Streams.Input_Stream_Access := null;
To_Close : File_Type_Array_Access;
end record;
-- Initialize the process instance.
overriding
procedure Initialize (Proc : in out Process);
-- Deletes the process instance.
overriding
procedure Finalize (Proc : in out Process);
-- Wait for the process to exit.
procedure Wait (Sys : in out System_Process;
Proc : in out Process'Class;
Timeout : in Duration) is abstract;
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
procedure Stop (Sys : in out System_Process;
Proc : in out Process'Class;
Signal : in Positive := 15) is abstract;
-- Spawn a new process.
procedure Spawn (Sys : in out System_Process;
Proc : in out Process'Class;
Mode : in Pipe_Mode := NONE) is abstract;
-- Clear the program arguments.
procedure Clear_Arguments (Sys : in out System_Process) is abstract;
-- Append the argument to the process argument list.
procedure Append_Argument (Sys : in out System_Process;
Arg : in String) is abstract;
-- Set the environment variable to be used by the process before its creation.
procedure Set_Environment (Sys : in out System_Process;
Name : in String;
Value : in String) is abstract;
-- Set the process input, output and error streams to redirect and use specified files.
procedure Set_Streams (Sys : in out System_Process;
Input : in String;
Output : in String;
Error : in String;
Append_Output : in Boolean;
Append_Error : in Boolean;
To_Close : in File_Type_Array_Access) is abstract;
-- Deletes the storage held by the system process.
procedure Finalize (Sys : in out System_Process) is abstract;
end Util.Processes;
|
Rodeo-McCabe/orka | Ada | 3,131 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ahven; use Ahven;
with GL.Types;
with Orka.SIMD.SSE.Singles;
with Orka.SIMD.FMA.Singles.Arithmetic;
package body Test_SIMD_FMA_Singles_Arithmetic is
use GL.Types;
use Orka;
use Orka.SIMD.SSE.Singles;
use Orka.SIMD.FMA.Singles.Arithmetic;
overriding
procedure Initialize (T : in out Test) is
begin
T.Set_Name ("Arithmetic");
T.Add_Test_Routine (Test_Multiply_Vector'Access, "Test '*' operator on matrix and vector");
T.Add_Test_Routine (Test_Multiply_Matrices'Access, "Test '*' operator on matrices");
end Initialize;
procedure Test_Multiply_Vector is
-- Matrix is an array of columns
Left : constant m128_Array := ((1.0, 5.0, 9.0, 13.0),
(2.0, 6.0, 10.0, 14.0),
(3.0, 7.0, 11.0, 15.0),
(4.0, 8.0, 12.0, 16.0));
Right : constant m128 := (2.0, 1.0, 1.0, 1.0);
Expected : constant m128 := (11.0, 31.0, 51.0, 71.0);
Result : constant m128 := Left * Right;
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I));
end loop;
end Test_Multiply_Vector;
procedure Test_Multiply_Matrices is
-- Each matrix is an array of columns
Left : constant m128_Array := ((1.0, 5.0, 9.0, 13.0),
(2.0, 6.0, 10.0, 14.0),
(3.0, 7.0, 11.0, 15.0),
(4.0, 8.0, 12.0, 16.0));
Right : constant m128_Array := ((2.0, 1.0, 1.0, 1.0),
(1.0, 2.0, 1.0, 1.0),
(1.0, 1.0, 2.0, 1.0),
(1.0, 1.0, 1.0, 2.0));
Expected : constant m128_Array := ((11.0, 31.0, 51.0, 71.0),
(12.0, 32.0, 52.0, 72.0),
(13.0, 33.0, 53.0, 73.0),
(14.0, 34.0, 54.0, 74.0));
Result : constant m128_Array := Left * Right;
begin
for I in Index_Homogeneous loop
for J in Index_Homogeneous loop
Assert (Expected (I) (J) = Result (I) (J),
"Unexpected Double at " & Index_Homogeneous'Image (I));
end loop;
end loop;
end Test_Multiply_Matrices;
end Test_SIMD_FMA_Singles_Arithmetic;
|
charlie5/aIDE | Ada | 2,882 | adb | with
-- AdaM.Assist.Query.find_All.Driver,
-- AdaM.Assist.Query.find_All.Metrics,
AdaM.Assist.Query.find_Entities.Driver,
AdaM.Assist.Query.find_Entities.Metrics,
Ada.Strings.unbounded,
Ada.Strings.fixed;
package body AdaM.Assist
is
-- function known_Types return AdaM.a_Type.Vector
-- is
-- begin
-- return AdaM.Assist.Query.find_all.Metrics.all_Types;
-- end known_Types;
-- function known_Environment return AdaM.Environment.item
-- is
-- Environ : Environment.item renames AdaM.Assist.Query.find_All.Metrics.Environment;
-- begin
-- Environ.clear;
-- AdaM.Assist.Query.find_All.Driver;
--
-- return Environ;
-- end known_Environment;
function known_Entities return AdaM.Environment.item
is
Environ : Environment.item renames Query.find_Entities.Metrics.Environment;
begin
Environ.clear;
Query.find_Entities.Driver;
return Environ;
end known_Entities;
function Tail_of (the_full_Name : in String) return String
is
use Ada.Strings,
Ada.Strings.fixed;
Dot : constant Natural := Index (the_full_Name, ".", Backward);
begin
if Dot = 0
then
return the_full_Name;
else
return the_full_Name (Dot + 1 .. the_full_Name'Last);
end if;
end Tail_of;
function strip_Tail_of (the_full_Name : in String) return String
is
use Ada.Strings,
Ada.Strings.fixed;
Dot : constant Natural := Index (the_full_Name, ".", Backward);
begin
if Dot = 0 then
return the_full_Name;
else
return the_full_Name (the_full_Name'First .. Dot - 1);
end if;
end strip_Tail_of;
function type_button_Name_of (the_full_Name : in String) return String
is
Tail : constant String := Assist.Tail_of (the_full_Name);
begin
if the_full_Name'Length >= 9
and then the_full_Name (the_full_Name'First .. the_full_Name'First + 8) = "Standard."
then
return Tail;
end if;
declare
Head : constant String := assist.strip_Tail_of (the_full_Name);
begin
return assist.Tail_of (Head) & "." & Tail;
end;
end type_button_Name_of;
function Split (the_Text : in String) return text_Lines
is
use ada.Strings.Fixed,
ada.Strings.Unbounded;
the_Lines : text_Lines;
Dot : Natural := Index (the_Text, ".");
First : Positive := 1;
Last : Positive;
begin
while Dot /= 0
loop
Last := Dot - 1;
the_Lines.append (+the_Text (First .. Last));
First := Dot + 1;
Dot := Index (the_Text, ".", First);
end loop;
the_Lines.append (+the_Text (First .. the_Text'Last));
return the_Lines;
end Split;
end AdaM.Assist;
|
zhmu/ananas | Ada | 3,895 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 4 2 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 42
package System.Pack_42 is
pragma Preelaborate;
Bits : constant := 42;
type Bits_42 is mod 2 ** Bits;
for Bits_42'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_42
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_42 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_42
(Arr : System.Address;
N : Natural;
E : Bits_42;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
function GetU_42
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_42 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned. This version
-- is used when Arr may represent an unaligned address.
procedure SetU_42
(Arr : System.Address;
N : Natural;
E : Bits_42;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value. This version
-- is used when Arr may represent an unaligned address
end System.Pack_42;
|
docandrew/troodon | Ada | 1,925 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with bits_thread_shared_types_h;
package bits_struct_mutex_h is
-- x86 internal mutex struct definitions.
-- Copyright (C) 2019-2021 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C Library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- The GNU C 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
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with the GNU C Library; if not, see
-- <http://www.gnu.org/licenses/>.
type uu_pthread_mutex_s is record
uu_lock : aliased int; -- /usr/include/bits/struct_mutex.h:24
uu_count : aliased unsigned; -- /usr/include/bits/struct_mutex.h:25
uu_owner : aliased int; -- /usr/include/bits/struct_mutex.h:26
uu_nusers : aliased unsigned; -- /usr/include/bits/struct_mutex.h:28
uu_kind : aliased int; -- /usr/include/bits/struct_mutex.h:32
uu_spins : aliased short; -- /usr/include/bits/struct_mutex.h:34
uu_elision : aliased short; -- /usr/include/bits/struct_mutex.h:35
uu_list : aliased bits_thread_shared_types_h.uu_pthread_list_t; -- /usr/include/bits/struct_mutex.h:36
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/struct_mutex.h:22
-- KIND must stay at this position in the structure to maintain
-- binary compatibility with static initializers.
end bits_struct_mutex_h;
|
docandrew/sdlada | Ada | 6,041 | ads | --------------------------------------------------------------------------------------------------------------------
-- 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.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Video.Textures
--
-- Texture abstraction.
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
with System;
private with SDL.C_Pointers;
with SDL.Video.Palettes;
with SDL.Video.Pixel_Formats;
with SDL.Video.Pixels;
with SDL.Video.Rectangles;
limited with SDL.Video.Renderers;
with SDL.Video.Surfaces;
with SDL.Video;
package SDL.Video.Textures is
Texture_Error : exception;
-- Was SDL_TextureAccess.
type Kinds is (Static, Streaming, Target) with
Convention => C;
type Texture is new Ada.Finalization.Limited_Controlled with private;
Null_Texture : constant Texture;
procedure Destroy (Self : in out Texture);
-- Get the alpha value to be multiplied (modulated) into render copy operations.
function Get_Alpha (Self : in Texture) return SDL.Video.Palettes.Colour_Component;
procedure Set_Alpha (Self : in out Texture; Alpha : in SDL.Video.Palettes.Colour_Component);
function Get_Blend_Mode (Self : in Texture) return Blend_Modes;
procedure Set_Blend_Mode (Self : in out Texture; Mode : in Blend_Modes);
function Get_Modulate_Colour (Self : in Texture) return SDL.Video.Palettes.RGB_Colour;
procedure Set_Modulate_Colour (Self : in out Texture; Colour : in SDL.Video.Palettes.RGB_Colour);
-- TODO: Fix this.
-- Lock returns access to pixel data as write-only.
-- function Lock (Self : in out Texture; Pixel_Data : out SDL.Video.Pixels.Pixel) return Boolean with
-- function Lock (Self : in out Texture; Area : in SDL.Video.Rectangles.Rectangle;
-- Pixel_Data : out SDL.Video.Pixels.Pixel) return Boolean with
-- Pre => Self.Locked = False,
-- Post => Result = True and then Self.Locked = True;
--
-- Lock should return an object representing the bitmap data. We should be able to access it like an array,
-- e.g. (x, y) and also using an iterator, which traverses, top -> bottom, left -> right, 1 pixel at a time. We
-- need to be able to do subimage copies using Ada's slices, e.g. bm1 (x .. x2, y .. y2) := bm2 (x .. x2, y .. y2)
--
-- For YV12 format:
--
-- package ARGB_8888_Array is new SDL.Video.Pixels.Texture_Data (Width => , Height => , Element => );
-- procedure Lock_Texture (Self : in out Texture;
-- Pixels : out SDL.Video.Pixels.Pixel_ARGB_8888_Array_Access);
-- Lock
--
-- Lock the entire texture data.
--
-- There will be multiple pixel formats, there should only be one Lock sub-program to handle them all.
generic
type Pixel_Pointer_Type is private;
procedure Lock (Self : in out Texture;
Pixels : out Pixel_Pointer_Type);
-- Lock
--
-- Lock a particular area of the texture data.
generic
type Pixel_Pointer_Type is private;
procedure Lock_Area (Self : in out Texture;
Area : in SDL.Video.Rectangles.Rectangle;
Pixels : out Pixel_Pointer_Type;
Pitch : out SDL.Video.Pixels.Pitches);
procedure Unlock (Self : in out Texture);
procedure Query (Self : in Texture;
Pixel_Format_Name : out SDL.Video.Pixel_Formats.Pixel_Format_Names;
Kind : out Kinds;
Size : out SDL.Sizes);
function Get_Pixel_Format (Self : in Texture) return SDL.Video.Pixel_Formats.Pixel_Format_Names;
function Get_Kind (Self : in Texture) return Kinds;
function Get_Size (Self : in Texture) return SDL.Sizes;
-- SDL_UpdateTexture
-- SDL_UpdateYUVTexture
private
type Texture is new Ada.Finalization.Limited_Controlled with
record
Internal : SDL.C_Pointers.Texture_Pointer := null;
Owns : Boolean := True;
Locked : Boolean := False;
Size : SDL.Sizes := SDL.Zero_Size;
Pixel_Format : SDL.Video.Pixel_Formats.Pixel_Format_Names := SDL.Video.Pixel_Formats.Pixel_Format_Unknown;
end record;
overriding
procedure Finalize (Self : in out Texture);
function Get_Internal_Texture (Self : in Texture) return SDL.C_Pointers.Texture_Pointer with
Export => True,
Convention => Ada;
Null_Texture : constant Texture := (Ada.Finalization.Limited_Controlled with
Internal => null,
Owns => True,
Size => SDL.Zero_Size,
Pixel_Format => Pixel_Formats.Pixel_Format_Unknown,
Locked => False);
end SDL.Video.Textures;
|
io7m/coreland-spatial_hash | Ada | 9,629 | adb | with Ada.Characters.Latin_1;
with Ada.Containers.Ordered_Sets;
with Ada.Containers.Vectors;
with Ada.IO_Exceptions;
with Ada.Integer_Text_IO;
with Ada.Strings.Maps;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Getline;
with Spatial_Hash;
pragma Elaborate_All (Spatial_Hash);
package body Mapper is
package Integer_IO renames Ada.Integer_Text_IO;
package Latin_1 renames Ada.Characters.Latin_1;
package Maps renames Ada.Strings.Maps;
package Text_IO renames Ada.Text_IO;
package UB_Strings renames Ada.Strings.Unbounded;
package Entity_Vectors is new Ada.Containers.Vectors
(Element_Type => Entity_t,
Index_Type => Entity_ID_t);
package Entity_Sets is new Ada.Containers.Ordered_Sets
(Element_Type => Entity_ID_t);
Area_Width : Positive;
Area_Height : Positive;
Cell_Size : Positive;
Line_Buffer : UB_Strings.Unbounded_String;
Entities : Entity_Vectors.Vector;
procedure Bounding_Box
(Entity : in Entity_ID_t;
Bottom : out Positive;
Height : out Positive;
Left : out Positive;
Width : out Positive);
package Spatial_Hashing is new Standard.Spatial_Hash
(Discrete_Axis_Value_Type => Integer,
Entity_ID_Type => Entity_ID_t,
Entity_Sets => Entity_Sets,
Bounding_Box => Bounding_Box);
package Cell_Sets renames Spatial_Hashing.Cell_Sets;
package ID_IO is new Ada.Text_IO.Integer_IO (Entity_ID_t);
package Type_IO is new Ada.Text_IO.Enumeration_IO (Entity_Type_t);
package Cell_IO is new Ada.Text_IO.Integer_IO (Spatial_Hashing.Cell_t);
Spatial_Hash : Spatial_Hashing.Spatial_Hash_t;
Active_Cells : Spatial_Hashing.Cell_Set_t;
--
-- Private subprograms.
--
procedure Clear_Line_Buffer;
procedure Divider;
procedure Fill_Line_Buffer;
procedure Init;
procedure Init_Bounds;
procedure Init_Entities;
procedure Init_IO;
procedure Init_Spatial_Hash;
procedure Read_Integer (Value : out Integer);
procedure Read_Type (Value : out Entity_Type_t);
procedure Statistics;
--
-- Bounding_Box
--
procedure Bounding_Box
(Entity : in Entity_ID_t;
Bottom : out Positive;
Height : out Positive;
Left : out Positive;
Width : out Positive)
is
procedure Query_Entity (Entity : in Entity_t) is
begin
Left := Entity.X;
Width := Entity.Width;
Bottom := Entity.Y;
Height := Entity.Height;
end Query_Entity;
begin
Entity_Vectors.Query_Element
(Container => Entities,
Index => Entity,
Process => Query_Entity'Access);
end Bounding_Box;
--
-- Clear_Line_Buffer
--
procedure Clear_Line_Buffer is
begin
Line_Buffer := UB_Strings.To_Unbounded_String ("");
end Clear_Line_Buffer;
--
-- Divider
--
procedure Divider is
begin
Text_IO.Put_Line ("--------------------------------------------------");
end Divider;
--
-- Fill_Line_Buffer
--
procedure Fill_Line_Buffer is
First_Character : Character;
begin
loop
Getline.Get
(File => Text_IO.Current_Input,
Item => Line_Buffer);
First_Character := UB_Strings.Element
(Source => Line_Buffer,
Index => 1);
exit when First_Character /= '#' and First_Character /= Latin_1.LF;
Clear_Line_Buffer;
end loop;
end Fill_Line_Buffer;
--
-- Init
--
procedure Init is
begin
Init_IO;
Init_Bounds;
Init_Entities;
Init_Spatial_Hash;
end Init;
--
-- Init_Bounds
--
procedure Init_Bounds is
begin
Clear_Line_Buffer;
Fill_Line_Buffer;
Read_Integer (Area_Width);
Read_Integer (Area_Height);
Read_Integer (Cell_Size);
Text_IO.Put ("area_width: ");
Integer_IO.Put (Area_Width);
Text_IO.New_Line;
Text_IO.Put ("area_height: ");
Integer_IO.Put (Area_Height);
Text_IO.New_Line;
Text_IO.Put ("cell_size: ");
Integer_IO.Put (Cell_Size);
Text_IO.New_Line;
Divider;
end Init_Bounds;
--
-- Init_Entities
--
procedure Init_Entities is
Done : Boolean := False;
Entity : Entity_t;
Entity_ID : Entity_ID_t := Entity_ID_t'First;
begin
loop exit when Done;
Clear_Line_Buffer;
begin
Fill_Line_Buffer;
Read_Type (Entity.Entity_Type);
Read_Integer (Entity.X);
Read_Integer (Entity.Y);
Read_Integer (Entity.Width);
Read_Integer (Entity.Height);
Text_IO.Put ("entity: ");
ID_IO.Put (Entity_ID);
Text_IO.Put (" ");
Type_IO.Put (Entity.Entity_Type);
Text_IO.Put (" ");
Integer_IO.Put (Entity.X);
Text_IO.Put (" ");
Integer_IO.Put (Entity.Y);
Text_IO.Put (" ");
Integer_IO.Put (Entity.Width);
Text_IO.Put (" ");
Integer_IO.Put (Entity.Height);
Text_IO.New_Line;
Entity_Vectors.Append (Entities, Entity);
Entity_ID := Entity_ID + 1;
exception
when Ada.IO_Exceptions.End_Error => Done := True;
end;
end loop;
Divider;
end Init_Entities;
--
-- Init_IO
--
procedure Init_IO is
begin
ID_IO.Default_Width := 0;
Cell_IO.Default_Width := 0;
Integer_IO.Default_Width := 0;
end Init_IO;
--
-- Init_Spatial_Hash
--
procedure Init_Spatial_Hash is
begin
Spatial_Hashing.Initialize
(Spatial_Hash => Spatial_Hash,
Width => Area_Width,
Height => Area_Height,
Cell_Size => Cell_Size);
for ID in Entity_ID_t'First .. Entity_Vectors.Last_Index (Entities) loop
declare
procedure Add_Entity_To_Hash (Entity : in Entity_t) is
begin
case Entity.Entity_Type is
when Static => Spatial_Hashing.Add_Static_Entity (Spatial_Hash, ID);
when Dynamic => Spatial_Hashing.Add_Dynamic_Entity (Spatial_Hash, ID);
end case;
end Add_Entity_To_Hash;
begin
Text_IO.Put ("adding: ");
ID_IO.Put (ID);
Text_IO.New_Line;
Entity_Vectors.Query_Element
(Container => Entities,
Index => ID,
Process => Add_Entity_To_Hash'Access);
end;
end loop;
Divider;
end Init_Spatial_Hash;
--
-- Read_Integer
--
procedure Read_Integer
(Value : out Integer)
is
Index : Natural;
Whitespace : constant Maps.Character_Set := Maps.To_Set (" ");
begin
-- Find blank.
Index := UB_Strings.Index
(Source => Line_Buffer,
Set => Whitespace,
From => 1);
if Index = 0 then
Index := UB_Strings.Length (Line_Buffer);
end if;
Value := Positive'Value (UB_Strings.Slice (Line_Buffer, 1, Index));
-- Delete consumed characters.
UB_Strings.Delete
(Source => Line_Buffer,
From => 1,
Through => Index);
-- Delete now leading space.
UB_Strings.Trim
(Source => Line_Buffer,
Side => Ada.Strings.Left);
end Read_Integer;
--
-- Read_Type
--
procedure Read_Type
(Value : out Entity_Type_t)
is
Index : Natural;
Whitespace : constant Maps.Character_Set := Maps.To_Set (" ");
begin
Index := UB_Strings.Index
(Source => Line_Buffer,
Set => Whitespace,
From => 1);
if Index = 0 then
Index := UB_Strings.Length (Line_Buffer);
end if;
Value := Entity_Type_t'Value (UB_Strings.Slice (Line_Buffer, 1, Index));
-- Delete consumed characters.
UB_Strings.Delete
(Source => Line_Buffer,
From => 1,
Through => Index);
-- Delete now leading space.
UB_Strings.Trim
(Source => Line_Buffer,
Side => Ada.Strings.Left);
end Read_Type;
--
-- Run
--
procedure Run is
begin
Init;
Statistics;
end Run;
--
-- Statistics
--
procedure Statistics is
procedure Show_Cell (Position : in Cell_Sets.Cursor) is
begin
Cell_IO.Put (Cell_Sets.Element (Position));
Text_IO.Put (" ");
end Show_Cell;
procedure Show_Entities_For_Cell (Position : in Cell_Sets.Cursor) is
Cell : constant Spatial_Hashing.Cell_t := Cell_Sets.Element (Position);
Entities_In_Cell : Entity_Sets.Set;
procedure Show_Entity (Position : in Entity_Sets.Cursor) is
procedure Show (Entity : in Entity_ID_t) is
begin
ID_IO.Put (Entity);
Text_IO.Put (" ");
end Show;
begin
Entity_Sets.Query_Element (Position, Show'Access);
end Show_Entity;
begin
Spatial_Hashing.Entities_For_Cell
(Spatial_Hash => Spatial_Hash,
Cell => Cell,
Entities => Entities_In_Cell);
Text_IO.Put ("cell ");
Cell_IO.Put (Cell);
Text_IO.Put (" entities: ");
Entity_Sets.Iterate (Entities_In_Cell, Show_Entity'Access);
Text_IO.New_Line;
Text_IO.Put ("number of entities in cell: ");
Integer_IO.Put (Natural (Entity_Sets.Length (Entities_In_Cell)));
Text_IO.New_Line;
end Show_Entities_For_Cell;
begin
Spatial_Hashing.Active_Cells
(Spatial_Hash => Spatial_Hash,
Cells => Active_Cells);
Text_IO.Put ("number of cells active: ");
Integer_IO.Put (Natural (Cell_Sets.Length (Active_Cells)));
Text_IO.New_Line;
Text_IO.Put ("cells: ");
Cell_Sets.Iterate (Active_Cells, Show_Cell'Access);
Text_IO.New_Line;
Divider;
Cell_Sets.Iterate (Active_Cells, Show_Entities_For_Cell'Access);
end Statistics;
end Mapper;
|
zhmu/ananas | Ada | 4,690 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G E N _ I L --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
package body Gen_IL is
procedure Put (F : File_Type; S : String);
-- The output primitive
-----------
-- Image --
-----------
function Image (X : Root_Int) return String is
Result : constant String := X'Img;
begin
if Result (1) = ' ' then
return Result (2 .. Result'Last);
else
return Result;
end if;
end Image;
----------------
-- Capitalize --
----------------
procedure Capitalize (S : in out String) is
Cap : Boolean := True;
begin
for X of S loop
declare
Old : constant Character := X;
begin
if Cap then
X := To_Upper (X);
else
X := To_Lower (X);
end if;
Cap := not (Is_Letter (Old) or else Is_Digit (Old));
end;
end loop;
end Capitalize;
----------------
-- Capitalize --
----------------
function Capitalize (S : String) return String is
begin
return Result : String (S'Range) := S do
Capitalize (Result);
end return;
end Capitalize;
-----------------
-- Create_File --
-----------------
procedure Create_File (Buffer : in out Sink; Name : String) is
begin
Create (Buffer.File, Out_File, Name);
Buffer.Indent := 0;
Buffer.New_Line := True;
end Create_File;
---------------------
-- Increase_Indent --
---------------------
procedure Increase_Indent (Buffer : in out Sink; Amount : Natural) is
begin
Buffer.Indent := Buffer.Indent + Amount;
end Increase_Indent;
---------------------
-- Decrease_Indent --
---------------------
procedure Decrease_Indent (Buffer : in out Sink; Amount : Natural) is
begin
Buffer.Indent := Buffer.Indent - Amount;
end Decrease_Indent;
---------
-- Put --
---------
procedure Put (F : File_Type; S : String) is
begin
String'Write (Stream (F), S);
end Put;
procedure Put (Buffer : in out Sink; Item : String) is
begin
-- If the first character is LF, indent after it only
if Item (Item'First) = ASCII.LF then
Put (Buffer.File, LF);
Buffer.New_Line := True;
if Item'Length > 1 then
Put (Buffer, Item (Item'First + 1 .. Item'Last));
end if;
return;
end if;
-- If this is a new line, indent
if Buffer.New_Line and then Buffer.Indent > 0 then
declare
S : constant String (1 .. Buffer.Indent) := (others => ' ');
begin
Put (Buffer.File, S);
end;
end if;
Put (Buffer.File, Item);
Buffer.New_Line := Item (Item'Last) = ASCII.LF;
end Put;
end Gen_IL;
|
io7m/coreland-plexlog-ada | Ada | 18,860 | adb | with Ada.Calendar;
with Ada.Characters.Latin_1;
with Ada.Containers.Indefinite_Vectors;
with Ada.Directories;
with Ada.Streams;
with Ada.Strings.Fixed;
with Ada.Strings;
with Ada.Unchecked_Conversion;
package body Plexlog.API is
package Calendar renames Ada.Calendar;
package Directories renames Ada.Directories;
package F_Strings renames Ada.Strings.Fixed;
package Stream_IO renames Ada.Streams.Stream_IO;
package Streams renames Ada.Streams;
package Strings renames Ada.Strings;
use type POSIX.FD_t;
use type Stream_IO.Count;
--
-- Log file is currently locked?
--
function Have_Directory_Lock (Context : in Plexlog_t) return Boolean is
begin
return Context.Lock_FD /= POSIX.Invalid_FD;
end Have_Directory_Lock;
--
-- Acquire write lock.
--
procedure Lock_Directory (Context : in out Plexlog_t) is
pragma Assert (not Have_Directory_Lock (Context));
begin
Dir_Stack.Push_FD (Context.Dir_Stack, Context.Log_Dir_FD);
Context.Lock_FD := POSIX.Open_Create ("lock");
if Context.Lock_FD = POSIX.Invalid_FD then
raise Lock_Error with "could not open lock";
end if;
if not POSIX.FD_Write_Lock (Context.Lock_FD) then
raise Lock_Error with "could not set lock on file";
end if;
exception
when Dir_Stack.Push_Error =>
raise Lock_Error with "could not switch to log directory";
when Lock_Error =>
POSIX.Close (Context.Lock_FD);
Dir_Stack.Pop (Context.Dir_Stack);
raise;
end Lock_Directory;
--
-- Relinquish write lock.
--
procedure Unlock_Directory (Context : in out Plexlog_t) is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (Dir_Stack.Size (Context.Dir_Stack) > 0);
begin
Dir_Stack.Pop (Context.Dir_Stack);
if not POSIX.FD_Write_Unlock (Context.Lock_FD) then
raise Lock_Error with "could not unlock file";
end if;
if not POSIX.Close (Context.Lock_FD) then
raise Lock_Error with "could not close lock descriptor";
end if;
Context.Lock_FD := POSIX.Invalid_FD;
exception
when Dir_Stack.Pop_Error =>
raise Lock_Error with "could not remove old directory descriptor";
end Unlock_Directory;
--
-- File information type.
--
type Log_File_t (Length : Positive) is record
Name : String (1 .. Length);
Modification_Time : Calendar.Time;
end record;
function Log_File_Compare
(Left : in Log_File_t;
Right : in Log_File_t) return Boolean
is
use type Calendar.Time;
begin
return Left.Modification_Time > Right.Modification_Time;
end Log_File_Compare;
package Log_File_Vectors is new Ada.Containers.Indefinite_Vectors
(Index_Type => Natural,
Element_Type => Log_File_t);
package Log_File_Vectors_Sorting is new
Log_File_Vectors.Generic_Sorting (Log_File_Compare);
--
-- Remove oldest log files.
--
procedure Rotate_Remove_Old (Context : in Plexlog_t) is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
pragma Assert (Context.Files_Max > 0);
Log_List : Log_File_Vectors.Vector;
-- Collect current log files.
procedure Collect_Log_File
(Dir_Entry : in Directories.Directory_Entry_Type)
is
Name : constant String := Directories.Simple_Name (Dir_Entry);
begin
if Name (1) = '@' then
declare
Log_File : constant Log_File_t (Length => Name'Length) :=
(Length => Name'Length,
Name => Name,
Modification_Time => Directories.Modification_Time (Dir_Entry));
begin
Log_File_Vectors.Append
(Container => Log_List,
New_Item => Log_File);
end;
end if;
end Collect_Log_File;
-- Delete log file
procedure Remove_Log (File : in Log_File_t) is
begin
Directories.Delete_File (File.Name);
end Remove_Log;
begin
-- Collect names and times of all log files.
Directories.Search
(Directory => Directories.Current_Directory,
Pattern => "",
Filter => (Directories.Ordinary_File => True, others => False),
Process => Collect_Log_File'Access);
-- Sort collected log files by date.
Log_File_Vectors_Sorting.Sort (Log_List);
-- Select and remove all log files over Files_Max
declare
Num_Files : constant Natural := Natural (Log_File_Vectors.Length (Log_List));
Max_Files : constant Natural := Context.Files_Max - 1; -- ignore 'current'
begin
if Num_Files >= Max_Files then
for Index in Max_Files .. Num_Files - 1 loop
Log_File_Vectors.Query_Element
(Container => Log_List,
Index => Index,
Process => Remove_Log'Access);
end loop;
end if;
end;
end Rotate_Remove_Old;
--
-- Remove old log files and rename current to a timestamp
--
procedure Rotate
(Context : in out Plexlog_t)
is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
TAIA : chrono.TAIA.TAIA_t;
TAIA_Label : chrono.TAIA.Label_TAI64N_t;
begin
chrono.TAIA.Now (TAIA);
chrono.TAIA.Label_TAI64N (TAIA, TAIA_Label);
-- Remove old log files if number of files is limited.
if Context.Files_Max > 0 then
Rotate_Remove_Old (Context);
end if;
Rename_Current : declare
Label_String : constant String := "@" & String (TAIA_Label);
begin
if not POSIX.Rename ("current", "@" & String (TAIA_Label)) then
raise Rotate_Error with "could not rename current to " & Label_String;
end if;
end Rename_Current;
end Rotate;
--
-- Character -> NN base16.
--
procedure Character_To_Hex
(Value : in Character;
Buffer : out String)
is
Hex_Table : constant String := "0123456789abcdef";
Int_Value : constant Natural := Character'Pos (Value);
begin
Buffer (Buffer'First) := Hex_Table (1 + ((Int_Value / 16) mod 16));
Buffer (Buffer'First + 1) := Hex_Table (1 + (Int_Value mod 16));
end Character_To_Hex;
pragma Inline (Character_To_Hex);
--
-- Filter Character.
--
type Character_Width_t is range 1 .. 4;
type Character_Buffer_t is array
(Character_Width_t'First .. Character_Width_t'Last) of Character;
procedure Filter_Character
(Item : in Character;
Write : in Boolean := True;
Length : out Positive;
Buffer : out Character_Buffer_t)
is
Character_High : constant Character := Ada.Characters.Latin_1.DEL;
Character_Low : constant Character := Ada.Characters.Latin_1.US;
begin
-- Character out of printable ASCII range
if (Item <= Character_Low) or (Item >= Character_High) then
if Write then
Buffer (1) := '\';
Buffer (2) := 'x';
Character_To_Hex (Item, String (Buffer (3 .. 4)));
end if;
-- if Character'Pos (Item) >= 16#0f# then
Length := 4;
-- else
-- Length := 3;
-- end if;
return;
end if;
-- Escape slashes
if Item = '\' then
if Write then
Buffer (1) := '\';
Buffer (2) := '\';
end if;
Length := 2;
return;
end if;
-- Ordinary printable ASCII
if Write then
Buffer (1) := Item;
end if;
Length := 1;
end Filter_Character;
--
-- Get length of message after filtering.
--
function Filtered_Message_Length (Data : in String) return Natural is
Current_Length : Natural;
Accumulated_Length : Natural := 0;
Buffer : Character_Buffer_t;
begin
for Index in Data'Range loop
Filter_Character
(Item => Data (Index),
Write => False,
Length => Current_Length,
Buffer => Buffer);
Accumulated_Length := Accumulated_Length + Current_Length;
end loop;
return Accumulated_Length;
end Filtered_Message_Length;
--
-- Return String associated with level
--
type String_Access_t is access constant String;
Log_None_String : aliased constant String := "";
Log_Debug_String : aliased constant String := "debug";
Log_Info_String : aliased constant String := "info";
Log_Notice_String : aliased constant String := "notice";
Log_Warn_String : aliased constant String := "warn";
Log_Error_String : aliased constant String := "error";
Log_Fatal_String : aliased constant String := "fatal";
Log_Audit_String : aliased constant String := "audit";
Level_Strings : constant array (Level_t range <>) of String_Access_t :=
(Log_None => Log_None_String'Access,
Log_Debug => Log_Debug_String'Access,
Log_Info => Log_Info_String'Access,
Log_Notice => Log_Notice_String'Access,
Log_Warn => Log_Warn_String'Access,
Log_Error => Log_Error_String'Access,
Log_Fatal => Log_Fatal_String'Access,
Log_Audit => Log_Audit_String'Access);
function Level_String
(Level : in Level_t) return String is
begin
return Level_Strings (Level).all;
end Level_String;
--
-- Convenience functions
--
function Log_Is_Empty
(Context : in Plexlog_t) return Boolean
is
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
begin
return Context.Log_Size = 0;
end Log_Is_Empty;
pragma Inline (Log_Is_Empty);
function Log_Has_Space_For
(Context : in Plexlog_t;
Length : in Natural) return Boolean
is
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
begin
return (Context.Log_Size + Stream_IO.Count (Length)
+ Message_Minimum_Length) < Stream_IO.Count (Context.Size_Max);
end Log_Has_Space_For;
pragma Inline (Log_Has_Space_For);
--
-- Open/create 'current' log file.
--
procedure Open_Current (Context : in out Plexlog_t) is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
begin
begin
Stream_IO.Open
(File => Context.Log_File,
Mode => Stream_IO.Append_File,
Name => "current");
exception
when Stream_IO.Name_Error =>
Stream_IO.Create
(File => Context.Log_File,
Mode => Stream_IO.Append_File,
Name => "current");
end;
Context.Log_Size := Stream_IO.Size (Context.Log_File);
end Open_Current;
--
-- Stream write.
--
procedure Write_Raw
(Context : in Plexlog_t;
Data : in String)
is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
subtype Source is String (1 .. Data'Last);
subtype Target is Streams.Stream_Element_Array
(1 .. Streams.Stream_Element_Offset (Data'Last));
function Convert is new Ada.Unchecked_Conversion (Source, Target);
begin
Stream_IO.Write
(File => Context.Log_File,
Item => Convert (Data));
end Write_Raw;
--
-- Write log line prefix.
--
procedure Write_Line_Prefix
(Context : in out Plexlog_t;
Level_String : in String := "";
PID_String : in String;
TAIA_Label : in chrono.TAIA.Label_TAI64N_t)
is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
begin
if Level_String /= "" then
Write_Raw
(Context => Context,
Data => "@" & String (TAIA_Label) & " " & PID_String & " " & Level_String & ": ");
else
Write_Raw
(Context => Context,
Data => "@" & String (TAIA_Label) & " " & PID_String & " ");
end if;
end Write_Line_Prefix;
--
-- Write message, returning number of bytes processed and written.
--
type Log_Status_t is record
Characters_Written : Natural;
Characters_Processed : Natural;
end record;
procedure Write_Message
(Context : in out Plexlog_t;
Message : in String;
Limit : in Natural := 0;
Status : out Log_Status_t)
is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
Filtered_Length : Natural;
Buffer : Character_Buffer_t;
begin
Status.Characters_Processed := 0;
Status.Characters_Written := 0;
for Index in Message'Range loop
Filter_Character
(Item => Message (Index),
Write => True,
Length => Filtered_Length,
Buffer => Buffer);
if Limit > 0 then
exit when Status.Characters_Written + Filtered_Length >= Limit;
end if;
declare
Min : constant Character_Width_t := Buffer'First;
Max : constant Character_Width_t := Character_Width_t (Filtered_Length);
begin
Write_Raw
(Context => Context,
Data => String (Buffer (Min .. Max)));
end;
Status.Characters_Processed := Status.Characters_Processed + 1;
Status.Characters_Written := Status.Characters_Written + Filtered_Length;
end loop;
Write_Raw (Context, "" & Ada.Characters.Latin_1.LF);
Stream_IO.Flush (Context.Log_File);
end Write_Message;
--
-- Write log data, rotating log files if necessary.
--
procedure Write_With_Rotate
(Context : in out Plexlog_t;
Level_String : in String;
TAIA_Label : in chrono.TAIA.Label_TAI64N_t;
PID_String : in String;
Data : in String)
is
pragma Assert (Have_Directory_Lock (Context));
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
Max_Length : constant Natural := Natural (Context.Size_Max) - Message_Minimum_Length;
Filtered_Length : Natural := Filtered_Message_Length (Data);
Current_Offset : Natural := 0;
begin
-- Message cannot fit completely within remaining space.
if not Log_Has_Space_For (Context, Filtered_Length) then
-- Current log file requires rotation?
if not Log_Is_Empty (Context) then
Stream_IO.Close (Context.Log_File);
Rotate (Context);
Open_Current (Context);
end if;
-- Split message across as many log files as is required.
Write_Loop : loop
-- Message will fit in log file without splitting?
exit Write_Loop when Log_Has_Space_For (Context, Filtered_Length);
-- Write line prefix.
Write_Line_Prefix
(Context => Context,
Level_String => Level_String,
PID_String => PID_String,
TAIA_Label => TAIA_Label);
-- Write as much data as current log file limit allows.
declare
Status : Log_Status_t;
begin
Write_Message
(Context => Context,
Message => Data (Data'First + Current_Offset .. Data'Last),
Limit => Max_Length,
Status => Status);
Current_Offset := Current_Offset + Status.Characters_Processed;
Filtered_Length := Filtered_Message_Length
(Data (Data'First + Current_Offset .. Data'Last));
end;
-- Close current log file.
Stream_IO.Close (Context.Log_File);
-- Create new log file.
Rotate (Context);
Open_Current (Context);
end loop Write_Loop;
end if;
-- Write remaining data, if any.
if Data (Data'First + Current_Offset .. Data'Last)'Length > 0 then
-- Write line prefix.
Write_Line_Prefix
(Context => Context,
Level_String => Level_String,
PID_String => PID_String,
TAIA_Label => TAIA_Label);
-- Write message, no splitting.
declare
Status : Log_Status_t;
begin
Write_Message
(Context => Context,
Message => Data (Data'First + Current_Offset .. Data'Last),
Status => Status);
end;
end if;
end Write_With_Rotate;
--
-- API
--
procedure Open
(Context : in out Plexlog_t;
Path : in String)
is
pragma Assert (not Have_Directory_Lock (Context));
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
begin
Context.Log_Dir_FD := POSIX.Open_Read (Path);
if Context.Log_Dir_FD = POSIX.Invalid_FD then
raise Open_Error;
end if;
end Open;
procedure Set_Maximum_Saved_Files
(Context : in out Plexlog_t;
Max_Files : in Natural) is
begin
Context.Files_Max := Max_Files;
end Set_Maximum_Saved_Files;
procedure Set_Maximum_File_Size
(Context : in out Plexlog_t;
Max_File_Size : in File_Size_t) is
begin
Context.Size_Max := Max_File_Size;
Context.Size_Limited := True;
end Set_Maximum_File_Size;
procedure Set_Unlimited_File_Size
(Context : in out Plexlog_t) is
begin
Context.Size_Limited := False;
end Set_Unlimited_File_Size;
procedure Write
(Context : in out Plexlog_t;
Data : in String;
Level : in Level_t := Log_None)
is
pragma Assert (not Have_Directory_Lock (Context));
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
TAIA : chrono.TAIA.TAIA_t;
TAIA_Label : chrono.TAIA.Label_TAI64N_t;
begin
chrono.TAIA.Now (TAIA);
chrono.TAIA.Label_TAI64N (TAIA, TAIA_Label);
Lock_Directory (Context);
Open_Current (Context);
if Context.Size_Limited then
Write_With_Rotate
(Context => Context,
Level_String => Level_String (Level),
TAIA_Label => TAIA_Label,
PID_String => F_Strings.Trim (POSIX.PID_t'Image (POSIX.Get_PID), Strings.Left),
Data => Data);
else
Write_Line_Prefix
(Context => Context,
Level_String => Level_String (Level),
PID_String => F_Strings.Trim (POSIX.PID_t'Image (POSIX.Get_PID), Strings.Left),
TAIA_Label => TAIA_Label);
declare
Status : Log_Status_t;
begin
Write_Message
(Context => Context,
Message => Data,
Status => Status);
pragma Assert (Status.Characters_Processed = Data'Length);
end;
end if;
pragma Assert (Stream_IO.Is_Open (Context.Log_File));
Stream_IO.Close (Context.Log_File);
Unlock_Directory (Context);
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
exception
when others =>
pragma Assert (not Stream_IO.Is_Open (Context.Log_File));
if Have_Directory_Lock (Context) then
Unlock_Directory (Context);
end if;
raise;
end Write;
procedure Close
(Context : in out Plexlog_t) is
begin
if Context.Log_Dir_FD /= POSIX.Invalid_FD then
POSIX.Close (Context.Log_Dir_FD);
end if;
if Context.Lock_FD /= POSIX.Invalid_FD then
POSIX.Close (Context.Lock_FD);
end if;
end Close;
function Space_Requirement
(Max_Files : in Long_Positive;
Max_Size : in Long_Positive) return Long_Positive is
begin
return (Max_Files * Max_Size) + Max_Size;
end Space_Requirement;
end Plexlog.API;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.File_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_File_Element_Node is
begin
return Self : Form_File_Element_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Form_File_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Form_File
(ODF.DOM.Form_File_Elements.ODF_Form_File_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_File_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.File_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Form_File_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Form_File
(ODF.DOM.Form_File_Elements.ODF_Form_File_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Form_File_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Form_File
(Visitor,
ODF.DOM.Form_File_Elements.ODF_Form_File_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.File_Element,
Form_File_Element_Node'Tag);
end Matreshka.ODF_Form.File_Elements;
|
PThierry/ewok-kernel | Ada | 18,976 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.exported.dma; use ewok.exported.dma;
with ewok.sanitize;
with ewok.tasks;
with ewok.interrupts;
with ewok.devices_shared;
with ewok.debug;
#if CONFIG_KERNEL_DOMAIN
with ewok.perm;
#end if;
with soc.dma; use soc.dma;
with soc.dma.interfaces; use soc.dma.interfaces;
with soc.nvic;
package body ewok.dma
with spark_mode => off
is
procedure get_registered_dma_entry
(index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
begin
for id in registered_dma'range loop
if registered_dma(id).status = DMA_UNUSED then
registered_dma(id).status := DMA_USED;
index := id;
success := true;
return;
end if;
end loop;
success := false;
end get_registered_dma_entry;
function has_same_dma_channel
(index : ewok.dma_shared.t_registered_dma_index;
user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
and
registered_dma(index).config.channel =
soc.dma.t_channel_index (user_config.channel)
then
return true;
else
return false;
end if;
end has_same_dma_channel;
function stream_is_already_used
(user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).status /= DMA_UNUSED then
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
then
return true;
end if;
end if;
end loop;
return false;
end stream_is_already_used;
function task_owns_dma_stream
(caller_id : ewok.tasks_shared.t_task_id;
dma_id : ewok.exported.dma.t_controller;
stream_id : ewok.exported.dma.t_stream)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).task_id = caller_id
and then
registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (dma_id)
and then
registered_dma(index).config.stream =
soc.dma.t_stream_index (stream_id)
then
return true;
end if;
end loop;
return false;
end task_owns_dma_stream;
procedure enable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end enable_dma_stream;
procedure disable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.disable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end disable_dma_stream;
procedure enable_dma_irq
(index : in ewok.dma_shared.t_registered_dma_index)
is
-- Peripheral associated with the DMA stream
periph_id : constant soc.devmap.t_periph_id := registered_dma(index).periph_id;
-- DMAs have only one IRQ line per stream
intr : constant soc.interrupts.t_interrupt :=
soc.devmap.periphs(periph_id).interrupt_list
(soc.devmap.t_interrupt_range'first);
begin
soc.nvic.enable_irq (soc.nvic.to_irq_number (intr));
end enable_dma_irq;
function is_config_complete
(config : soc.dma.interfaces.t_dma_config)
return boolean
is
begin
if config.in_addr = 0 or
config.out_addr = 0 or
config.bytes = 0 or
config.transfer_dir = MEMORY_TO_MEMORY or
(config.transfer_dir = MEMORY_TO_PERIPHERAL and config.in_handler = 0)
or
(config.transfer_dir = PERIPHERAL_TO_MEMORY and config.out_handler = 0)
then
return false;
else
return true;
end if;
end is_config_complete;
function sanitize_dma
(user_config : ewok.exported.dma.t_dma_user_config;
caller_id : ewok.tasks_shared.t_task_id;
to_configure : ewok.exported.dma.t_config_mask;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if to_configure.buffer_in then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.in_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_range_in_any_slot
(user_config.out_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.out_addr, unsigned_32 (user_config.size),
SHM_ACCESS_WRITE, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.out_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if to_configure.buffer_in then
if not ewok.sanitize.is_range_in_any_slot
(user_config.in_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.in_addr, unsigned_32 (user_config.size),
SHM_ACCESS_READ, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.out_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.in_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_MEMORY =>
return false;
end case;
return true;
end sanitize_dma;
function sanitize_dma_shm
(shm : ewok.exported.dma.t_dma_shm_info;
caller_id : ewok.tasks_shared.t_task_id;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
if not ewok.tasks.is_real_user (shm.granted_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong target"));
return false;
end if;
if shm.accessed_id /= caller_id then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong caller"));
return false;
end if;
#if CONFIG_KERNEL_DOMAIN
if not ewok.perm.is_same_domain (shm.granted_id, shm.accessed_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): not same domain"));
return false;
end if;
#end if;
if not ewok.sanitize.is_range_in_data_slot
(shm.base, shm.size, caller_id, mode) and
not ewok.sanitize.is_range_in_devices_slot
(shm.base, shm.size, caller_id)
then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): shm not in range"));
return false;
end if;
return true;
end sanitize_dma_shm;
procedure reconfigure_stream
(user_config : in out ewok.exported.dma.t_dma_user_config;
index : in ewok.dma_shared.t_registered_dma_index;
to_configure : in ewok.exported.dma.t_config_mask;
caller_id : in ewok.tasks_shared.t_task_id;
success : out boolean)
is
periph_id : constant soc.devmap.t_periph_id := registered_dma(index).periph_id;
ok : boolean;
begin
if not to_configure.buffer_size then
user_config.size := registered_dma(index).config.bytes;
else
registered_dma(index).config.bytes := user_config.size;
end if;
if to_configure.buffer_in then
registered_dma(index).config.in_addr := user_config.in_addr;
end if;
if to_configure.buffer_out then
registered_dma(index).config.out_addr := user_config.out_addr;
end if;
if to_configure.mode then
registered_dma(index).config.mode := user_config.mode;
end if;
if to_configure.priority then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_priority :=
user_config.out_priority;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_priority :=
user_config.in_priority;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log
(debug.ERROR,
"reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
if to_configure.direction then
registered_dma(index).config.transfer_dir := user_config.transfer_dir;
end if;
if to_configure.handlers then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_handler :=
user_config.out_handler;
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_handler :=
user_config.in_handler;
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list (soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log (debug.ERROR, "reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
--
-- Configuring the DMA
--
soc.dma.interfaces.reconfigure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config,
soc.dma.interfaces.t_config_mask (to_configure));
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
else
registered_dma(index).status := DMA_USED;
end if;
success := true;
end reconfigure_stream;
procedure init_stream
(user_config : in ewok.exported.dma.t_dma_user_config;
caller_id : in ewok.tasks_shared.t_task_id;
index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
periph_id : soc.devmap.t_periph_id;
ok : boolean;
begin
-- Find a free entry in the registered_dma array
get_registered_dma_entry (index, ok);
if not ok then
pragma DEBUG (debug.log ("dma.init(): no DMA entry available"));
success := false;
return;
end if;
-- Copy the user configuration
registered_dma(index).config :=
(dma_id => soc.dma.t_dma_periph_index (user_config.controller),
stream => soc.dma.t_stream_index (user_config.stream),
channel => soc.dma.t_channel_index (user_config.channel),
bytes => user_config.size,
in_addr => user_config.in_addr,
in_priority => user_config.in_priority,
in_handler => user_config.in_handler,
out_addr => user_config.out_addr,
out_priority => user_config.out_priority,
out_handler => user_config.out_handler,
flow_controller => user_config.flow_controller,
transfer_dir => user_config.transfer_dir,
mode => user_config.mode,
data_size => user_config.data_size,
memory_inc => boolean (user_config.memory_inc),
periph_inc => boolean (user_config.periph_inc),
mem_burst_size => user_config.mem_burst_size,
periph_burst_size => user_config.periph_burst_size);
registered_dma(index).task_id := caller_id;
registered_dma(index).periph_id :=
soc.devmap.find_dma_periph
(soc.dma.t_dma_periph_index (user_config.controller),
soc.dma.t_stream_index (user_config.stream));
periph_id := registered_dma(index).periph_id;
-- Set up the interrupt handler
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if user_config.out_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if user_config.in_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log ("dma.init(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
else
registered_dma(index).status := DMA_USED;
end if;
-- Reset the DMA stream
soc.dma.interfaces.reset_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
-- Configure the DMA stream
soc.dma.interfaces.configure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config);
success := true;
end init_stream;
procedure init
is
begin
soc.dma.enable_clocks;
end init;
procedure clear_dma_interrupts
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
raise program_error;
end if;
if not task_owns_dma_stream (caller_id, t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
raise program_error;
end if;
soc.dma.interfaces.clear_all_interrupts
(soc_dma_id, soc_stream_id);
end clear_dma_interrupts;
procedure get_status_register
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt;
status : out soc.dma.t_dma_stream_int_status;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
success := false;
return;
end if;
if not task_owns_dma_stream (caller_id,
t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
success := false;
return;
end if;
status := soc.dma.interfaces.get_interrupt_status
(soc_dma_id, soc_stream_id);
soc.dma.interfaces.clear_all_interrupts (soc_dma_id, soc_stream_id);
success := true;
end get_status_register;
end ewok.dma;
|
reznikmm/matreshka | Ada | 6,920 | 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.Sequence_Decl_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Sequence_Decl_Element_Node is
begin
return Self : Text_Sequence_Decl_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Sequence_Decl_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Sequence_Decl
(ODF.DOM.Text_Sequence_Decl_Elements.ODF_Text_Sequence_Decl_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Sequence_Decl_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Sequence_Decl_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Sequence_Decl_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Sequence_Decl
(ODF.DOM.Text_Sequence_Decl_Elements.ODF_Text_Sequence_Decl_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Sequence_Decl_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Sequence_Decl
(Visitor,
ODF.DOM.Text_Sequence_Decl_Elements.ODF_Text_Sequence_Decl_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Sequence_Decl_Element,
Text_Sequence_Decl_Element_Node'Tag);
end Matreshka.ODF_Text.Sequence_Decl_Elements;
|
reznikmm/matreshka | Ada | 6,271 | 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;
with ODF.DOM.Elements.Style.Background_Image.Internals;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Elements.Style.Background_Image is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access Style_Background_Image_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.ODF_Visitor'Class then
ODF.DOM.Visitors.ODF_Visitor'Class
(Visitor).Enter_Style_Background_Image
(ODF.DOM.Elements.Style.Background_Image.Internals.Create
(Style_Background_Image_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Enter_Element (Visitor, Control);
end if;
end Enter_Element;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Background_Image_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Background_Image_Name;
end Get_Local_Name;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access Style_Background_Image_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.ODF_Visitor'Class then
ODF.DOM.Visitors.ODF_Visitor'Class
(Visitor).Leave_Style_Background_Image
(ODF.DOM.Elements.Style.Background_Image.Internals.Create
(Style_Background_Image_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Leave_Element (Visitor, Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access Style_Background_Image_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.ODF_Iterator'Class then
ODF.DOM.Iterators.ODF_Iterator'Class
(Iterator).Visit_Style_Background_Image
(Visitor,
ODF.DOM.Elements.Style.Background_Image.Internals.Create
(Style_Background_Image_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Visit_Element (Iterator, Visitor, Control);
end if;
end Visit_Element;
end Matreshka.ODF_Elements.Style.Background_Image;
|
charlie5/lace | Ada | 93 | ads | package Chat
--
-- Provides a namespace for the chat family.
--
is
pragma Pure;
end Chat;
|
stcarrez/ada-asf | Ada | 1,518 | ads | -----------------------------------------------------------------------
-- components-utils-flush -- Flush javascript queue and response
-- Copyright (C) 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 ASF.Components.Core;
with ASF.Contexts.Faces;
package ASF.Components.Utils.Flush is
-- ------------------------------
-- UIFlush
-- ------------------------------
-- The <b>UIFlush</b> component is intended to be used to flush the javascript
-- queue at well defined positions in the HTML document.
type UIFlush is new ASF.Components.Core.UILeaf with null record;
-- Flush the javascript queue
overriding
procedure Encode_Begin (UI : in UIFlush;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
end ASF.Components.Utils.Flush;
|
reznikmm/matreshka | Ada | 4,425 | 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$
------------------------------------------------------------------------------
-- Factory for UML Testing Profile module.
------------------------------------------------------------------------------
package AMF.Internals.Factories.Utp_Module_Factory is
type Utp_Module_Factory is
limited new AMF.Internals.Factories.Abstract_Module_Factory
with null record;
------------------------------
-- AMF_Factory's operations --
------------------------------
overriding procedure Connect_Extent
(Self : not null access constant Utp_Module_Factory;
Element : AMF.Internals.AMF_Element;
Extent : AMF.Internals.AMF_Extent);
overriding procedure Connect_Link_End
(Self : not null access constant Utp_Module_Factory;
Element : AMF.Internals.AMF_Element;
Property : AMF.Internals.CMOF_Element;
Link : AMF.Internals.AMF_Link;
Other : AMF.Internals.AMF_Element);
overriding function To_Element
(Self : not null access constant Utp_Module_Factory;
Element : AMF.Internals.AMF_Element) return AMF.Elements.Element_Access;
end AMF.Internals.Factories.Utp_Module_Factory;
|
stcarrez/ada-keystore | Ada | 2,088 | ads | -----------------------------------------------------------------------
-- akt-commands-drivers -- Ada Keystore command driver
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Commands.Drivers;
with Util.Commands.Parsers.GNAT_Parser;
with Util.Commands.Raw_IO;
private package AKT.Commands.Drivers is
package Main_Driver is
new Util.Commands.Drivers (Context_Type => Context_Type,
Config_Parser => Util.Commands.Parsers.GNAT_Parser.Config_Parser,
Translate => Intl.Gettext,
IO => Util.Commands.Raw_IO,
Driver_Name => "akt");
subtype Help_Command_Type is Main_Driver.Help_Command_Type;
subtype Driver_Type is Main_Driver.Driver_Type;
type Command_Type is abstract new Main_Driver.Command_Type with null record;
-- Setup the command before parsing the arguments and executing it.
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type);
-- Write the help associated with the command.
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type);
end AKT.Commands.Drivers;
|
AdaCore/ada-traits-containers | Ada | 2,886 | adb | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Ada.Unchecked_Conversion;
with Interfaces; use Interfaces;
package body Conts with SPARK_Mode is
-------------------
-- Ranged_Random --
-------------------
procedure Ranged_Random
(Self : in out Random.Generator; Result : out Random.Discrete)
is
use Random;
begin
-- These tests are performed statically by the compiler.
-- Special case to avoid division by zero below
if Min = Max then
Result := Min;
elsif Min = Discrete'First
and then Max = Discrete'Last
then
Random.Random (Self, Result => Result);
elsif Discrete'Base'Size > 32 then
declare
-- In the 64-bit case, we have to be careful, since not all 64-bit
-- unsigned values are representable in GNAT's root_integer type.
-- Ignore different-size warnings here since GNAT's handling
-- is correct.
pragma Warnings ("Z");
function Conv_To_Unsigned is
new Ada.Unchecked_Conversion (Discrete'Base, Unsigned_64);
function Conv_To_Result is
new Ada.Unchecked_Conversion (Unsigned_64, Discrete'Base);
pragma Warnings ("z");
N : constant Unsigned_64 :=
Conv_To_Unsigned (Max) - Conv_To_Unsigned (Min) + 1;
Slop : constant Unsigned_64 := Unsigned_64'Last rem N + 1;
X2 : Discrete;
X : Unsigned_64;
begin
loop
Random.Random (Self, Result => X2);
X := Discrete'Pos (X2);
exit when Slop = N or else X <= Unsigned_64'Last - Slop;
end loop;
Result := Conv_To_Result (Conv_To_Unsigned (Min) + X rem N);
end;
else
declare
N : constant Unsigned_32 :=
Unsigned_32 (Discrete'Pos (Max) - Discrete'Pos (Min) + 1);
Slop : constant Unsigned_32 := Unsigned_32'Last rem N + 1;
X : Unsigned_32;
X2 : Discrete;
begin
loop
Random.Random (Self, Result => X2);
X := Discrete'Pos (X2);
exit when Slop = N or else X <= Unsigned_32'Last - Slop;
end loop;
Result := Discrete'Val
(Discrete'Pos (Min) + Unsigned_32'Pos (X rem N));
end;
end if;
end Ranged_Random;
--------------------
-- Default_Random --
--------------------
package body Default_Random is
------------
-- Random --
------------
procedure Random (Gen : in out Generator; Result : out Discrete_Type) is
begin
Result := Ada_Random.Random (Gen);
end Random;
end Default_Random;
end Conts;
|
AdaCore/ada-traits-containers | Ada | 1,300 | ads | --
-- Copyright (C) 2016-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Conts.Properties;
package Conts.Graphs.Components is
generic
with package Graphs is new Conts.Graphs.Traits (<>);
with package Component_Maps is new Conts.Properties.Maps
(Key_Type => Graphs.Vertex, Element_Type => Integer, others => <>);
procedure Strongly_Connected_Components
(G : Graphs.Graph;
Components : out Component_Maps.Map;
Components_Count : out Positive);
-- Compute the strongly components of the graph:
-- These are maximal sets of vertices such that for every pair of
-- vertices u and v in the set, there exists a path from u to v and
-- a path from v to u.
-- Each vertex belongs to one, and only one, such component. This
-- algorithm sets the index of that component in the Components map,
-- and returns the number of components that were found. In the
-- Components, the indexes are in the range 1 .. Components_Count.
--
-- Each vertex that is not part of a vertex forms its own component.
--
-- The implementation uses the Cheriyan-Mehlhorn-Gabow algorithm.
-- Complexity is O( |edges| + |vertices| )
end Conts.Graphs.Components;
|
reznikmm/matreshka | Ada | 3,649 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Db_Columns_Elements is
pragma Preelaborate;
type ODF_Db_Columns is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Db_Columns_Access is
access all ODF_Db_Columns'Class
with Storage_Size => 0;
end ODF.DOM.Db_Columns_Elements;
|
reznikmm/matreshka | Ada | 3,384 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package AWF is
pragma Pure;
end AWF;
|
zhmu/ananas | Ada | 3,227 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 9 3 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 93
package System.Pack_93 is
pragma Preelaborate;
Bits : constant := 93;
type Bits_93 is mod 2 ** Bits;
for Bits_93'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_93
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_93 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_93
(Arr : System.Address;
N : Natural;
E : Bits_93;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_93;
|
zhmu/ananas | Ada | 10,525 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.STRINGS.UTF_ENCODING.STRINGS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010-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. --
-- --
------------------------------------------------------------------------------
package body Ada.Strings.UTF_Encoding.Strings is
use Interfaces;
------------
-- Decode --
------------
-- Decode UTF-8/UTF-16BE/UTF-16LE input to String
function Decode
(Item : UTF_String;
Input_Scheme : Encoding_Scheme) return String
is
begin
if Input_Scheme = UTF_8 then
return Decode (Item);
else
return Decode (To_UTF_16 (Item, Input_Scheme));
end if;
end Decode;
-- Decode UTF-8 input to String
function Decode (Item : UTF_8_String) return String is
Result : String (1 .. Item'Length);
-- Result string (worst case is same length as input)
Len : Natural := 0;
-- Length of result stored so far
Iptr : Natural;
-- Input Item pointer
C : Unsigned_8;
R : Unsigned_16;
procedure Get_Continuation;
-- Reads a continuation byte of the form 10xxxxxx, shifts R left
-- by 6 bits, and or's in the xxxxxx to the low order 6 bits. On
-- return Ptr is incremented. Raises exception if continuation
-- byte does not exist or is invalid.
----------------------
-- Get_Continuation --
----------------------
procedure Get_Continuation is
begin
if Iptr > Item'Last then
Raise_Encoding_Error (Iptr - 1);
else
C := To_Unsigned_8 (Item (Iptr));
Iptr := Iptr + 1;
if C not in 2#10_000000# .. 2#10_111111# then
Raise_Encoding_Error (Iptr - 1);
else
R := Shift_Left (R, 6) or Unsigned_16 (C and 2#00_111111#);
end if;
end if;
end Get_Continuation;
-- Start of processing for Decode
begin
Iptr := Item'First;
-- Skip BOM at start
if Item'Length >= 3
and then Item (Iptr .. Iptr + 2) = BOM_8
then
Iptr := Iptr + 3;
-- Error if bad BOM
elsif Item'Length >= 2
and then (Item (Iptr .. Iptr + 1) = BOM_16BE
or else
Item (Iptr .. Iptr + 1) = BOM_16LE)
then
Raise_Encoding_Error (Iptr);
end if;
while Iptr <= Item'Last loop
C := To_Unsigned_8 (Item (Iptr));
Iptr := Iptr + 1;
-- Codes in the range 16#00# - 16#7F# are represented as
-- 0xxxxxxx
if C <= 16#7F# then
R := Unsigned_16 (C);
-- No initial code can be of the form 10xxxxxx. Such codes are used
-- only for continuations.
elsif C <= 2#10_111111# then
Raise_Encoding_Error (Iptr - 1);
-- Codes in the range 16#80# - 16#7FF# are represented as
-- 110yyyxx 10xxxxxx
elsif C <= 2#110_11111# then
R := Unsigned_16 (C and 2#000_11111#);
Get_Continuation;
-- Codes in the range 16#800# - 16#FFFF# are represented as
-- 1110yyyy 10yyyyxx 10xxxxxx
-- Such codes are out of range for type Character
-- Codes in the range 16#10000# - 16#10FFFF# are represented as
-- 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx
-- Such codes are out of range for Wide_String output
-- Thus all remaining cases raise Encoding_Error
else
Raise_Encoding_Error (Iptr - 1);
end if;
Len := Len + 1;
-- The value may still be out of range of Standard.Character. We make
-- the check explicit because the library is typically compiled with
-- range checks disabled.
if R > Character'Pos (Character'Last) then
Raise_Encoding_Error (Iptr - 1);
end if;
Result (Len) := Character'Val (R);
end loop;
return Result (1 .. Len);
end Decode;
-- Decode UTF-16 input to String
function Decode (Item : UTF_16_Wide_String) return String is
Result : String (1 .. Item'Length);
-- Result is same length as input (possibly minus 1 if BOM present)
Len : Natural := 0;
-- Length of result
Iptr : Natural;
-- Index of next Item element
C : Unsigned_16;
begin
-- Skip UTF-16 BOM at start
Iptr := Item'First;
if Item'Length > 0 and then Item (Iptr) = BOM_16 (1) then
Iptr := Iptr + 1;
end if;
-- Loop through input characters
while Iptr <= Item'Last loop
C := To_Unsigned_16 (Item (Iptr));
Iptr := Iptr + 1;
-- Codes in the range 16#0000#..16#00FF# represent their own value
if C <= 16#00FF# then
Len := Len + 1;
Result (Len) := Character'Val (C);
-- All other codes are invalid, either they are invalid UTF-16
-- encoding sequences, or they represent values that are out of
-- range for type Character.
else
Raise_Encoding_Error (Iptr - 1);
end if;
end loop;
return Result (1 .. Len);
end Decode;
------------
-- Encode --
------------
-- Encode String in UTF-8, UTF-16BE or UTF-16LE
function Encode
(Item : String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) return UTF_String
is
begin
-- Case of UTF_8
if Output_Scheme = UTF_8 then
return Encode (Item, Output_BOM);
-- Case of UTF_16LE or UTF_16BE, use UTF-16 intermediary
else
return From_UTF_16 (UTF_16_Wide_String'(Encode (Item)),
Output_Scheme, Output_BOM);
end if;
end Encode;
-- Encode String in UTF-8
function Encode
(Item : String;
Output_BOM : Boolean := False) return UTF_8_String
is
Result : UTF_8_String (1 .. 3 * Item'Length + 3);
-- Worst case is three bytes per input byte + space for BOM
Len : Natural;
-- Number of output codes stored in Result
C : Unsigned_8;
-- Single input character
procedure Store (C : Unsigned_8);
pragma Inline (Store);
-- Store one output code, C is in the range 0 .. 255
-----------
-- Store --
-----------
procedure Store (C : Unsigned_8) is
begin
Len := Len + 1;
Result (Len) := Character'Val (C);
end Store;
-- Start of processing for UTF8_Encode
begin
-- Output BOM if required
if Output_BOM then
Result (1 .. 3) := BOM_8;
Len := 3;
else
Len := 0;
end if;
-- Loop through characters of input
for J in Item'Range loop
C := To_Unsigned_8 (Item (J));
-- Codes in the range 16#00# - 16#7F# are represented as
-- 0xxxxxxx
if C <= 16#7F# then
Store (C);
-- Codes in the range 16#80# - 16#7FF# are represented as
-- 110yyyxx 10xxxxxx
-- For type character of course, the limit is 16#FF# in any case
else
Store (2#110_00000# or Shift_Right (C, 6));
Store (2#10_000000# or (C and 2#00_111111#));
end if;
end loop;
return Result (1 .. Len);
end Encode;
-- Encode String in UTF-16
function Encode
(Item : String;
Output_BOM : Boolean := False) return UTF_16_Wide_String
is
Result : UTF_16_Wide_String
(1 .. Item'Length + Boolean'Pos (Output_BOM));
-- Output is same length as input + possible BOM
Len : Integer;
-- Length of output string
C : Unsigned_8;
begin
-- Output BOM if required
if Output_BOM then
Result (1) := BOM_16 (1);
Len := 1;
else
Len := 0;
end if;
-- Loop through input characters encoding them
for Iptr in Item'Range loop
C := To_Unsigned_8 (Item (Iptr));
-- Codes in the range 16#0000#..16#00FF# are output unchanged. This
-- includes all possible cases of Character values.
Len := Len + 1;
Result (Len) := Wide_Character'Val (C);
end loop;
return Result;
end Encode;
end Ada.Strings.UTF_Encoding.Strings;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,758 | ads | -- This spec has been automatically generated from STM32F303xE.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
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, 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
-- 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, 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;
-- CRC 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 => System'To_Address (16#40023000#);
end STM32_SVD.CRC;
|
optikos/oasis | Ada | 5,403 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Real_Range_Specifications;
with Program.Elements.Decimal_Fixed_Point_Types;
with Program.Element_Visitors;
package Program.Nodes.Decimal_Fixed_Point_Types is
pragma Preelaborate;
type Decimal_Fixed_Point_Type is
new Program.Nodes.Node
and Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type
and Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type_Text
with private;
function Create
(Delta_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Digits_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access)
return Decimal_Fixed_Point_Type;
type Implicit_Decimal_Fixed_Point_Type is
new Program.Nodes.Node
and Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type
with private;
function Create
(Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Decimal_Fixed_Point_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Decimal_Fixed_Point_Type is
abstract new Program.Nodes.Node
and Program.Elements.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Type
with record
Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Decimal_Fixed_Point_Type'Class);
overriding procedure Visit
(Self : not null access Base_Decimal_Fixed_Point_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Delta_Expression
(Self : Base_Decimal_Fixed_Point_Type)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Digits_Expression
(Self : Base_Decimal_Fixed_Point_Type)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Real_Range
(Self : Base_Decimal_Fixed_Point_Type)
return Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
overriding function Is_Decimal_Fixed_Point_Type_Element
(Self : Base_Decimal_Fixed_Point_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Decimal_Fixed_Point_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Decimal_Fixed_Point_Type)
return Boolean;
type Decimal_Fixed_Point_Type is
new Base_Decimal_Fixed_Point_Type
and Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type_Text
with record
Delta_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Digits_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Decimal_Fixed_Point_Type_Text
(Self : aliased in out Decimal_Fixed_Point_Type)
return Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type_Text_Access;
overriding function Delta_Token
(Self : Decimal_Fixed_Point_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Digits_Token
(Self : Decimal_Fixed_Point_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Decimal_Fixed_Point_Type is
new Base_Decimal_Fixed_Point_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Decimal_Fixed_Point_Type_Text
(Self : aliased in out Implicit_Decimal_Fixed_Point_Type)
return Program.Elements.Decimal_Fixed_Point_Types
.Decimal_Fixed_Point_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Decimal_Fixed_Point_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Decimal_Fixed_Point_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Decimal_Fixed_Point_Type)
return Boolean;
end Program.Nodes.Decimal_Fixed_Point_Types;
|
ohenley/black | Ada | 21,318 | adb | with
Ada.IO_Exceptions,
Ada.Strings.Fixed;
with
System.Storage_Elements;
with
GNAT.SHA1;
with
Black.Parsing,
Black.Text_IO;
package body Black.Response is
function Parse (Item : in String) return Access_Control.HTTP_Method_Set;
procedure Put_Line
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Access_Control.HTTP_Method_Set);
procedure Put_Line
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Access_Controls);
function Bad_Request (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.Bad_Request,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end Bad_Request;
function Content (Response : in Instance) return String is
begin
-- TODO: Ought to raise a constraint error, if the content type
-- isn't text/plain.
return Ada.Strings.Unbounded.To_String (Response.Content);
end Content;
function Content_Type (Response : in Instance) return String is
begin
return Ada.Strings.Unbounded.To_String (Response.Content_Type);
end Content_Type;
function Create (Status : HTTP.Statuses) return Instance is
begin
case Status is
when HTTP.Switching_Protocols =>
return Instance'(Status => HTTP.Switching_Protocols,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Websocket_Accept => <>);
when HTTP.OK =>
return Instance'(Status => HTTP.OK,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.No_Content =>
return Instance'(Status => HTTP.No_Content,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.Moved_Permanently =>
return Instance'(Status => HTTP.Moved_Permanently,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Location => <>);
when HTTP.Moved_Temporarily =>
return Instance'(Status => HTTP.Moved_Temporarily,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Location => <>);
when HTTP.Bad_Request =>
return Instance'(Status => HTTP.Bad_Request,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.Unauthorized =>
return Instance'(Status => HTTP.Unauthorized,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.Forbidden =>
return Instance'(Status => HTTP.Forbidden,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.Not_Found =>
return Instance'(Status => HTTP.Not_Found,
Content_Type => <>,
Content => <>,
Access_Control => <>);
when HTTP.Server_Error =>
return Instance'(Status => HTTP.Server_Error,
Content_Type => <>,
Content => <>,
Access_Control => <>);
end case;
end Create;
function Forbidden (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.Forbidden,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end Forbidden;
function Input_HTTP
(Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Instance is
use Ada.Strings.Unbounded;
use Text_IO;
use type HTTP.Header_Key;
Status : HTTP.Statuses;
Header : Parsing.Header;
Line : Parsing.Header_Line;
Got_Content_Length : Boolean := False;
Content_Length : Natural := 0;
begin
Status := Parsing.Parse (Get_Line (Stream));
Header := Parsing.Get (Stream);
return R : Instance (Status) do
while not Parsing.End_Of_Header (Header) loop
Parsing.Read (Stream => Stream,
From => Header,
Item => Line);
-- Excessive cyclomatic complexity: Refactor!!!
if Line.Key = "Content-Type" then
R.Content_Type := Line.Value;
elsif Line.Key = "Content-Length" then
Got_Content_Length := True;
Content_Length := Line.Value;
elsif Line.Key = "Location" then
R.Location := Line.Value;
elsif Line.Key = "Sec-Websocket-Accept" then
R.Websocket_Accept :=
HTTP.Websocket_Accept_Key (String'(Line.Value));
elsif Line.Key = "Access-Control-Allow-Origin" then
R.Access_Control.Allow_Origin := Line.Value;
elsif Line.Key = "Access-Control-Allow-Credentials" then
R.Access_Control.Allow_Credentials := (Set => True,
Value => Line.Value);
elsif Line.Key = "Access-Control-Allow-Headers" then
R.Access_Control.Allow_Headers := Parse (Line.Value);
elsif Line.Key = "Access-Control-Max-Age" then
R.Access_Control.Max_Age := (Set => True,
Value => Line.Value);
end if;
end loop;
if Got_Content_Length then
declare
subtype Content is String (1 .. Content_Length);
Buffer : Content;
begin
Content'Read (Stream, Buffer);
R.Content := To_Unbounded_String (Buffer);
end;
else
declare
Buffer : Character;
begin
loop
Character'Read (Stream, Buffer);
Append (R.Content, Buffer);
end loop;
exception
when Ada.IO_Exceptions.End_Error =>
null;
end;
end if;
end return;
end Input_HTTP;
function No_Content return Instance is
begin
return Instance'(Status => HTTP.No_Content,
Content_Type => <>,
Content => <>,
Access_Control => <>);
end No_Content;
function Not_Found (Resource : in String) return Instance is
begin
return Not_Found (Data => "The requested resource, '" & Resource &
"' was not found on the server.");
end Not_Found;
function Not_Found (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.Not_Found,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end Not_Found;
function OK (Content_Type : in String;
Data : in Ada.Streams.Stream_Element_Array)
return Instance is
use Ada.Strings.Unbounded;
pragma Assert (Ada.Streams.Stream_Element'Size = Character'Size);
Buffer : String (1 .. Data'Length);
for Buffer'Address use Data'Address;
begin
return Instance'(Status => HTTP.OK,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Buffer),
Access_Control => <>);
end OK;
function OK (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.OK,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end OK;
procedure Output
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Class) is
begin
Output_HTTP (Stream, Item);
end Output;
procedure Output_HTTP
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Instance) is
use Ada.Strings.Unbounded;
use type HTTP.Statuses;
begin
if Length (Item.Content) > 0 and Length (Item.Content_Type) = 0 then
raise Constraint_Error
with "Response object is not ready to be streamed. " &
"No content-type provided for content.";
elsif Item.Status = HTTP.Moved_Permanently and then
Length (Item.Location) = 0
then
raise Constraint_Error
with "Response object is not ready to be streamed. " &
"No location provided for redirection.";
elsif Item.Status = HTTP.Moved_Temporarily and then
Length (Item.Location) = 0
then
raise Constraint_Error
with "Response object is not ready to be streamed. " &
"No location provided for redirection.";
else
declare
use Text_IO;
begin
Put_Line (Stream, HTTP.Status_Line (Item.Status));
Put (Stream, "Content-Length: ");
Put_Line (Stream, Length (Item.Content));
if Length (Item.Content) > 0 then
Put (Stream, "Content-Type: ");
Put_Line (Stream, Item.Content_Type);
end if;
case Item.Status is
when HTTP.Switching_Protocols =>
Put_Line (Stream, "Upgrade: websocket");
Put_Line (Stream, "Connection: Upgrade");
Put (Stream, "Sec-WebSocket-Accept: ");
Put_Line (Stream, String (Item.Websocket_Accept));
when HTTP.Moved_Permanently | HTTP.Moved_Temporarily =>
Put (Stream, "Location: ");
Put_Line (Stream, Item.Location);
when others =>
null;
end case;
Put_Line (Stream, Item.Access_Control);
New_Line (Stream);
Put (Stream, Item.Content);
end;
end if;
end Output_HTTP;
function Parse (Item : in String) return Access_Control.HTTP_Method_Set is
use Ada.Strings, Ada.Strings.Fixed;
From : Integer;
To : Natural := Item'First - 1;
begin
return Result : Access_Control.HTTP_Method_Set := (others => False) do
loop
From := To + 1;
exit when not (From in Item'Range);
To := Index (Item (From .. Item'Last), ",");
if To = 0 then
To := Item'Last + 1;
end if;
declare
Name : String renames Trim (Item (From .. To - 1), Both);
Method : HTTP.Methods renames HTTP.Methods'Value (Name);
begin
Result (Method) := True;
end;
end loop;
end return;
exception
when others =>
raise Protocol_Error
with "Could not parse Access-Control-Allow-Methods value.";
end Parse;
procedure Put_Line
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Access_Control.HTTP_Method_Set) is
First : Boolean := True;
begin
for Method in Item'Range loop
if Item (Method) then
if not First then
Text_IO.Put (Target => Stream,
Item => ", ");
end if;
Text_IO.Put (Target => Stream,
Item => HTTP.Methods'Image (Method));
First := False;
end if;
end loop;
Text_IO.New_Line (Target => Stream);
end Put_Line;
procedure Put_Line
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Access_Controls) is
use Ada.Strings.Unbounded;
use Text_IO;
No_Headers : constant Access_Control.HTTP_Method_Set :=
(others => False);
use type Access_Control.HTTP_Method_Set;
begin
if Length (Item.Allow_Origin) > 0 then
Put (Stream, "Access-Control-Allow-Origin: ");
Put_Line (Stream, Item.Allow_Origin);
end if;
if Item.Allow_Credentials.Set then
Put (Stream, "Access-Control-Allow-Credentials: ");
Put_Line (Stream, Item.Allow_Credentials.Value);
end if;
if Item.Allow_Headers /= No_Headers then
Put (Stream, "Access-Control-Allow-Headers: ");
Put_Line (Stream, Item.Allow_Headers);
end if;
if Item.Max_Age.Set then
Put (Stream, "Access-Control-Max-Age: ");
Put_Line (Stream, Item.Max_Age.Value);
end if;
end Put_Line;
function Redirect (Target : in String;
Permanent : in Boolean)
return Instance is
use Ada.Strings.Unbounded;
begin
if Permanent then
return Instance'(Status => HTTP.Moved_Permanently,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Location => To_Unbounded_String (Target));
else
return Instance'(Status => HTTP.Moved_Temporarily,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Location => To_Unbounded_String (Target));
end if;
end Redirect;
function Server_Error (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.Server_Error,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end Server_Error;
function Status (Response : in Instance) return HTTP.Statuses is
begin
return Response.Status;
end Status;
function Switch_To_Websocket (Key : in String) return Instance is
function Accept_Key return HTTP.Websocket_Accept_Key;
function To_Storage_Elements
(Hex : in String)
return System.Storage_Elements.Storage_Array;
function Base64 (Octets : in System.Storage_Elements.Storage_Array)
return String;
function Accept_Key return HTTP.Websocket_Accept_Key is
use GNAT.SHA1;
Hash : Context := Initial_Context;
begin
Update (Hash, Key);
Update (Hash, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
return HTTP.Websocket_Accept_Key
(Base64 (To_Storage_Elements (Digest (Hash))));
end Accept_Key;
function Base64 (Octets : in System.Storage_Elements.Storage_Array)
return String is
use System.Storage_Elements;
subtype Sextet is Storage_Element range 0 .. 2 ** 6 - 1;
Alphabet : constant array (Sextet) of Character :=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
"abcdefghijklmnopqrstuvwxyz" &
"0123456789+/";
O_Pos : Storage_Offset := Octets'First;
Result : String (1 .. (Octets'Length + 2) / 3 * 4) := (others => '_');
R_Pos : Positive := Result'First;
begin
while O_Pos in Octets'Range loop
declare
A, B, C, D : Sextet;
begin
First_Byte :
declare
First : Storage_Element renames Octets (O_Pos);
begin
A := (First and 2#1111_1100#) / 2 ** 2;
B := (First and 2#0000_0011#) * 2 ** 4;
if O_Pos = Octets'Last then
Result (R_Pos .. R_Pos + 3) :=
Alphabet (A) & Alphabet (B) & "==";
return Result;
end if;
end First_Byte;
Second_Byte :
declare
Second : Storage_Element renames Octets (O_Pos + 1);
begin
B := B or (Second and 2#1111_0000#) / 2 ** 4;
C := (Second and 2#0000_1111#) * 2 ** 2;
if O_Pos + 1 = Octets'Last then
Result (R_Pos .. R_Pos + 3) :=
Alphabet (A) & Alphabet (B) & Alphabet (C) & "=";
return Result;
end if;
end Second_Byte;
Third_Byte :
declare
Third : Storage_Element renames Octets (O_Pos + 2);
begin
C := C or (Third and 2#1100_0000#) / 2 ** 6;
D := (Third and 2#0011_1111#);
end Third_Byte;
Result (R_Pos .. R_Pos + 3) :=
Alphabet (A) & Alphabet (B) & Alphabet (C) & Alphabet (D);
O_Pos := O_Pos + 3;
R_Pos := R_Pos + 4;
end;
end loop;
return Result;
end Base64;
function To_Storage_Elements
(Hex : in String)
return System.Storage_Elements.Storage_Array is
use System.Storage_Elements;
begin
pragma Assert (Hex'Length mod 2 = 0, "We only process octets.");
return Octets : Storage_Array (0 .. Hex'Length / 2 - 1) do
for Index in Octets'Range loop
declare
Hex_Offset : constant Positive :=
Hex'First + Positive'Base (2 * Index);
begin
Octets (Index) :=
Storage_Element'Value
("16#" & Hex (Hex_Offset .. Hex_Offset + 1) & "#");
end;
end loop;
end return;
end To_Storage_Elements;
--use Text_IO;
begin
return Instance'(Status => HTTP.Switching_Protocols,
Content_Type => <>,
Content => <>,
Access_Control => <>,
Websocket_Accept => Accept_Key);
end Switch_To_Websocket;
function Unauthorized (Content_Type : in String := MIME_Types.Text.Plain;
Data : in String) return Instance is
use Ada.Strings.Unbounded;
begin
return Instance'(Status => HTTP.Unauthorized,
Content_Type => To_Unbounded_String (Content_Type),
Content => To_Unbounded_String (Data),
Access_Control => <>);
end Unauthorized;
package body Access_Control is
procedure Allow_Credentials (Item : in out Class) is
begin
Item.Access_Control.Allow_Credentials := (Set => True,
Value => True);
end Allow_Credentials;
procedure Allow_Headers (Item : in out Class;
Headers : in HTTP_Method_Set) is
begin
Item.Access_Control.Allow_Headers := Headers;
end Allow_Headers;
procedure Allow_Origin (Item : in out Class;
Pattern : in String) is
use Ada.Strings.Unbounded;
begin
Item.Access_Control.Allow_Origin := To_Unbounded_String (Pattern);
end Allow_Origin;
procedure Max_Age (Item : in out Class;
Age : in Duration) is
begin
Item.Access_Control.Max_Age := (Set => True,
Value => Age);
end Max_Age;
end Access_Control;
end Black.Response;
|
micahwelf/FLTK-Ada | Ada | 3,375 | adb |
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Widgets.Buttons.Light.Radio is
procedure radio_light_button_set_draw_hook
(W, D : in System.Address);
pragma Import (C, radio_light_button_set_draw_hook, "radio_light_button_set_draw_hook");
pragma Inline (radio_light_button_set_draw_hook);
procedure radio_light_button_set_handle_hook
(W, H : in System.Address);
pragma Import (C, radio_light_button_set_handle_hook, "radio_light_button_set_handle_hook");
pragma Inline (radio_light_button_set_handle_hook);
function new_fl_radio_light_button
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_radio_light_button, "new_fl_radio_light_button");
pragma Inline (new_fl_radio_light_button);
procedure free_fl_radio_light_button
(B : in System.Address);
pragma Import (C, free_fl_radio_light_button, "free_fl_radio_light_button");
pragma Inline (free_fl_radio_light_button);
procedure fl_radio_light_button_draw
(W : in System.Address);
pragma Import (C, fl_radio_light_button_draw, "fl_radio_light_button_draw");
pragma Inline (fl_radio_light_button_draw);
function fl_radio_light_button_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_radio_light_button_handle, "fl_radio_light_button_handle");
pragma Inline (fl_radio_light_button_handle);
procedure Finalize
(This : in out Radio_Light_Button) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Radio_Light_Button'Class
then
free_fl_radio_light_button (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Light_Button (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Radio_Light_Button is
begin
return This : Radio_Light_Button do
This.Void_Ptr := new_fl_radio_light_button
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
radio_light_button_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
radio_light_button_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Draw
(This : in out Radio_Light_Button) is
begin
fl_radio_light_button_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Radio_Light_Button;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_radio_light_button_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Buttons.Light.Radio;
|
reznikmm/matreshka | Ada | 4,129 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Relative_Tab_Stop_Position_Attributes;
package Matreshka.ODF_Text.Relative_Tab_Stop_Position_Attributes is
type Text_Relative_Tab_Stop_Position_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Relative_Tab_Stop_Position_Attributes.ODF_Text_Relative_Tab_Stop_Position_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Relative_Tab_Stop_Position_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Relative_Tab_Stop_Position_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Relative_Tab_Stop_Position_Attributes;
|
alexcamposruiz/dds-requestreply | Ada | 13,961 | adb | package body DDS.Request_Reply.connext_c_requestreply_treqtrepsimplereplier is
-- /* $Id$
--
-- (c) Copyright, Real-Time Innovations, 2012-2016.
-- All rights reserved.
-- No duplications, whole or partial, manual or electronic, may be made
-- without express written permission. Any such copies, or
-- revisions thereof, must display this notice unaltered.
-- This code contains trade secrets of Real-Time Innovations, Inc.
--
-- modification history
-- ---------------------
-- 5.20,20aug14,acr Moved out function that previously was inside macro and
-- duplicated a symbol when declaring more than
-- one SimpleReplier for different types (REQREPLY-18)
-- 1.0a,2mar12,jch Created.
-- ============================================================================ */
--
-- #include "log/log_makeheader.h"
--
-- /*#include <stdlib.h>*/
--
-- #ifndef log_common_h
-- #include "log/log_common.h"
-- #endif
--
-- #ifndef connext_c_replier_h
-- #include "connext_c/connext_c_replier.h"
-- #endif
--
-- #include "connext_c/connext_c_simple_replier.h"
--
-- #ifndef connext_c_replier_impl_h
-- #include "connext_c/connext_c_replier_impl.h"
-- #endif
--
-- #include "dds_c/dds_c_log_impl.h"
--
-- #include "connext_c/connext_c_untyped_impl.h"
--
-- /* TODO: add RTI_Connext_SimpleReplier type here
-- * Type will contain TReqTRepReplier in it */
-- /* TODO: consider abstracting out common TypeSupport defines to common.gen file & include it */
--
-- #define DDS_CURRENT_SUBMODULE DDS_SUBMODULE_MASK_DATA
--
-- #if defined(TReq) && defined(TRep)
--
-- #define TReqTRep_SimpleName_c(TReq, TRep) concatenate(TReq, TRep)
-- #define TReqTRep_SimpleName TReqTRep_SimpleName_c(TReq, TRep)
--
-- #ifdef TSimpleReplier
-- #define TReqTRepSimpleReplier_name_c(SimpleReplier_name) SimpleReplier_name
-- #define TReqTRepSimpleReplier_name TReqTRepSimpleReplier_name_c(TSimpleReplier)
-- #define TReqTRepSimpleReplier TReqTRepSimpleReplier_name_c(TSimpleReplier)
-- #else
-- #define TReqTRepSimpleReplier_name_c(TReqTRep_SimpleName) concatenate(TReqTRep_SimpleName, SimpleReplier)
-- #define TReqTRepSimpleReplier_name TReqTRepSimpleReplier_name_c(TReqTRep_SimpleName)
-- #define TReqTRepSimpleReplier TReqTRepSimpleReplier_name_c(TReqTRep_name)
-- #endif
--
-- #define TReqTypeSupport_c(TReq) concatenate(TReq, TypeSupport)
-- #define TReqTypeSupport TReqTypeSupport_c(TReq)
--
-- #define TRepTypeSupport_c(TRep) concatenate(TRep, TypeSupport)
-- #define TRepTypeSupport TRepTypeSupport_c(TRep)
--
-- #define TRepTypeSupport_copy_data_c(TRepTypeSupport) concatenate(TRepTypeSupport, _copy_data)
-- #define TRepTypeSupport_copy_data TRepTypeSupport_copy_data_c(TRepTypeSupport)
--
-- #define TReqTypeSupport_register_type_c(TReqTypeSupport) concatenate(TReqTypeSupport, _register_type)
-- #define TReqTypeSupport_register_type TReqTypeSupport_register_type_c(TReqTypeSupport)
--
-- #define TReqTypeSupport_get_type_name_c(TReqTypeSupport) concatenate(TReqTypeSupport, _get_type_name)
-- #define TReqTypeSupport_get_type_name TReqTypeSupport_get_type_name_c(TReqTypeSupport)
--
-- #define TRepTypeSupport_register_type_c(TRepTypeSupport) concatenate(TRepTypeSupport, _register_type)
-- #define TRepTypeSupport_register_type TRepTypeSupport_register_type_c(TRepTypeSupport)
--
-- #define TRepTypeSupport_get_type_name_c(TRepTypeSupport) concatenate(TRepTypeSupport, _get_type_name)
-- #define TRepTypeSupport_get_type_name TRepTypeSupport_get_type_name_c(TRepTypeSupport)
--
-- #define TReqTRepSimpleReplier_on_data_available_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _on_data_available)
-- #define TReqTRepSimpleReplier_on_data_available TReqTRepSimpleReplier_on_data_available_c(TReqTRepSimpleReplier_name)
--
-- #define TReqDataReader_c(TReq) concatenate(TReq, DataReader)
-- #define TReqDataReader TReqDataReader_c(TReq)
--
-- #define TRepDataWriter_c(TRep) concatenate(TRep, DataWriter)
-- #define TRepDataWriter TRepDataWriter_c(TRep)
--
-- #define TReqSeq_c(TReq) concatenate(TReq, Seq)
-- #define TReqSeq TReqSeq_c(TReq)
--
-- #define TReqDataReader_narrow_c(TReqDataReader) concatenate(TReqDataReader, _narrow)
-- #define TReqDataReader_narrow TReqDataReader_narrow_c(TReqDataReader)
--
-- #define TRepDataWriter_narrow_c(TRepDataWriter) concatenate(TRepDataWriter, _narrow)
-- #define TRepDataWriter_narrow TRepDataWriter_narrow_c(TRepDataWriter)
--
-- #define TReqDataReader_take_c(TReqDataReader) concatenate(TReqDataReader, _take)
-- #define TReqDataReader_take TReqDataReader_take_c(TReqDataReader)
--
-- #define TReqSeq_get_length_c(TReqSeq) concatenate(TReqSeq, _get_length)
-- #define TReqSeq_get_length TReqSeq_get_length_c(TReqSeq)
--
-- #define TReqSeq_get_reference_c(TReqSeq) concatenate(TReqSeq, _get_reference)
-- #define TReqSeq_get_reference TReqSeq_get_reference_c(TReqSeq)
--
-- #define TRepDataWriter_write_w_params_c(TRepDataWriter) concatenate(TRepDataWriter, _write_w_params)
-- #define TRepDataWriter_write_w_params TRepDataWriter_write_w_params_c(TRepDataWriter)
--
-- #define TReqDataReader_return_loan_c(TReqDataReader) concatenate(TReqDataReader, _return_loan)
-- #define TReqDataReader_return_loan TReqDataReader_return_loan_c(TReqDataReader)
--
-- #define TReqTRepSimpleReplier_create_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _create)
-- #define TReqTRepSimpleReplier_create TReqTRepSimpleReplier_create_c(TReqTRepSimpleReplier_name)
--
-- #define TReqTRepSimpleReplier_create_w_params_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _create_w_params)
-- #define TReqTRepSimpleReplier_create_w_params TReqTRepSimpleReplier_create_w_params_c(TReqTRepSimpleReplier_name)
--
-- #define TReqTRepSimpleReplier_delete_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _delete)
-- #define TReqTRepSimpleReplier_delete TReqTRepSimpleReplier_delete_c(TReqTRepSimpleReplier_name)
--
-- #define TReqTRepSimpleReplier_get_request_datareader_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _get_request_datareader)
-- #define TReqTRepSimpleReplier_get_request_datareader TReqTRepSimpleReplier_get_request_datareader_c(TReqTRepSimpleReplier_name)
--
-- #define TReqTRepSimpleReplier_get_reply_datawriter_c(TReqTRepSimpleReplier_name) concatenate(TReqTRepSimpleReplier_name, _get_reply_datawriter)
-- #define TReqTRepSimpleReplier_get_reply_datawriter TReqTRepSimpleReplier_get_reply_datawriter_c(TReqTRepSimpleReplier_name)
--
-- void TReqTRepSimpleReplier_on_data_available(
-- void* listener_data, DDS_DataReader* reader)
-- {
-- struct TReqSeq typed_seq = DDS_SEQUENCE_INITIALIZER;
-- struct DDS_SampleInfoSeq info_seq = DDS_SEQUENCE_INITIALIZER;
-- DDS_ReturnCode_t retcode = DDS_RETCODE_OK;
-- int i = 0;
-- TReqTRepSimpleReplier* self = (TReqTRepSimpleReplier*) listener_data;
--
-- retcode = TReqTRepReplier_take_requests(
-- (TReqTRepReplier *) self,
-- &typed_seq, &info_seq,
-- DDS_LENGTH_UNLIMITED);
--
-- if (retcode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_GET_FAILURE_s,
-- "requests from Replier");
-- return;
-- }
--
-- for (i = 0; i < TReqSeq_get_length(&typed_seq); ++i) {
-- struct DDS_SampleIdentity_t id = DDS_UNKNOWN_SAMPLE_IDENTITY;
--
-- TReq* sample = TReqSeq_get_reference(&typed_seq, i);
-- struct DDS_SampleInfo* info =
-- DDS_SampleInfoSeq_get_reference(&info_seq, i);
--
-- TRep* reply = (TRep*)self->parent.simpleListener.on_request_available(
-- &self->parent.simpleListener, (void *) sample, info);
--
-- if (reply == NULL) {
-- continue;
-- }
--
-- DDS_GUID_copy(&id.writer_guid,
-- &info->original_publication_virtual_guid);
-- id.sequence_number = info->original_publication_virtual_sequence_number;
--
-- retcode = TReqTRepReplier_send_reply(
-- (TReqTRepReplier *) self, reply, &id);
-- if (retcode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "write reply");
-- }
--
-- self->parent.simpleListener.return_loan(
-- &self->parent.simpleListener, (void*)reply);
-- }
--
-- retcode = TReqTRepReplier_return_loan(
-- (TReqTRepReplier *) self, &typed_seq, &info_seq);
--
-- if (retcode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "return loan to Replier");
-- }
-- }
--
-- /* TODO: move out of macro */
-- DDS_ReturnCode_t TReqTRepSimpleReplier_delete(TReqTRepSimpleReplier * self)
-- {
-- DDS_ReturnCode_t retcode = DDS_RETCODE_OK;
--
-- /* TODO: error on precondition */
-- if(self != NULL) {
-- if(self->parent._impl != NULL) {
-- RTI_Connext_EntityUntypedImpl_delete(self->parent._impl);
-- }
-- RTIOsapiHeap_free(self);
-- }
--
-- return retcode;
-- }
--
-- TReqTRepSimpleReplier* TReqTRepSimpleReplier_create(
-- DDS_DomainParticipant * participant,
-- char * service_name,
-- RTI_Connext_SimpleReplierListener * listener)
-- {
-- TReqTRepSimpleReplier* replier = NULL;
--
-- RTI_Connext_SimpleReplierParams params =
-- RTI_Connext_SimpleReplierParams_INITIALIZER;
--
-- params.participant = participant;
-- params.service_name = (char *) service_name;
-- params.simple_listener = listener;
--
-- replier = TReqTRepSimpleReplier_create_w_params(¶ms);
-- if(replier == NULL) {
-- DDSLog_exception(&RTI_LOG_CREATION_FAILURE_s,
-- "SimpleReplier with params");
-- return NULL;
-- }
--
-- return replier;
-- }
--
-- TReqTRepSimpleReplier* TReqTRepSimpleReplier_create_w_params(
-- RTI_Connext_SimpleReplierParams* params)
-- {
-- TReqTRepSimpleReplier * replier = NULL;
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
-- struct DDS_DataReaderListener reader_listener =
-- DDS_DataReaderListener_INITIALIZER;
-- RTI_Connext_EntityParams entity_params;
--
-- if(params == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "params");
-- return NULL;
-- }
--
-- if (params->simple_listener == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "listener is required");
-- return NULL;
-- }
--
-- RTIOsapiHeap_allocateStructure(&replier, TReqTRepSimpleReplier);
-- if(replier == NULL) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "error creating a TReqTRepRequester");
-- replier = NULL;
-- goto finish;
-- }
--
-- replier->parent._impl = NULL;
-- replier->parent.simpleListener = *params->simple_listener;
--
-- replier->parent._impl = RTI_Connext_ReplierUntypedImpl_create();
-- if(replier->parent._impl == NULL) {
-- DDSLog_exception(&RTI_LOG_CREATION_FAILURE_s,
-- "ReplierUntypedImpl");
-- goto finish;
-- }
--
-- reader_listener.on_data_available = TReqTRepSimpleReplier_on_data_available;
-- reader_listener.as_listener.listener_data = replier;
--
-- RTI_Connext_SimpleReplierParams_to_entityparams(params, &entity_params);
-- retCode = RTI_Connext_ReplierUntypedImpl_initialize(
-- replier->parent._impl,
-- &entity_params,
-- &TReqTypeSupport_register_type,
-- TReqTypeSupport_get_type_name(),
-- &TRepTypeSupport_register_type,
-- TRepTypeSupport_get_type_name(),
-- sizeof(TReq),
-- &reader_listener);
--
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "initialize ReplierUntypedImpl");
-- goto finish;
-- }
--
-- return replier;
--
-- finish:
-- if(replier != NULL) {
-- TReqTRepSimpleReplier_delete(replier);
-- }
-- return NULL;
-- }
--
-- TReqDataReader* TReqTRepSimpleReplier_get_request_datareader(
-- TReqTRepSimpleReplier* self)
-- {
-- return TReqTRepReplier_get_request_datareader((TReqTRepReplier* )self);
-- }
--
-- TRepDataWriter* TReqTRepSimpleReplier_get_reply_datawriter(
-- TReqTRepSimpleReplier* self)
-- {
-- return TReqTRepReplier_get_reply_datawriter((TReqTRepReplier* )self);
-- }
--
-- #endif
-- /* ----------------------------------------------------------------- */
-- /* End of $Id$ */
end DDS.Request_Reply.connext_c_requestreply_treqtrepsimplereplier;
|
onox/orka | Ada | 15,081 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Characters.Latin_1;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;
with Ada.Unchecked_Conversion;
with GL.Pixels.Extensions;
package body Orka.KTX is
use Ada.Streams;
type Four_Bytes_Array is array (Positive range 1 .. 4) of Stream_Element
with Size => 32, Pack;
function Convert_Size is new Ada.Unchecked_Conversion
(Source => Four_Bytes_Array, Target => Unsigned_32);
type Header_Array is array (Positive range 1 .. 13 * 4) of Stream_Element
with Size => 32 * 13, Pack;
type Internal_Header is record
Endianness : Unsigned_32;
Data_Type : Unsigned_32;
Type_Size : Unsigned_32;
Format : Unsigned_32;
Internal_Format : Unsigned_32;
Base_Internal_Format : Unsigned_32;
Width : Unsigned_32;
Height : Unsigned_32;
Depth : Unsigned_32;
Array_Elements : Unsigned_32;
Faces : Unsigned_32;
Mipmap_Levels : Unsigned_32;
Bytes_Key_Value_Data : Unsigned_32;
end record
with Size => 32 * 13, Pack;
Identifier : constant Resources.Byte_Array
:= (16#AB#, 16#4B#, 16#54#, 16#58#, 16#20#, 16#31#,
16#31#, 16#BB#, 16#0D#, 16#0A#, 16#1A#, 16#0A#);
Endianness_Reference : constant := 16#04030201#;
function Valid_Identifier (Bytes : Bytes_Reference) return Boolean is
(Identifier = Bytes (Bytes.Value'First .. Bytes.Value'First + Identifier'Length - 1));
function Get_Header (Bytes : Bytes_Reference) return Header is
function Convert is new Ada.Unchecked_Conversion
(Source => Header_Array, Target => Internal_Header);
function Convert_To_Data_Type is new Ada.Unchecked_Conversion
(Source => Unsigned_32, Target => GL.Pixels.Data_Type);
function Convert_To_Format is new Ada.Unchecked_Conversion
(Source => Unsigned_32, Target => GL.Pixels.Format);
function Convert_To_Internal_Format is new Ada.Unchecked_Conversion
(Source => Unsigned_32, Target => GL.Pixels.Internal_Format);
function Convert_To_Compressed_Format is new Ada.Unchecked_Conversion
(Source => Unsigned_32, Target => GL.Pixels.Compressed_Format);
Offset : constant Stream_Element_Offset := Bytes.Value'First + Identifier'Length;
File_Header : constant Internal_Header := Convert (Header_Array
(Bytes (Offset .. Offset + Header_Array'Length - 1)));
Compressed : constant Boolean := File_Header.Data_Type = 0;
begin
pragma Assert (File_Header.Endianness = Endianness_Reference);
-- Endianness conversion is not supported in the code
if Compressed then
pragma Assert (File_Header.Type_Size in 0 | 1);
-- Compressed textures should have a Type_Size = 1, but some files
-- set this to 0
else
pragma Assert (File_Header.Type_Size in 1 | 2 | 4);
end if;
return Result : Header (Compressed) do
pragma Assert (File_Header.Width > 0);
if File_Header.Depth > 0 then
pragma Assert (File_Header.Height > 0);
end if;
-- Set dimensions of a single texture
Result.Width := Size (File_Header.Width);
Result.Height := Size (File_Header.Height);
Result.Depth := Size (File_Header.Depth);
-- Set texture kind based on faces, array elements, and dimensions
if File_Header.Faces = 6 then
pragma Assert (File_Header.Width = File_Header.Height);
pragma Assert (File_Header.Depth = 0);
if File_Header.Array_Elements > 0 then
Result.Kind := Texture_Cube_Map_Array;
else
Result.Kind := Texture_Cube_Map;
end if;
else
if File_Header.Array_Elements > 0 then
if File_Header.Depth > 0 then
raise Constraint_Error with "OpenGL does not support 3D texture arrays";
elsif File_Header.Height > 0 then
Result.Kind := Texture_2D_Array;
else
Result.Kind := Texture_1D_Array;
end if;
else
if File_Header.Depth > 0 then
Result.Kind := Texture_3D;
elsif File_Header.Height > 0 then
Result.Kind := Texture_2D;
else
Result.Kind := Texture_1D;
end if;
end if;
end if;
Result.Array_Elements := Size (File_Header.Array_Elements);
Result.Mipmap_Levels := Size (File_Header.Mipmap_Levels);
-- If mipmap levels is 0, then client should generate full
-- mipmap pyramid
Result.Bytes_Key_Value := Size (File_Header.Bytes_Key_Value_Data);
if Compressed then
pragma Assert (File_Header.Format = 0);
pragma Assert (File_Header.Type_Size in 0 | 1);
pragma Assert (File_Header.Mipmap_Levels > 0);
-- Format / Internal format
begin
Result.Compressed_Format
:= Convert_To_Compressed_Format (File_Header.Internal_Format);
exception
when Constraint_Error =>
raise Invalid_Enum_Error with
"invalid internal format (" & File_Header.Internal_Format'Image & ")";
end;
else
-- Data type
begin
Result.Data_Type := Convert_To_Data_Type (File_Header.Data_Type);
exception
when Constraint_Error =>
raise Invalid_Enum_Error with
"invalid data type (" & File_Header.Data_Type'Image & ")";
end;
-- Format
begin
Result.Format := Convert_To_Format (File_Header.Format);
exception
when Constraint_Error =>
raise Invalid_Enum_Error with
"invalid format (" & File_Header.Format'Image & ")";
end;
-- Internal format
begin
Result.Internal_Format
:= Convert_To_Internal_Format (File_Header.Internal_Format);
exception
when Constraint_Error =>
raise Invalid_Enum_Error with
"invalid internal format (" & File_Header.Internal_Format'Image & ")";
end;
end if;
end return;
end Get_Header;
function Get_Key_Value_Map
(Bytes : Bytes_Reference;
Length : Size) return KTX.String_Maps.Map
is
Result : KTX.String_Maps.Map;
Non_Header_Index : constant Stream_Element_Offset := Get_Data_Offset (Bytes, 0);
Data_Index : constant Stream_Element_Offset
:= Non_Header_Index + Stream_Element_Offset (Length);
pragma Assert (Data_Index <= Bytes.Value'Last);
Bytes_Remaining : Natural := Natural (Length);
Pair_Index : Stream_Element_Offset := Non_Header_Index;
begin
while Bytes_Remaining > 0 loop
declare
Key_Value_Size : constant Natural := Get_Length (Bytes, Pair_Index);
Padding_Size : constant Natural := 3 - ((Key_Value_Size + 3) mod 4);
Pair_Size : constant Natural := 4 + Key_Value_Size + Padding_Size;
pragma Assert (Pair_Size <= Bytes_Remaining);
type Key_Value_Array is array (Positive range 1 .. Key_Value_Size) of Stream_Element
with Pack;
type Character_Array is array (Positive range 1 .. Key_Value_Size) of Character
with Pack;
function Convert_Pair is new Ada.Unchecked_Conversion
(Source => Key_Value_Array, Target => Character_Array);
Key_Value_Pair : constant Key_Value_Array := Key_Value_Array (Bytes
(Pair_Index + 4 .. Pair_Index + 4 + Stream_Element_Offset (Key_Value_Size) - 1));
Key_Value : constant String := String (Convert_Pair (Key_Value_Pair));
Position_NUL : constant Natural := Ada.Strings.Fixed.Index
(Key_Value, Ada.Strings.Maps.To_Set (Ada.Characters.Latin_1.NUL));
pragma Assert (Position_NUL > 0);
begin
-- Extract key and value here
declare
Key : constant String := Key_Value (1 .. Position_NUL - 1);
Value : constant String := Key_Value (Position_NUL + 1 .. Key_Value'Last);
begin
Result.Insert (Key, Value);
end;
Bytes_Remaining := Bytes_Remaining - Pair_Size;
Pair_Index := Pair_Index + Stream_Element_Offset (Pair_Size);
end;
end loop;
pragma Assert (Pair_Index = Data_Index);
return Result;
end Get_Key_Value_Map;
function Get_Length
(Bytes : Bytes_Reference;
Offset : Stream_Element_Offset) return Natural
is
Size_Bytes : constant Four_Bytes_Array := Four_Bytes_Array
(Bytes (Offset .. Offset + 4 - 1));
begin
return Natural (Convert_Size (Size_Bytes));
end Get_Length;
function Get_Data_Offset
(Bytes : Bytes_Reference;
Bytes_Key_Value : Size) return Stream_Element_Offset
is (Bytes.Value'First + Identifier'Length + Header_Array'Length
+ Stream_Element_Offset (Bytes_Key_Value));
function Create_KTX_Bytes
(KTX_Header : Header;
Get_Data : not null access function (Level : GL.Objects.Textures.Mipmap_Level)
return Resources.Byte_Array_Pointers.Pointer)
return Resources.Byte_Array_Pointers.Pointer
is
function Convert is new Ada.Unchecked_Conversion
(Source => Internal_Header, Target => Header_Array);
function Convert is new Ada.Unchecked_Conversion
(Source => Unsigned_32, Target => Four_Bytes_Array);
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Pixels.Data_Type, Target => Unsigned_32);
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Pixels.Format, Target => Unsigned_32);
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Pixels.Internal_Format, Target => Unsigned_32);
function Convert is new Ada.Unchecked_Conversion
(Source => GL.Pixels.Compressed_Format, Target => Unsigned_32);
package PE renames GL.Pixels.Extensions;
Compressed : Boolean renames KTX_Header.Compressed;
Type_Size : constant Size
:= (if Compressed then 1 else PE.Bytes (KTX_Header.Data_Type));
Faces : constant Unsigned_32
:= (if KTX_Header.Kind in Texture_Cube_Map | Texture_Cube_Map_Array then 6 else 1);
File_Header : constant Internal_Header
:= (Endianness => Endianness_Reference,
Data_Type => (if Compressed then 0 else Convert (KTX_Header.Data_Type)),
Type_Size => Unsigned_32 (if Compressed then 1 else Type_Size),
Format => (if Compressed then 0 else Convert (KTX_Header.Format)),
Internal_Format =>
(if Compressed then
Convert (KTX_Header.Compressed_Format)
else
Convert (KTX_Header.Internal_Format)),
Base_Internal_Format =>
(if Compressed then
Convert (KTX_Header.Compressed_Format)
else
Convert (KTX_Header.Format)),
Width => Unsigned_32 (KTX_Header.Width),
Height => Unsigned_32 (KTX_Header.Height),
Depth => Unsigned_32 (if Faces = 6 then 0 else KTX_Header.Depth),
Array_Elements => Unsigned_32 (KTX_Header.Array_Elements),
Faces => Faces,
Mipmap_Levels => Unsigned_32 (KTX_Header.Mipmap_Levels),
Bytes_Key_Value_Data => 0);
-- TODO Support key value map?
Pointer : Resources.Byte_Array_Pointers.Pointer;
--------------------------------------------------------------------------
Data : array (0 .. KTX_Header.Mipmap_Levels - 1) of Resources.Byte_Array_Pointers.Pointer;
Total_Size : Stream_Element_Offset := 0;
begin
for Level in Data'Range loop
Data (Level) := Get_Data (Level);
Total_Size := Total_Size + Data (Level).Get.Value'Length;
end loop;
Total_Size := Total_Size + 4 * Data'Length;
pragma Assert (if not Compressed then
(for all Pointer of Data => Pointer.Get.Value'Length mod 4 = 0));
-- Data must be a multiple of 4 bytes because of the requirement
-- of GL.Pixels.Unpack_Alignment = Words (= 4)
-- Note: assertion is not precise because length of a row might
-- not be a multiple of 4 bytes
-- Note: Cube padding and mipmap padding can be assumed to be 0
declare
Result : constant not null Resources.Byte_Array_Access := new Resources.Byte_Array
(1 .. Identifier'Length + Header_Array'Length + Total_Size);
Header_Offset : constant Stream_Element_Offset := Result'First + Identifier'Length;
Size_Offset : Stream_Element_Offset := Header_Offset + Header_Array'Length;
begin
Result (Result'First .. Header_Offset - 1) := Identifier;
Result (Header_Offset .. Size_Offset - 1) := Stream_Element_Array (Convert (File_Header));
for Level_Data of Data loop
declare
Image_Size : constant Unsigned_32
:= (if KTX_Header.Kind = Texture_Cube_Map then
Level_Data.Get.Value'Length / 6
else
Level_Data.Get.Value'Length);
Data_Offset : constant Stream_Element_Offset := Size_Offset + 4;
Next_Offset : constant Stream_Element_Offset
:= Data_Offset + Level_Data.Get.Value'Length;
begin
Result (Size_Offset .. Data_Offset - 1)
:= Stream_Element_Array (Convert (Image_Size));
Result (Data_Offset .. Next_Offset - 1)
:= Level_Data.Get;
Size_Offset := Next_Offset;
end;
end loop;
Pointer.Set (Result);
return Pointer;
end;
end Create_KTX_Bytes;
end Orka.KTX;
|
Subsets and Splits