Dataset Viewer
added
stringdate 2023-09-08 23:13:54
2023-09-08 23:13:54
| created
stringdate 2023-09-08 23:13:54
2023-09-08 23:13:54
| id
int64 0
30.9k
| metadata
dict | source
stringclasses 1
value | text
stringlengths 9
1M
|
|---|---|---|---|---|---|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 0 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "luk9400/nsi",
"max_stars_repo_path": "list3/task3/c/src/bubble.adb",
"provenance": "train-00000-of-00001.jsonl.gz:1"
}
|
starcoder
|
<reponame>luk9400/nsi<gh_stars>0
package body Bubble with SPARK_Mode is
procedure Sort (A : in out Arr) is
Tmp : Integer;
begin
Outer: for I in reverse A'First .. A'Last - 1 loop
Inner: for J in A'First .. I loop
if A(J) > A(J + 1) then
Tmp := A(J);
A(J) := A(J + 1);
A(J + 1) := Tmp;
end if;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Inner)(K1)));
end loop Inner;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Outer)(K1)));
end loop Outer;
end Sort;
end Bubble;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 1 |
{
"extension": "ada",
"max_stars_count": "192",
"max_stars_repo_name": "rocher/Ada_Drivers_Library",
"max_stars_repo_path": "components/src/screen/ST7735R/st7735r.adb",
"provenance": "train-00000-of-00001.jsonl.gz:2"
}
|
starcoder
|
<filename>components/src/screen/ST7735R/st7735r.adb
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body ST7735R is
---------------------------
-- Register definitions --
---------------------------
type MADCTL is record
Reserved1, Reserved2 : Boolean;
MH : Horizontal_Refresh_Order;
RGB : RGB_BGR_Order;
ML : Vertical_Refresh_Order;
MV : Boolean;
MX : Column_Address_Order;
MY : Row_Address_Order;
end record with Size => 8, Bit_Order => System.Low_Order_First;
for MADCTL use record
Reserved1 at 0 range 0 .. 0;
Reserved2 at 0 range 1 .. 1;
MH at 0 range 2 .. 2;
RGB at 0 range 3 .. 3;
ML at 0 range 4 .. 4;
MV at 0 range 5 .. 5;
MX at 0 range 6 .. 6;
MY at 0 range 7 .. 7;
end record;
function To_UInt8 is new Ada.Unchecked_Conversion (MADCTL, UInt8);
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8);
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8;
Data : HAL.UInt8_Array);
procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class;
Data : UInt16;
Count : Natural);
-- Send the same pixel data Count times. This is used to fill an area with
-- the same color without allocating a buffer.
procedure Write_Data (LCD : ST7735R_Screen'Class;
Data : HAL.UInt8_Array);
procedure Read_Data (LCD : ST7735R_Screen'Class;
Data : out UInt16);
procedure Set_Command_Mode (LCD : ST7735R_Screen'Class);
procedure Set_Data_Mode (LCD : ST7735R_Screen'Class);
procedure Start_Transaction (LCD : ST7735R_Screen'Class);
procedure End_Transaction (LCD : ST7735R_Screen'Class);
----------------------
-- Set_Command_Mode --
----------------------
procedure Set_Command_Mode (LCD : ST7735R_Screen'Class) is
begin
LCD.RS.Clear;
end Set_Command_Mode;
-------------------
-- Set_Data_Mode --
-------------------
procedure Set_Data_Mode (LCD : ST7735R_Screen'Class) is
begin
LCD.RS.Set;
end Set_Data_Mode;
-----------------------
-- Start_Transaction --
-----------------------
procedure Start_Transaction (LCD : ST7735R_Screen'Class) is
begin
LCD.CS.Clear;
end Start_Transaction;
---------------------
-- End_Transaction --
---------------------
procedure End_Transaction (LCD : ST7735R_Screen'Class) is
begin
LCD.CS.Set;
end End_Transaction;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Command_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b'(1 => Cmd),
Status);
End_Transaction (LCD);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end Write_Command;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen'Class;
Cmd : UInt8;
Data : HAL.UInt8_Array)
is
begin
Write_Command (LCD, Cmd);
Write_Data (LCD, Data);
end Write_Command;
----------------
-- Write_Data --
----------------
procedure Write_Data (LCD : ST7735R_Screen'Class;
Data : HAL.UInt8_Array)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b (Data), Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
end Write_Data;
----------------------
-- Write_Pix_Repeat --
----------------------
procedure Write_Pix_Repeat (LCD : ST7735R_Screen'Class;
Data : UInt16;
Count : Natural)
is
Status : SPI_Status;
Data8 : constant SPI_Data_8b :=
SPI_Data_8b'(1 => UInt8 (Shift_Right (Data, 8) and 16#FF#),
2 => UInt8 (Data and 16#FF#));
begin
Write_Command (LCD, 16#2C#);
Start_Transaction (LCD);
Set_Data_Mode (LCD);
for X in 1 .. Count loop
LCD.Port.Transmit (Data8, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end loop;
End_Transaction (LCD);
end Write_Pix_Repeat;
---------------
-- Read_Data --
---------------
procedure Read_Data (LCD : ST7735R_Screen'Class;
Data : out UInt16)
is
SPI_Data : SPI_Data_16b (1 .. 1);
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Receive (SPI_Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
Data := SPI_Data (SPI_Data'First);
end Read_Data;
----------------
-- Initialize --
----------------
procedure Initialize (LCD : in out ST7735R_Screen) is
begin
LCD.Layer.LCD := LCD'Unchecked_Access;
LCD.RST.Clear;
LCD.Time.Delay_Milliseconds (100);
LCD.RST.Set;
LCD.Time.Delay_Milliseconds (100);
-- Sleep Exit
Write_Command (LCD, 16#11#);
LCD.Time.Delay_Milliseconds (100);
LCD.Initialized := True;
end Initialize;
-----------------
-- Initialized --
-----------------
overriding
function Initialized (LCD : ST7735R_Screen) return Boolean is
(LCD.Initialized);
-------------
-- Turn_On --
-------------
procedure Turn_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#29#);
end Turn_On;
--------------
-- Turn_Off --
--------------
procedure Turn_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#28#);
end Turn_Off;
--------------------------
-- Display_Inversion_On --
--------------------------
procedure Display_Inversion_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#21#);
end Display_Inversion_On;
---------------------------
-- Display_Inversion_Off --
---------------------------
procedure Display_Inversion_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#20#);
end Display_Inversion_Off;
---------------
-- Gamma_Set --
---------------
procedure Gamma_Set (LCD : ST7735R_Screen; Gamma_Curve : UInt4) is
begin
Write_Command (LCD, 16#26#, (0 => UInt8 (Gamma_Curve)));
end Gamma_Set;
----------------------
-- Set_Pixel_Format --
----------------------
procedure Set_Pixel_Format (LCD : ST7735R_Screen; Pix_Fmt : Pixel_Format) is
Value : constant UInt8 := (case Pix_Fmt is
when Pixel_12bits => 2#011#,
when Pixel_16bits => 2#101#,
when Pixel_18bits => 2#110#);
begin
Write_Command (LCD, 16#3A#, (0 => Value));
end Set_Pixel_Format;
----------------------------
-- Set_Memory_Data_Access --
----------------------------
procedure Set_Memory_Data_Access
(LCD : ST7735R_Screen;
Color_Order : RGB_BGR_Order;
Vertical : Vertical_Refresh_Order;
Horizontal : Horizontal_Refresh_Order;
Row_Addr_Order : Row_Address_Order;
Column_Addr_Order : Column_Address_Order;
Row_Column_Exchange : Boolean)
is
Value : MADCTL;
begin
Value.MY := Row_Addr_Order;
Value.MX := Column_Addr_Order;
Value.MV := Row_Column_Exchange;
Value.ML := Vertical;
Value.RGB := Color_Order;
Value.MH := Horizontal;
Write_Command (LCD, 16#36#, (0 => To_UInt8 (Value)));
end Set_Memory_Data_Access;
---------------------------
-- Set_Frame_Rate_Normal --
---------------------------
procedure Set_Frame_Rate_Normal
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B1#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Normal;
-------------------------
-- Set_Frame_Rate_Idle --
-------------------------
procedure Set_Frame_Rate_Idle
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B2#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Idle;
---------------------------------
-- Set_Frame_Rate_Partial_Full --
---------------------------------
procedure Set_Frame_Rate_Partial_Full
(LCD : ST7735R_Screen;
RTN_Part : UInt4;
Front_Porch_Part : UInt6;
Back_Porch_Part : UInt6;
RTN_Full : UInt4;
Front_Porch_Full : UInt6;
Back_Porch_Full : UInt6)
is
begin
Write_Command (LCD, 16#B3#,
(UInt8 (RTN_Part),
UInt8 (Front_Porch_Part),
UInt8 (Back_Porch_Part),
UInt8 (RTN_Full),
UInt8 (Front_Porch_Full),
UInt8 (Back_Porch_Full)));
end Set_Frame_Rate_Partial_Full;
---------------------------
-- Set_Inversion_Control --
---------------------------
procedure Set_Inversion_Control
(LCD : ST7735R_Screen;
Normal, Idle, Full_Partial : Inversion_Control)
is
Value : UInt8 := 0;
begin
if Normal = Line_Inversion then
Value := Value or 2#100#;
end if;
if Idle = Line_Inversion then
Value := Value or 2#010#;
end if;
if Full_Partial = Line_Inversion then
Value := Value or 2#001#;
end if;
Write_Command (LCD, 16#B4#, (0 => Value));
end Set_Inversion_Control;
-------------------------
-- Set_Power_Control_1 --
-------------------------
procedure Set_Power_Control_1
(LCD : ST7735R_Screen;
AVDD : UInt3;
VRHP : UInt5;
VRHN : UInt5;
MODE : UInt2)
is
P1, P2, P3 : UInt8;
begin
P1 := Shift_Left (UInt8 (AVDD), 5) or UInt8 (VRHP);
P2 := UInt8 (VRHN);
P3 := Shift_Left (UInt8 (MODE), 6) or 2#00_0100#;
Write_Command (LCD, 16#C0#, (P1, P2, P3));
end Set_Power_Control_1;
-------------------------
-- Set_Power_Control_2 --
-------------------------
procedure Set_Power_Control_2
(LCD : ST7735R_Screen;
VGH25 : UInt2;
VGSEL : UInt2;
VGHBT : UInt2)
is
P1 : UInt8;
begin
P1 := Shift_Left (UInt8 (VGH25), 6) or
Shift_Left (UInt8 (VGSEL), 2) or
UInt8 (VGHBT);
Write_Command (LCD, 16#C1#, (0 => P1));
end Set_Power_Control_2;
-------------------------
-- Set_Power_Control_3 --
-------------------------
procedure Set_Power_Control_3
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C2#, (P1, P2));
end Set_Power_Control_3;
-------------------------
-- Set_Power_Control_4 --
-------------------------
procedure Set_Power_Control_4
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C3#, (P1, P2));
end Set_Power_Control_4;
-------------------------
-- Set_Power_Control_5 --
-------------------------
procedure Set_Power_Control_5
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C4#, (P1, P2));
end Set_Power_Control_5;
--------------
-- Set_Vcom --
--------------
procedure Set_Vcom (LCD : ST7735R_Screen; VCOMS : UInt6) is
begin
Write_Command (LCD, 16#C5#, (0 => UInt8 (VCOMS)));
end Set_Vcom;
------------------------
-- Set_Column_Address --
------------------------
procedure Set_Column_Address (LCD : ST7735R_Screen; X_Start, X_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (X_Start and 16#FF#, 8));
P2 := UInt8 (X_Start and 16#FF#);
P3 := UInt8 (Shift_Right (X_End and 16#FF#, 8));
P4 := UInt8 (X_End and 16#FF#);
Write_Command (LCD, 16#2A#, (P1, P2, P3, P4));
end Set_Column_Address;
---------------------
-- Set_Row_Address --
---------------------
procedure Set_Row_Address (LCD : ST7735R_Screen; Y_Start, Y_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (Y_Start and 16#FF#, 8));
P2 := UInt8 (Y_Start and 16#FF#);
P3 := UInt8 (Shift_Right (Y_End and 16#FF#, 8));
P4 := UInt8 (Y_End and 16#FF#);
Write_Command (LCD, 16#2B#, (P1, P2, P3, P4));
end Set_Row_Address;
-----------------
-- Set_Address --
-----------------
procedure Set_Address (LCD : ST7735R_Screen;
X_Start, X_End, Y_Start, Y_End : UInt16)
is
begin
Set_Column_Address (LCD, X_Start, X_End);
Set_Row_Address (LCD, Y_Start, Y_End);
end Set_Address;
---------------
-- Set_Pixel --
---------------
procedure Set_Pixel (LCD : ST7735R_Screen;
X, Y : UInt16;
Color : UInt16)
is
Data : HAL.UInt16_Array (1 .. 1) := (1 => Color);
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Write_Raw_Pixels (LCD, Data);
end Set_Pixel;
-----------
-- Pixel --
-----------
function Pixel (LCD : ST7735R_Screen;
X, Y : UInt16)
return UInt16
is
Ret : UInt16;
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Read_Data (LCD, Ret);
return Ret;
end Pixel;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt8_Array)
is
Index : Natural := Data'First + 1;
Tmp : UInt8;
begin
-- The ST7735R uses a different endianness than our bitmaps
while Index <= Data'Last loop
Tmp := Data (Index);
Data (Index) := Data (Index - 1);
Data (Index - 1) := Tmp;
Index := Index + 1;
end loop;
Write_Command (LCD, 16#2C#);
Write_Data (LCD, Data);
end Write_Raw_Pixels;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt16_Array)
is
Data_8b : HAL.UInt8_Array (1 .. Data'Length * 2)
with Address => Data'Address;
begin
Write_Raw_Pixels (LCD, Data_8b);
end Write_Raw_Pixels;
--------------------
-- Get_Max_Layers --
--------------------
overriding
function Max_Layers
(Display : ST7735R_Screen) return Positive is (1);
------------------
-- Is_Supported --
------------------
overriding
function Supported
(Display : ST7735R_Screen;
Mode : FB_Color_Mode) return Boolean is
(Mode = HAL.Bitmap.RGB_565);
---------------------
-- Set_Orientation --
---------------------
overriding
procedure Set_Orientation
(Display : in out ST7735R_Screen;
Orientation : Display_Orientation)
is
begin
null;
end Set_Orientation;
--------------
-- Set_Mode --
--------------
overriding
procedure Set_Mode
(Display : in out ST7735R_Screen;
Mode : Wait_Mode)
is
begin
null;
end Set_Mode;
---------------
-- Get_Width --
---------------
overriding
function Width
(Display : ST7735R_Screen) return Positive is (Screen_Width);
----------------
-- Get_Height --
----------------
overriding
function Height
(Display : ST7735R_Screen) return Positive is (Screen_Height);
----------------
-- Is_Swapped --
----------------
overriding
function Swapped
(Display : ST7735R_Screen) return Boolean is (False);
--------------------
-- Set_Background --
--------------------
overriding
procedure Set_Background
(Display : ST7735R_Screen; R, G, B : UInt8)
is
begin
-- Does it make sense when there's no alpha channel...
raise Program_Error;
end Set_Background;
----------------------
-- Initialize_Layer --
----------------------
overriding
procedure Initialize_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Mode : FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
pragma Unreferenced (X, Y);
begin
if Layer /= 1 or else Mode /= RGB_565 then
raise Program_Error;
end if;
Display.Layer.Width := Width;
Display.Layer.Height := Height;
end Initialize_Layer;
-----------------
-- Initialized --
-----------------
overriding
function Initialized
(Display : ST7735R_Screen;
Layer : Positive) return Boolean
is
pragma Unreferenced (Display);
begin
return Layer = 1;
end Initialized;
------------------
-- Update_Layer --
------------------
overriding
procedure Update_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Copy_Back : Boolean := False)
is
pragma Unreferenced (Copy_Back, Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
end Update_Layer;
-------------------
-- Update_Layers --
-------------------
overriding
procedure Update_Layers
(Display : in out ST7735R_Screen)
is
begin
Display.Update_Layer (1);
end Update_Layers;
--------------------
-- Get_Color_Mode --
--------------------
overriding
function Color_Mode
(Display : ST7735R_Screen;
Layer : Positive) return FB_Color_Mode
is
pragma Unreferenced (Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
return RGB_565;
end Color_Mode;
-----------------------
-- Get_Hidden_Buffer --
-----------------------
overriding
function Hidden_Buffer
(Display : in out ST7735R_Screen;
Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer
is
begin
if Layer /= 1 then
raise Program_Error;
end if;
return Display.Layer'Unchecked_Access;
end Hidden_Buffer;
----------------
-- Pixel_Size --
----------------
overriding
function Pixel_Size
(Display : ST7735R_Screen;
Layer : Positive) return Positive is (16);
----------------
-- Set_Source --
----------------
overriding
procedure Set_Source (Buffer : in out ST7735R_Bitmap_Buffer;
Native : UInt32)
is
begin
Buffer.Native_Source := Native;
end Set_Source;
------------
-- Source --
------------
overriding
function Source
(Buffer : ST7735R_Bitmap_Buffer)
return UInt32
is
begin
return Buffer.Native_Source;
end Source;
---------------
-- Set_Pixel --
---------------
overriding
procedure Set_Pixel
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point)
is
begin
Buffer.LCD.Set_Pixel (UInt16 (Pt.X), UInt16 (Pt.Y),
UInt16 (Buffer.Native_Source));
end Set_Pixel;
---------------------
-- Set_Pixel_Blend --
---------------------
overriding
procedure Set_Pixel_Blend
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point) renames Set_Pixel;
-----------
-- Pixel --
-----------
overriding
function Pixel
(Buffer : ST7735R_Bitmap_Buffer;
Pt : Point)
return UInt32
is (UInt32 (Buffer.LCD.Pixel (UInt16 (Pt.X), UInt16 (Pt.Y))));
----------
-- Fill --
----------
overriding
procedure Fill
(Buffer : in out ST7735R_Bitmap_Buffer)
is
begin
-- Set the drawing area over the entire layer
Set_Address (Buffer.LCD.all,
0, UInt16 (Buffer.Width - 1),
0, UInt16 (Buffer.Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Buffer.Width * Buffer.Height);
end Fill;
---------------
-- Fill_Rect --
---------------
overriding
procedure Fill_Rect
(Buffer : in out ST7735R_Bitmap_Buffer;
Area : Rect)
is
begin
-- Set the drawing area coresponding to the rectangle to draw
Set_Address (Buffer.LCD.all,
UInt16 (Area.Position.X),
UInt16 (Area.Position.X + Area.Width - 1),
UInt16 (Area.Position.Y),
UInt16 (Area.Position.Y + Area.Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Area.Width * Area.Height);
end Fill_Rect;
------------------------
-- Draw_Vertical_Line --
------------------------
overriding
procedure Draw_Vertical_Line
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point;
Height : Integer)
is
begin
-- Set the drawing area coresponding to the line to draw
Set_Address (Buffer.LCD.all,
UInt16 (Pt.X),
UInt16 (Pt.X),
UInt16 (Pt.Y),
UInt16 (Pt.Y + Height - 1));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Height);
end Draw_Vertical_Line;
--------------------------
-- Draw_Horizontal_Line --
--------------------------
overriding
procedure Draw_Horizontal_Line
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point;
Width : Integer)
is
begin
-- Set the drawing area coresponding to the line to draw
Set_Address (Buffer.LCD.all,
UInt16 (Pt.X),
UInt16 (Pt.X + Width),
UInt16 (Pt.Y),
UInt16 (Pt.Y));
-- Fill the drawing area with a single color
Write_Pix_Repeat (Buffer.LCD.all,
UInt16 (Buffer.Native_Source and 16#FFFF#),
Width);
end Draw_Horizontal_Line;
end ST7735R;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 2 |
{
"extension": "ada",
"max_stars_count": "7",
"max_stars_repo_name": "best08618/asylo",
"max_stars_repo_path": "gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c38002a.ada",
"provenance": "train-00000-of-00001.jsonl.gz:3"
}
|
starcoder
|
<reponame>best08618/asylo
-- C38002A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT AN UNCONSTRAINED ARRAY TYPE OR A RECORD WITHOUT
-- DEFAULT DISCRIMINANTS CAN BE USED IN AN ACCESS_TYPE_DEFINITION
-- WITHOUT AN INDEX OR DISCRIMINANT CONSTRAINT.
--
-- CHECK THAT (NON-STATIC) INDEX OR DISCRIMINANT CONSTRAINTS CAN
-- SUBSEQUENTLY BE IMPOSED WHEN THE TYPE IS USED IN AN OBJECT
-- DECLARATION, ARRAY COMPONENT DECLARATION, RECORD COMPONENT
-- DECLARATION, ACCESS TYPE DECLARATION, PARAMETER DECLARATION,
-- DERIVED TYPE DEFINITION, PRIVATE TYPE.
--
-- CHECK FOR UNCONSTRAINED GENERIC FORMAL TYPE.
-- HISTORY:
-- AH 09/02/86 CREATED ORIGINAL TEST.
-- DHH 08/16/88 REVISED HEADER AND ENTERED COMMENTS FOR PRIVATE TYPE
-- AND CORRECTED INDENTATION.
-- BCB 04/12/90 ADDED CHECKS FOR AN ARRAY AS A SUBPROGRAM RETURN
-- TYPE AND AN ARRAY AS A FORMAL PARAMETER.
-- LDC 10/01/90 ADDED CODE SO F, FPROC, G, GPROC AREN'T OPTIMIZED
-- AWAY
WITH REPORT; USE REPORT;
PROCEDURE C38002A IS
BEGIN
TEST ("C38002A", "NON-STATIC CONSTRAINTS CAN BE IMPOSED " &
"ON ACCESS TYPES ACCESSING PREVIOUSLY UNCONSTRAINED " &
"ARRAY OR RECORD TYPES");
DECLARE
C3 : CONSTANT INTEGER := IDENT_INT(3);
TYPE ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE ARR_NAME IS ACCESS ARR;
SUBTYPE ARR_NAME_3 IS ARR_NAME(1..3);
TYPE REC(DISC : INTEGER) IS
RECORD
COMP : ARR_NAME(1..DISC);
END RECORD;
TYPE REC_NAME IS ACCESS REC;
OBJ : REC_NAME(C3);
TYPE ARR2 IS ARRAY (1..10) OF REC_NAME(C3);
TYPE REC2 IS
RECORD
COMP2 : REC_NAME(C3);
END RECORD;
TYPE NAME_REC_NAME IS ACCESS REC_NAME(C3);
TYPE DERIV IS NEW REC_NAME(C3);
SUBTYPE REC_NAME_3 IS REC_NAME(C3);
FUNCTION F (PARM : REC_NAME_3) RETURN REC_NAME_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END;
PROCEDURE FPROC (PARM : REC_NAME_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END FPROC;
FUNCTION G (PA : ARR_NAME_3) RETURN ARR_NAME_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(5), 3 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE G AWAY");
END IF;
RETURN PA;
END G;
PROCEDURE GPROC (PA : ARR_NAME_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(6), 4 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE GPROC AWAY");
END IF;
END GPROC;
BEGIN
DECLARE
R : REC_NAME;
BEGIN
R := NEW REC'(DISC => 3, COMP => NEW ARR'(1..3 => 5));
R := F(R);
R := NEW REC'(DISC => 4, COMP => NEW ARR'(1..4 => 5));
R := F(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR RECORD");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - RECORD,FUNCTION");
END IF;
END;
DECLARE
R : REC_NAME;
BEGIN
R := NEW REC'(DISC => 3, COMP => NEW ARR'(1..3 => 5));
FPROC(R);
R := NEW REC'(DISC => 4, COMP => NEW ARR'(1..4 => 5));
FPROC(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR RECORD");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - RECORD,PROCEDURE");
END IF;
END;
DECLARE
A : ARR_NAME;
BEGIN
A := NEW ARR'(1..3 => 5);
A := G(A);
A := NEW ARR'(1..4 => 6);
A := G(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR ARRAY");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - ARRAY,FUNCTION");
END IF;
END;
DECLARE
A : ARR_NAME;
BEGIN
A := NEW ARR'(1..3 => 5);
GPROC(A);
A := NEW ARR'(1..4 => 6);
GPROC(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR ARRAY");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT OF " &
"ACCESS VALUE - ARRAY,PROCEDURE");
END IF;
END;
END;
DECLARE
C3 : CONSTANT INTEGER := IDENT_INT(3);
TYPE REC (DISC : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE P_ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE P_ARR_NAME IS ACCESS P_ARR;
TYPE P_REC_NAME IS ACCESS REC;
GENERIC
TYPE UNCON_ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
PACKAGE P IS
TYPE ACC_REC IS ACCESS REC;
TYPE ACC_ARR IS ACCESS UNCON_ARR;
TYPE ACC_P_ARR IS ACCESS P_ARR;
SUBTYPE ACC_P_ARR_3 IS ACC_P_ARR(1..3);
OBJ : ACC_REC(C3);
TYPE ARR2 IS ARRAY (1..10) OF ACC_REC(C3);
TYPE REC1 IS
RECORD
COMP1 : ACC_REC(C3);
END RECORD;
TYPE REC2 IS
RECORD
COMP2 : ACC_ARR(1..C3);
END RECORD;
SUBTYPE ACC_REC_3 IS ACC_REC(C3);
FUNCTION F (PARM : ACC_REC_3) RETURN ACC_REC_3;
PROCEDURE FPROC (PARM : ACC_REC_3);
FUNCTION G (PA : ACC_P_ARR_3) RETURN ACC_P_ARR_3;
PROCEDURE GPROC (PA : ACC_P_ARR_3);
TYPE ACC1 IS PRIVATE;
TYPE ACC2 IS PRIVATE;
TYPE DER1 IS PRIVATE;
TYPE DER2 IS PRIVATE;
PRIVATE
TYPE ACC1 IS ACCESS ACC_REC(C3);
TYPE ACC2 IS ACCESS ACC_ARR(1..C3);
TYPE DER1 IS NEW ACC_REC(C3);
TYPE DER2 IS NEW ACC_ARR(1..C3);
END P;
PACKAGE BODY P IS
FUNCTION F (PARM : ACC_REC_3) RETURN ACC_REC_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END;
PROCEDURE FPROC (PARM : ACC_REC_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END FPROC;
FUNCTION G (PA : ACC_P_ARR_3) RETURN ACC_P_ARR_3 IS
BEGIN
IF NOT EQUAL(IDENT_INT(5), 3 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE G AWAY");
END IF;
RETURN PA;
END;
PROCEDURE GPROC (PA : ACC_P_ARR_3) IS
BEGIN
IF NOT EQUAL(IDENT_INT(6), 4 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE GPROC AWAY");
END IF;
END GPROC;
END P;
PACKAGE NP IS NEW P (UNCON_ARR => P_ARR);
USE NP;
BEGIN
DECLARE
R : ACC_REC;
BEGIN
R := NEW REC(DISC => 3);
R := F(R);
R := NEW REC(DISC => 4);
R := F(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR A RECORD -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - RECORD," &
"FUNCTION -GENERIC");
END IF;
END;
DECLARE
R : ACC_REC;
BEGIN
R := NEW REC(DISC => 3);
FPROC(R);
R := NEW REC(DISC => 4);
FPROC(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR A RECORD -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R = NULL OR ELSE R.DISC /= 4 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - RECORD," &
"PROCEDURE -GENERIC");
END IF;
END;
DECLARE
A : ACC_P_ARR;
BEGIN
A := NEW P_ARR'(1..3 => 5);
A := G(A);
A := NEW P_ARR'(1..4 => 6);
A := G(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY FUNCTION FOR AN ARRAY -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - ARRAY," &
"FUNCTION -GENERIC");
END IF;
END;
DECLARE
A : ACC_P_ARR;
BEGIN
A := NEW P_ARR'(1..3 => 5);
GPROC(A);
A := NEW P_ARR'(1..4 => 6);
GPROC(A);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE FOR AN ARRAY -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF A = NULL OR ELSE A(4) /= 6 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - ARRAY," &
"PROCEDURE -GENERIC");
END IF;
END;
END;
DECLARE
TYPE CON_INT IS RANGE 1..10;
GENERIC
TYPE UNCON_INT IS RANGE <>;
PACKAGE P2 IS
SUBTYPE NEW_INT IS UNCON_INT RANGE 1..5;
FUNCTION FUNC_INT (PARM : NEW_INT) RETURN NEW_INT;
PROCEDURE PROC_INT (PARM : NEW_INT);
END P2;
PACKAGE BODY P2 IS
FUNCTION FUNC_INT (PARM : NEW_INT) RETURN NEW_INT IS
BEGIN
IF NOT EQUAL(IDENT_INT(3), 1 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE F AWAY");
END IF;
RETURN PARM;
END FUNC_INT;
PROCEDURE PROC_INT (PARM : NEW_INT) IS
BEGIN
IF NOT EQUAL(IDENT_INT(4), 2 + IDENT_INT(2)) THEN
COMMENT("DON'T OPTIMIZE FPROC AWAY");
END IF;
END PROC_INT;
END P2;
PACKAGE NP2 IS NEW P2 (UNCON_INT => CON_INT);
USE NP2;
BEGIN
DECLARE
R : CON_INT;
BEGIN
R := 2;
R := FUNC_INT(R);
R := 8;
R := FUNC_INT(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON VALUE " &
"ACCEPTED BY FUNCTION -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R /= 8 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF VALUE -FUNCTION, GENERIC");
END IF;
END;
DECLARE
R : CON_INT;
BEGIN
R := 2;
PROC_INT(R);
R := 9;
PROC_INT(R);
FAILED ("INCOMPATIBLE CONSTRAINT ON ACCESS VALUE " &
"ACCEPTED BY PROCEDURE -GENERIC");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF R /= 9 THEN
FAILED ("ERROR IN EVALUATION/ASSIGNMENT " &
"OF ACCESS VALUE - PROCEDURE, " &
"GENERIC");
END IF;
END;
END;
RESULT;
END C38002A;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 3 |
{
"extension": "ada",
"max_stars_count": "6",
"max_stars_repo_name": "jonashaggstrom/ada-canopen",
"max_stars_repo_path": "examples/stm32f40x/src/app.ads",
"provenance": "train-00000-of-00001.jsonl.gz:4"
}
|
starcoder
|
<filename>examples/stm32f40x/src/app.ads
package App is
procedure Run;
end App;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 4 |
{
"extension": "ada",
"max_stars_count": "1",
"max_stars_repo_name": "brucegua/moocos",
"max_stars_repo_path": "tools/scitools/conf/understand/ada/ada05/a-cihama.ads",
"provenance": "train-00000-of-00001.jsonl.gz:5"
}
|
starcoder
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . --
-- I N D E F I N I T E _ H A S H E D _ M A P S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2006, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- This unit was originally developed by <NAME>. --
------------------------------------------------------------------------------
with Ada.Containers.Hash_Tables;
with Ada.Streams;
with Ada.Finalization;
generic
type Key_Type (<>) is private;
type Element_Type (<>) is private;
with function Hash (Key : Key_Type) return Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Indefinite_Hashed_Maps is
pragma Preelaborate;
type Map is tagged private;
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Map : constant Map;
No_Element : constant Cursor;
function "=" (Left, Right : Map) return Boolean;
function Capacity (Container : Map) return Count_Type;
procedure Reserve_Capacity
(Container : in out Map;
Capacity : Count_Type);
function Length (Container : Map) return Count_Type;
function Is_Empty (Container : Map) return Boolean;
procedure Clear (Container : in out Map);
function Key (Position : Cursor) return Key_Type;
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type);
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : Element_Type));
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type));
procedure Move (Target : in out Map; Source : in out Map);
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Exclude (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Position : in out Cursor);
function First (Container : Map) return Cursor;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Find (Container : Map; Key : Key_Type) return Cursor;
function Contains (Container : Map; Key : Key_Type) return Boolean;
function Element (Container : Map; Key : Key_Type) return Element_Type;
function Has_Element (Position : Cursor) return Boolean;
function Equivalent_Keys (Left, Right : Cursor) return Boolean;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean;
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor));
private
pragma Inline ("=");
pragma Inline (Length);
pragma Inline (Is_Empty);
pragma Inline (Clear);
pragma Inline (Key);
pragma Inline (Element);
pragma Inline (Move);
pragma Inline (Contains);
pragma Inline (Capacity);
pragma Inline (Reserve_Capacity);
pragma Inline (Has_Element);
pragma Inline (Equivalent_Keys);
type Node_Type;
type Node_Access is access Node_Type;
type Key_Access is access Key_Type;
type Element_Access is access Element_Type;
type Node_Type is limited record
Key : Key_Access;
Element : Element_Access;
Next : Node_Access;
end record;
package HT_Types is new Hash_Tables.Generic_Hash_Table_Types
(Node_Type,
Node_Access);
type Map is new Ada.Finalization.Controlled with record
HT : HT_Types.Hash_Table_Type;
end record;
use HT_Types;
use Ada.Finalization;
use Ada.Streams;
procedure Adjust (Container : in out Map);
procedure Finalize (Container : in out Map);
type Map_Access is access constant Map;
for Map_Access'Storage_Size use 0;
type Cursor is
record
Container : Map_Access;
Node : Node_Access;
end record;
procedure Write
(Stream : access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
(Stream : access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
No_Element : constant Cursor :=
(Container => null,
Node => null);
procedure Write
(Stream : access Root_Stream_Type'Class;
Container : Map);
for Map'Write use Write;
procedure Read
(Stream : access Root_Stream_Type'Class;
Container : out Map);
for Map'Read use Read;
Empty_Map : constant Map := (Controlled with HT => (null, 0, 0, 0));
end Ada.Containers.Indefinite_Hashed_Maps;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 5 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "Letractively/ada-awa",
"max_stars_repo_path": "awa/src/awa-users-filters.adb",
"provenance": "train-00000-of-00001.jsonl.gz:6"
}
|
starcoder
|
-----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication and key verification
-- Copyright (C) 2011, 2012, 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Log.Loggers;
with ASF.Cookies;
with AWA.Users.Services;
with AWA.Users.Modules;
package body AWA.Users.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Set the user principal on the session associated with the ASF request.
-- ------------------------------
procedure Set_Session_Principal (Request : in out ASF.Requests.Request'Class;
Principal : in Principals.Principal_Access) is
Session : ASF.Sessions.Session := Request.Get_Session (Create => True);
begin
Session.Set_Principal (Principal.all'Access);
end Set_Session_Principal;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
procedure Initialize (Filter : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
ASF.Security.Filters.Auth_Filter (Filter).Initialize (Context);
end Initialize;
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Session);
use AWA.Users.Modules;
use AWA.Users.Services;
Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager;
P : AWA.Users.Principals.Principal_Access;
begin
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : ASF.Cookies.Cookie := ASF.Cookies.Create (ASF.Security.Filters.AID_COOKIE,
Cookie);
begin
ASF.Cookies.Set_Path (C, Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := To_String (Filter.Login_URI);
begin
Log.Info ("User is not logged, redirecting to {0}", URI);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => URI);
else
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Verify_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM);
begin
Filter.Invalid_Key_URI := To_Unbounded_String (URI);
end Initialize;
-- ------------------------------
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
-- ------------------------------
overriding
procedure Do_Filter (Filter : in Verify_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
Key : constant String := Request.Get_Parameter (PARAM_ACCESS_KEY);
Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager;
Principal : AWA.Users.Principals.Principal_Access;
begin
Log.Info ("Verify access key {0}", Key);
Manager.Verify_User (Key => Key,
IpAddr => "",
Principal => Principal);
Set_Session_Principal (Request, Principal);
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
exception
when AWA.Users.Services.Not_Found =>
declare
URI : constant String := To_String (Filter.Invalid_Key_URI);
begin
Log.Info ("Invalid access key {0}, redirecting to {1}", Key, URI);
Response.Send_Redirect (Location => URI);
end;
end Do_Filter;
end AWA.Users.Filters;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 6 |
{
"extension": "ada",
"max_stars_count": "7",
"max_stars_repo_name": "best08618/asylo",
"max_stars_repo_path": "gcc-gcc-7_3_0-release/gcc/ada/osint-c.adb",
"provenance": "train-00000-of-00001.jsonl.gz:7"
}
|
starcoder
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O S I N T - C --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2016, 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 Opt; use Opt;
with Tree_IO; use Tree_IO;
package body Osint.C is
Output_Object_File_Name : String_Ptr;
-- Argument of -o compiler option, if given. This is needed to verify
-- consistency with the ALI file name.
procedure Adjust_OS_Resource_Limits;
pragma Import (C, Adjust_OS_Resource_Limits,
"__gnat_adjust_os_resource_limits");
-- Procedure to make system specific adjustments to make GNAT run better
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type;
-- Common processing for Create_List_File, Create_Repinfo_File and
-- Create_Debug_File. Src is the file name used to create the required
-- output file and Suffix is the desired suffix (dg/rep/xxx for debug/
-- repinfo/list file where xxx is specified extension.
------------------
-- Close_C_File --
------------------
procedure Close_C_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing file "
& Get_Name_String (Output_File_Name));
end if;
end Close_C_File;
----------------------
-- Close_Debug_File --
----------------------
procedure Close_Debug_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing expanded source file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Debug_File;
------------------
-- Close_H_File --
------------------
procedure Close_H_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing file "
& Get_Name_String (Output_File_Name));
end if;
end Close_H_File;
---------------------
-- Close_List_File --
---------------------
procedure Close_List_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing list file "
& Get_Name_String (Output_File_Name));
end if;
end Close_List_File;
-------------------------------
-- Close_Output_Library_Info --
-------------------------------
procedure Close_Output_Library_Info is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing ALI file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Output_Library_Info;
------------------------
-- Close_Repinfo_File --
------------------------
procedure Close_Repinfo_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing representation info file "
& Get_Name_String (Output_File_Name));
end if;
end Close_Repinfo_File;
---------------------------
-- Create_Auxiliary_File --
---------------------------
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type
is
Result : File_Name_Type;
begin
Get_Name_String (Src);
Name_Buffer (Name_Len + 1) := '.';
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
if Output_Object_File_Name /= null then
for Index in reverse Output_Object_File_Name'Range loop
if Output_Object_File_Name (Index) = Directory_Separator then
declare
File_Name : constant String := Name_Buffer (1 .. Name_Len);
begin
Name_Len := Index - Output_Object_File_Name'First + 1;
Name_Buffer (1 .. Name_Len) :=
Output_Object_File_Name
(Output_Object_File_Name'First .. Index);
Name_Buffer (Name_Len + 1 .. Name_Len + File_Name'Length) :=
File_Name;
Name_Len := Name_Len + File_Name'Length;
end;
exit;
end if;
end loop;
end if;
Result := Name_Find;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
Create_File_And_Check (Output_FD, Text);
return Result;
end Create_Auxiliary_File;
-------------------
-- Create_C_File --
-------------------
procedure Create_C_File is
Dummy : Boolean;
begin
Set_File_Name ("c");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_C_File;
-----------------------
-- Create_Debug_File --
-----------------------
function Create_Debug_File (Src : File_Name_Type) return File_Name_Type is
begin
return Create_Auxiliary_File (Src, "dg");
end Create_Debug_File;
-------------------
-- Create_H_File --
-------------------
procedure Create_H_File is
Dummy : Boolean;
begin
Set_File_Name ("h");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_H_File;
----------------------
-- Create_List_File --
----------------------
procedure Create_List_File (S : String) is
Dummy : File_Name_Type;
begin
if S (S'First) = '.' then
Dummy :=
Create_Auxiliary_File (Current_Main, S (S'First + 1 .. S'Last));
else
Name_Buffer (1 .. S'Length) := S;
Name_Len := S'Length + 1;
Name_Buffer (Name_Len) := ASCII.NUL;
Create_File_And_Check (Output_FD, Text);
end if;
end Create_List_File;
--------------------------------
-- Create_Output_Library_Info --
--------------------------------
procedure Create_Output_Library_Info is
Dummy : Boolean;
begin
Set_File_Name (ALI_Suffix.all);
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
Create_File_And_Check (Output_FD, Text);
end Create_Output_Library_Info;
------------------------------
-- Open_Output_Library_Info --
------------------------------
procedure Open_Output_Library_Info is
begin
Set_File_Name (ALI_Suffix.all);
Open_File_To_Append_And_Check (Output_FD, Text);
end Open_Output_Library_Info;
-------------------------
-- Create_Repinfo_File --
-------------------------
procedure Create_Repinfo_File (Src : String) is
Discard : File_Name_Type;
begin
Name_Buffer (1 .. Src'Length) := Src;
Name_Len := Src'Length;
Discard := Create_Auxiliary_File (Name_Find, "rep");
return;
end Create_Repinfo_File;
---------------------------
-- Debug_File_Eol_Length --
---------------------------
function Debug_File_Eol_Length return Nat is
begin
-- There has to be a cleaner way to do this ???
if Directory_Separator = '/' then
return 1;
else
return 2;
end if;
end Debug_File_Eol_Length;
-------------------
-- Delete_C_File --
-------------------
procedure Delete_C_File is
Dummy : Boolean;
begin
Set_File_Name ("c");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
end Delete_C_File;
-------------------
-- Delete_H_File --
-------------------
procedure Delete_H_File is
Dummy : Boolean;
begin
Set_File_Name ("h");
Delete_File (Name_Buffer (1 .. Name_Len), Dummy);
end Delete_H_File;
---------------------------------
-- Get_Output_Object_File_Name --
---------------------------------
function Get_Output_Object_File_Name return String is
begin
pragma Assert (Output_Object_File_Name /= null);
return Output_Object_File_Name.all;
end Get_Output_Object_File_Name;
-----------------------
-- More_Source_Files --
-----------------------
function More_Source_Files return Boolean renames More_Files;
----------------------
-- Next_Main_Source --
----------------------
function Next_Main_Source return File_Name_Type renames Next_Main_File;
-----------------------
-- Read_Library_Info --
-----------------------
procedure Read_Library_Info
(Name : out File_Name_Type;
Text : out Text_Buffer_Ptr)
is
begin
Set_File_Name (ALI_Suffix.all);
-- Remove trailing NUL that comes from Set_File_Name above. This is
-- needed for consistency with names that come from Scan_ALI and thus
-- preventing repeated scanning of the same file.
pragma Assert (Name_Len > 1 and then Name_Buffer (Name_Len) = ASCII.NUL);
Name_Len := Name_Len - 1;
Name := Name_Find;
Text := Read_Library_Info (Name, Fatal_Err => False);
end Read_Library_Info;
-------------------
-- Set_File_Name --
-------------------
procedure Set_File_Name (Ext : String) is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- Find last dot since we replace the existing extension by .ali. The
-- initialization to Name_Len + 1 provides for simply adding the .ali
-- extension if the source file name has no extension.
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Make sure that the output file name matches the source file name.
-- To compare them, remove file name directories and extensions.
if Output_Object_File_Name /= null then
-- Make sure there is a dot at Dot_Index. This may not be the case
-- if the source file name has no extension.
Name_Buffer (Dot_Index) := '.';
-- If we are in multiple unit per file mode, then add ~nnn
-- extension to the name before doing the comparison.
if Multiple_Unit_Index /= 0 then
declare
Exten : constant String := Name_Buffer (Dot_Index .. Name_Len);
begin
Name_Len := Dot_Index - 1;
Add_Char_To_Name_Buffer (Multi_Unit_Index_Character);
Add_Nat_To_Name_Buffer (Multiple_Unit_Index);
Dot_Index := Name_Len + 1;
Add_Str_To_Name_Buffer (Exten);
end;
end if;
-- Remove extension preparing to replace it
declare
Name : String := Name_Buffer (1 .. Dot_Index);
First : Positive;
begin
Name_Buffer (1 .. Output_Object_File_Name'Length) :=
Output_Object_File_Name.all;
-- Put two names in canonical case, to allow object file names
-- with upper-case letters on Windows.
Canonical_Case_File_Name (Name);
Canonical_Case_File_Name
(Name_Buffer (1 .. Output_Object_File_Name'Length));
Dot_Index := 0;
for J in reverse Output_Object_File_Name'Range loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Dot_Index should not be zero now (we check for extension
-- elsewhere).
pragma Assert (Dot_Index /= 0);
-- Look for first character of file name
First := Dot_Index;
while First > 1
and then Name_Buffer (First - 1) /= Directory_Separator
and then Name_Buffer (First - 1) /= '/'
loop
First := First - 1;
end loop;
-- Check name of object file is what we expect
if Name /= Name_Buffer (First .. Dot_Index) then
Fail ("incorrect object file name");
end if;
end;
end if;
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1 .. Dot_Index + Ext'Length) := Ext;
Name_Buffer (Dot_Index + Ext'Length + 1) := ASCII.NUL;
Name_Len := Dot_Index + Ext'Length + 1;
end Set_File_Name;
---------------------------------
-- Set_Output_Object_File_Name --
---------------------------------
procedure Set_Output_Object_File_Name (Name : String) is
Ext : constant String := Target_Object_Suffix;
NL : constant Natural := Name'Length;
EL : constant Natural := Ext'Length;
begin
-- Make sure that the object file has the expected extension
if NL <= EL
or else
(Name (NL - EL + Name'First .. Name'Last) /= Ext
and then Name (NL - 2 + Name'First .. Name'Last) /= ".o"
and then
(not Generate_C_Code
or else Name (NL - 2 + Name'First .. Name'Last) /= ".c"))
then
Fail ("incorrect object file extension");
end if;
Output_Object_File_Name := new String'(Name);
end Set_Output_Object_File_Name;
----------------
-- Tree_Close --
----------------
procedure Tree_Close is
Status : Boolean;
begin
Tree_Write_Terminate;
Close (Output_FD, Status);
if not Status then
Fail
("error while closing tree file "
& Get_Name_String (Output_File_Name));
end if;
end Tree_Close;
-----------------
-- Tree_Create --
-----------------
procedure Tree_Create is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- If an object file has been specified, then the ALI file
-- will be in the same directory as the object file;
-- so, we put the tree file in this same directory,
-- even though no object file needs to be generated.
if Output_Object_File_Name /= null then
Name_Len := Output_Object_File_Name'Length;
Name_Buffer (1 .. Name_Len) := Output_Object_File_Name.all;
end if;
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Should be impossible to not have an extension
pragma Assert (Dot_Index /= 0);
-- Change extension to adt
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1) := 'a';
Name_Buffer (Dot_Index + 2) := 'd';
Name_Buffer (Dot_Index + 3) := 't';
Name_Buffer (Dot_Index + 4) := ASCII.NUL;
Name_Len := Dot_Index + 3;
Create_File_And_Check (Output_FD, Binary);
Tree_Write_Initialize (Output_FD);
end Tree_Create;
-----------------------
-- Write_Debug_Info --
-----------------------
procedure Write_Debug_Info (Info : String) renames Write_Info;
------------------------
-- Write_Library_Info --
------------------------
procedure Write_Library_Info (Info : String) renames Write_Info;
---------------------
-- Write_List_Info --
---------------------
procedure Write_List_Info (S : String) is
begin
Write_With_Check (S'Address, S'Length);
end Write_List_Info;
------------------------
-- Write_Repinfo_Line --
------------------------
procedure Write_Repinfo_Line (Info : String) renames Write_Info;
begin
Adjust_OS_Resource_Limits;
Opt.Create_Repinfo_File_Access := Create_Repinfo_File'Access;
Opt.Write_Repinfo_Line_Access := Write_Repinfo_Line'Access;
Opt.Close_Repinfo_File_Access := Close_Repinfo_File'Access;
Opt.Create_List_File_Access := Create_List_File'Access;
Opt.Write_List_Info_Access := Write_List_Info'Access;
Opt.Close_List_File_Access := Close_List_File'Access;
Set_Program (Compiler);
end Osint.C;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 7 |
{
"extension": "ada",
"max_stars_count": "3",
"max_stars_repo_name": "daveshields/AdaEd",
"max_stars_repo_path": "bugs/bug20.ada",
"provenance": "train-00000-of-00001.jsonl.gz:8"
}
|
starcoder
|
<reponame>daveshields/AdaEd
package p is
type t is private;
end p;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 8 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "fuzzysloth/ada-awa",
"max_stars_repo_path": "awa/plugins/awa-counters/src/awa-counters-beans.ads",
"provenance": "train-00000-of-00001.jsonl.gz:9"
}
|
starcoder
|
-----------------------------------------------------------------------
-- awa-counters-beans -- Counter bean definition
-- Copyright (C) 2015, 2016 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with ADO.Objects;
with ADO.Schemas;
with ADO.Queries;
with Util.Beans.Objects;
with Util.Beans.Basic;
with AWA.Counters.Modules;
with AWA.Counters.Models;
-- == Counter Bean ==
-- The <b>Counter_Bean</b> allows to represent a counter associated with some database
-- entity and allows its control by the <awa:counter> component.
--
package AWA.Counters.Beans is
type Counter_Bean (Of_Type : ADO.Objects.Object_Key_Type;
Of_Class : ADO.Schemas.Class_Mapping_Access) is
new Util.Beans.Basic.Readonly_Bean with record
Counter : Counter_Index_Type;
Value : Integer := -1;
Object : ADO.Objects.Object_Key (Of_Type, Of_Class);
end record;
type Counter_Bean_Access is access all Counter_Bean'Class;
-- Get the value identified by the name.
overriding
function Get_Value (From : in Counter_Bean;
Name : in String) return Util.Beans.Objects.Object;
type Counter_Stat_Bean is new AWA.Counters.Models.Stat_List_Bean with record
Module : AWA.Counters.Modules.Counter_Module_Access;
Stats : aliased AWA.Counters.Models.Stat_Info_List_Bean;
Stats_Bean : AWA.Counters.Models.Stat_Info_List_Bean_Access;
end record;
type Counter_Stat_Bean_Access is access all Counter_Stat_Bean'Class;
-- Get the query definition to collect the counter statistics.
function Get_Query (From : in Counter_Stat_Bean) return ADO.Queries.Query_Definition_Access;
overriding
function Get_Value (List : in Counter_Stat_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Counter_Stat_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Load the statistics information.
overriding
procedure Load (List : in out Counter_Stat_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Create the Blog_Stat_Bean bean instance.
function Create_Counter_Stat_Bean (Module : in AWA.Counters.Modules.Counter_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access;
end AWA.Counters.Beans;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 9 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "SSOCsoft/Log_Reporter",
"max_stars_repo_path": "src/ini.ads",
"provenance": "train-00000-of-00001.jsonl.gz:10"
}
|
starcoder
|
With
Ada.Streams,
Ada.Strings.Less_Case_Insensitive,
Ada.Strings.Equal_Case_Insensitive,
Ada.Containers.Indefinite_Ordered_Maps;
Package INI with Preelaborate, Elaborate_Body is
Type Value_Type is ( vt_String, vt_Float, vt_Integer, vt_Boolean );
Type Instance(Convert : Boolean) is private;
Function Exists( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Boolean;
-- Return the type of the associated value.
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Value_Type
with Pre => Exists(Object, Key, Section);
-- Return the value associated with the key in the indicated section.
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return String
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Float
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Integer
with Pre => Exists(Object, Key, Section);
Function Value( Object : in Instance;
Key : in String;
Section: in String:= ""
) return Boolean
with Pre => Exists(Object, Key, Section);
-- Associates a value with the given key in the indicated section.
Procedure Value( Object : in out Instance;
Key : in String;
Value : in String;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Float;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Integer;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
Procedure Value( Object : in out Instance;
Key : in String;
Value : in Boolean;
Section: in String:= ""
)
with Post => Exists(Object, Key, Section);
-- This value sets the Convert discriminant for the object that is generated
-- by the 'Input attribute.
Default_Conversion : Boolean := False;
Empty : Constant Instance;
Private
Type Value_Object( Kind : Value_Type; Length : Natural ) ;
Function "ABS"( Object : Value_Object ) return String;
Function "="(Left, Right : Value_Object) return Boolean;
Package Object_Package is
procedure Value_Output(
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Value_Object
) is null;
function Value_Input(
Stream : not null access Ada.Streams.Root_Stream_Type'Class
) return Value_Object;
End Object_Package;
Type Value_Object( Kind : Value_Type; Length : Natural ) is record
case Kind is
when vt_String => String_Value : String(1..Length):= (Others=>' ');
when vt_Float => Float_Value : Float := 0.0;
when vt_Integer => Integer_Value: Integer := 0;
when vt_Boolean => Boolean_Value: Boolean := False;
end case;
end record;
-- with Input => Object_Package.Value_Input,
-- Output => Object_Package.Value_Output;
Package KEY_VALUE_MAP is new Ada.Containers.Indefinite_Ordered_Maps(
-- "=" => ,
"<" => Ada.Strings.Less_Case_Insensitive,
Key_Type => String,
Element_Type => Value_Object
);
Function "="(Left, Right : KEY_VALUE_MAP.Map) return Boolean;
Package KEY_SECTION_MAP is new Ada.Containers.Indefinite_Ordered_Maps(
"=" => "=",
"<" => Ada.Strings.Less_Case_Insensitive,
Key_Type => String,
Element_Type => KEY_VALUE_MAP.Map
);
procedure INI_Output(
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Instance
);
function INI_Input(
Stream : not null access Ada.Streams.Root_Stream_Type'Class
) return Instance;
Type Instance(Convert : Boolean) is new KEY_SECTION_MAP.Map
with null record
with Input => INI_Input, Output => INI_Output;
overriding
function Copy (Source : Instance) return Instance is
( Source );
Empty : Constant Instance:=
(KEY_SECTION_MAP.map with Convert => True, others => <>);
End INI;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 10 |
{
"extension": "ada",
"max_stars_count": "7",
"max_stars_repo_name": "best08618/asylo",
"max_stars_repo_path": "gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/deferred_const4.ads",
"provenance": "train-00000-of-00001.jsonl.gz:11"
}
|
starcoder
|
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/deferred_const4.ads
with Deferred_Const4_Pkg;
package Deferred_Const4 is
type R1 is tagged record
I1 : Integer;
end record;
type R2 is new R1 with record
I2 : Integer;
end record;
package My_Q is new Deferred_Const4_Pkg (R2);
function F return My_Q.T;
end Deferred_Const4;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 11 |
{
"extension": "ada",
"max_stars_count": "2",
"max_stars_repo_name": "stcarrez/bbox-ada-api",
"max_stars_repo_path": "tools/druss-commands-ping.adb",
"provenance": "train-00000-of-00001.jsonl.gz:12"
}
|
starcoder
|
-----------------------------------------------------------------------
-- druss-commands-devices -- Print information about the devices
-- Copyright (C) 2017, 2018, 2019, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Properties;
with Util.Log.Loggers;
with Bbox.API;
with Druss.Gateways;
with Ada.Strings.Unbounded;
package body Druss.Commands.Ping is
use Ada.Strings.Unbounded;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Commands.Ping");
-- ------------------------------
-- Execute the wifi 'status' command to print the Wifi current status.
-- ------------------------------
procedure Do_Ping (Command : in Command_Type;
Args : in Argument_List'Class;
Selector : in Device_Selector_Type;
Context : in out Context_Type) is
pragma Unreferenced (Command, Args);
procedure Do_Ping (Gateway : in out Druss.Gateways.Gateway_Type);
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
procedure Do_Ping (Gateway : in out Druss.Gateways.Gateway_Type) is
procedure Ping_Device (Manager : in Util.Properties.Manager;
Name : in String);
Box : Bbox.API.Client_Type;
procedure Ping_Device (Manager : in Util.Properties.Manager;
Name : in String) is
Id : constant String := Manager.Get (Name & ".id", "");
begin
case Selector is
when DEVICE_ALL =>
null;
when DEVICE_ACTIVE =>
if Manager.Get (Name & ".active", "") = "0" then
return;
end if;
when DEVICE_INACTIVE =>
if Manager.Get (Name & ".active", "") = "1" then
return;
end if;
end case;
Log.Info ("Ping command on {0}", Manager.Get (Name & ".ipaddress", ""));
Box.Post ("hosts/" & Id, "action=ping");
end Ping_Device;
begin
if Ada.Strings.Unbounded.Length (Gateway.Passwd) = 0 then
return;
end if;
Gateway.Refresh;
Box.Set_Server (To_String (Gateway.Ip));
Box.Login (To_String (Gateway.Passwd));
Bbox.API.Iterate (Gateway.Hosts, "hosts.list", Ping_Device'Access);
end Do_Ping;
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type) is
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String);
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String) is
Link : constant String := Manager.Get (Name & ".link", "");
begin
if Manager.Get (Name & ".active", "") = "0" then
return;
end if;
Console.Start_Row;
Console.Print_Field (F_BBOX_IP_ADDR, Gateway.Ip);
Console.Print_Field (F_IP_ADDR, Manager.Get (Name & ".ipaddress", ""));
Console.Print_Field (F_HOSTNAME, Manager.Get (Name & ".hostname", ""));
Print_Perf (Console, F_ACTIVE, Manager.Get (Name & ".ping.average", ""));
if Link = "Ethernet" then
Console.Print_Field (F_LINK, Link & " port "
& Manager.Get (Name & ".ethernet.logicalport", ""));
else
Console.Print_Field (F_LINK, Link & " RSSI "
& Manager.Get (Name & ".wireless.rssi0", ""));
end if;
Console.End_Row;
end Print_Device;
begin
Gateway.Refresh;
Bbox.API.Iterate (Gateway.Hosts, "hosts.list", Print_Device'Access);
end Box_Status;
begin
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Do_Ping'Access);
delay 5.0;
Console.Start_Title;
Console.Print_Title (F_BBOX_IP_ADDR, "Bbox IP", 16);
Console.Print_Title (F_IP_ADDR, "Device IP", 16);
Console.Print_Title (F_HOSTNAME, "Hostname", 28);
Console.Print_Title (F_ACTIVE, "Ping", 15);
Console.Print_Title (F_LINK, "Link", 18);
Console.End_Title;
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Box_Status'Access);
end Do_Ping;
-- ------------------------------
-- Execute a ping from the gateway to each device.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
begin
if Args.Get_Count > 1 then
Context.Console.Notice (N_USAGE, "Too many arguments to the command");
Druss.Commands.Driver.Usage (Args, Context);
elsif Args.Get_Count = 0 then
Command.Do_Ping (Args, DEVICE_ALL, Context);
elsif Args.Get_Argument (1) = "all" then
Command.Do_Ping (Args, DEVICE_ALL, Context);
elsif Args.Get_Argument (1) = "active" then
Command.Do_Ping (Args, DEVICE_ACTIVE, Context);
elsif Args.Get_Argument (1) = "inactive" then
Command.Do_Ping (Args, DEVICE_INACTIVE, Context);
else
Context.Console.Notice (N_USAGE, "Invalid argument: " & Args.Get_Argument (1));
Druss.Commands.Driver.Usage (Args, Context);
end if;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
pragma Unreferenced (Command);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
begin
Console.Notice (N_HELP, "ping: Ask the Bbox to ping the devices");
Console.Notice (N_HELP, "Usage: ping [all | active | inactive]");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " Ask the Bbox to ping the devices. By default it will ping");
Console.Notice (N_HELP, " all the devices that have been discovered by the Bbox.");
Console.Notice (N_HELP, " The command will wait 5 seconds and it will list the active");
Console.Notice (N_HELP, " devices with their ping performance.");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " all Ping all the devices");
Console.Notice (N_HELP, " active Ping the active devices only");
Console.Notice (N_HELP, " inative Ping the inactive devices only");
end Help;
end Druss.Commands.Ping;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 12 |
{
"extension": "ada",
"max_stars_count": "3",
"max_stars_repo_name": "Fabien-Chouteau/AGATE",
"max_stars_repo_path": "src/armvx-m/agate-scheduler-context_switch.adb",
"provenance": "train-00000-of-00001.jsonl.gz:13"
}
|
starcoder
|
<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2018, <NAME> --
-- --
-- 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 System.Machine_Code; use System.Machine_Code;
with Cortex_M_SVD.SCB; use Cortex_M_SVD.SCB;
with AGATE.Traces;
with AGATE.Arch.ArmvX_m; use AGATE.Arch.ArmvX_m;
package body AGATE.Scheduler.Context_Switch is
procedure Context_Switch_Handler;
pragma Machine_Attribute (Context_Switch_Handler, "naked");
pragma Export (C, Context_Switch_Handler, "PendSV_Handler");
------------
-- Switch --
------------
procedure Switch is
begin
-- Trigger PendSV
SCB_Periph.ICSR.PENDSVSET := True;
end Switch;
----------------------------
-- Context_Switch_Handler --
----------------------------
procedure Context_Switch_Handler is
begin
Asm (Template =>
"push {lr}" & ASCII.LF &
"bl current_task_context" & ASCII.LF &
"stm r0, {r4-r12}", -- Save extra context
Volatile => True);
SCB_Periph.ICSR.PENDSVCLR := True;
Running_Task.Stack_Pointer := PSP;
Set_PSP (Ready_Tasks.Stack_Pointer);
Traces.Context_Switch (Task_ID (Running_Task),
Task_ID (Ready_Tasks));
Running_Task := Ready_Tasks;
Running_Task.Status := Running;
Traces.Running (Current_Task);
Asm (Template =>
"bl current_task_context" & ASCII.LF &
"ldm r0, {r4-r12}" & ASCII.LF & -- Load extra context
"pop {pc}",
Volatile => True);
end Context_Switch_Handler;
end AGATE.Scheduler.Context_Switch;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 13 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "pat-rogers/OpenUxAS",
"max_stars_repo_path": "src/ada/src/afrl-impact-impactautomationrequest-spark_boundary.ads",
"provenance": "train-00000-of-00001.jsonl.gz:14"
}
|
starcoder
|
with Common_Formal_Containers; use Common_Formal_Containers;
package afrl.impact.ImpactAutomationRequest.SPARK_Boundary with SPARK_Mode is
pragma Annotate (GNATprove, Terminating, SPARK_Boundary);
function Get_EntityList_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64_Vect
with Global => null;
function Get_OperatingRegion_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64
with Global => null;
function Get_TaskList_From_TrialRequest
(Request : ImpactAutomationRequest) return Int64_Vect
with Global => null;
end afrl.impact.ImpactAutomationRequest.SPARK_Boundary;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 14 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "RyanMcCarl/.emacs.d",
"max_stars_repo_path": "archive/test/manual/etags/ada-src/2ataspri.ads",
"provenance": "train-00000-of-00001.jsonl.gz:15"
}
|
starcoder
|
<reponame>RyanMcCarl/.emacs.d
------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- $Revision: 1.1 $ --
-- --
-- Copyright (C) 1991,1992,1993,1994,1995,1996 Florida State University --
-- --
-- GNARL 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 2, or (at your option) any later ver- --
-- sion. GNARL 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 GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Interfaces.C;
-- Used for Size_t;
with Interfaces.C.Pthreads;
-- Used for, size_t,
-- pthread_mutex_t,
-- pthread_cond_t,
-- pthread_t
with Interfaces.C.POSIX_RTE;
-- Used for, Signal,
-- siginfo_ptr,
with System.Task_Clock;
-- Used for, Stimespec
with Unchecked_Conversion;
pragma Elaborate_All (Interfaces.C.Pthreads);
with System.Task_Info;
package System.Task_Primitives is
-- Low level Task size and state definition
type LL_Task_Procedure_Access is access procedure (Arg : System.Address);
type Pre_Call_State is new System.Address;
type Task_Storage_Size is new Interfaces.C.size_t;
type Machine_Exceptions is new Interfaces.C.POSIX_RTE.Signal;
type Error_Information is new Interfaces.C.POSIX_RTE.siginfo_ptr;
type Lock is private;
type Condition_Variable is private;
-- The above types should both be limited. They are not due to a hack in
-- ATCB allocation which allocates a block of the correct size and then
-- assigns an initialized ATCB to it. This won't work with limited types.
-- When allocation is done with new, these can become limited once again.
-- ???
type Task_Control_Block is record
LL_Entry_Point : LL_Task_Procedure_Access;
LL_Arg : System.Address;
Thread : aliased Interfaces.C.Pthreads.pthread_t;
Stack_Size : Task_Storage_Size;
Stack_Limit : System.Address;
end record;
type TCB_Ptr is access all Task_Control_Block;
-- Task ATCB related and variables.
function Address_To_TCB_Ptr is new
Unchecked_Conversion (System.Address, TCB_Ptr);
procedure Initialize_LL_Tasks (T : TCB_Ptr);
-- Initialize GNULLI. T points to the Task Control Block that should
-- be initialized for use by the environment task.
function Self return TCB_Ptr;
-- Return a pointer to the Task Control Block of the calling task.
procedure Initialize_Lock (Prio : System.Any_Priority; L : in out Lock);
-- Initialize a lock object. Prio is the ceiling priority associated
-- with the lock.
procedure Finalize_Lock (L : in out Lock);
-- Finalize a lock object, freeing any resources allocated by the
-- corresponding Initialize_Lock.
procedure Write_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
pragma Inline (Write_Lock);
-- Lock a lock object for write access to a critical section. After
-- this operation returns, the calling task owns the lock, and
-- no other Write_Lock or Read_Lock operation on the same object will
-- return the owner executes an Unlock operation on the same object.
procedure Read_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
pragma Inline (Read_Lock);
-- Lock a lock object for read access to a critical section. After
-- this operation returns, the calling task owns the lock, and
-- no other Write_Lock operation on the same object will return until
-- the owner(s) execute Unlock operation(s) on the same object.
-- A Read_Lock to an owned lock object may return while the lock is
-- still owned, though an implementation may also implement
-- Read_Lock to have the same semantics.
procedure Unlock (L : in out Lock);
pragma Inline (Unlock);
-- Unlock a locked lock object. The results are undefined if the
-- calling task does not own the lock. Lock/Unlock operations must
-- be nested, that is, the argument to Unlock must be the object
-- most recently locked.
procedure Initialize_Cond (Cond : in out Condition_Variable);
-- Initialize a condition variable object.
procedure Finalize_Cond (Cond : in out Condition_Variable);
-- Finalize a condition variable object, recovering any resources
-- allocated for it by Initialize_Cond.
procedure Cond_Wait (Cond : in out Condition_Variable; L : in out Lock);
pragma Inline (Cond_Wait);
-- Wait on a condition variable. The mutex object L is unlocked
-- atomically, such that another task that is able to lock the mutex
-- can be assured that the wait has actually commenced, and that
-- a Cond_Signal operation will cause the waiting task to become
-- eligible for execution once again. Before Cond_Wait returns,
-- the waiting task will again lock the mutex. The waiting task may become
-- eligible for execution at any time, but will become eligible for
-- execution when a Cond_Signal operation is performed on the
-- same condition variable object. The effect of more than one
-- task waiting on the same condition variable is unspecified.
procedure Cond_Timed_Wait
(Cond : in out Condition_Variable;
L : in out Lock; Abs_Time : System.Task_Clock.Stimespec;
Timed_Out : out Boolean);
pragma Inline (Cond_Timed_Wait);
-- Wait on a condition variable, as for Cond_Wait, above. In addition,
-- the waiting task will become eligible for execution again
-- when the absolute time specified by Timed_Out arrives.
procedure Cond_Signal (Cond : in out Condition_Variable);
pragma Inline (Cond_Signal);
-- Wake up a task waiting on the condition variable object specified
-- by Cond, making it eligible for execution once again.
procedure Set_Priority (T : TCB_Ptr; Prio : System.Any_Priority);
pragma Inline (Set_Priority);
-- Set the priority of the task specified by T to P.
procedure Set_Own_Priority (Prio : System.Any_Priority);
pragma Inline (Set_Own_Priority);
-- Set the priority of the calling task to P.
function Get_Priority (T : TCB_Ptr) return System.Any_Priority;
pragma Inline (Get_Priority);
-- Return the priority of the task specified by T.
function Get_Own_Priority return System.Any_Priority;
pragma Inline (Get_Own_Priority);
-- Return the priority of the calling task.
procedure Create_LL_Task
(Priority : System.Any_Priority;
Stack_Size : Task_Storage_Size;
Task_Info : System.Task_Info.Task_Info_Type;
LL_Entry_Point : LL_Task_Procedure_Access;
Arg : System.Address;
T : TCB_Ptr);
-- Create a new low-level task with priority Priority. A new thread
-- of control is created with a stack size of at least Stack_Size,
-- and the procedure LL_Entry_Point is called with the argument Arg
-- from this new thread of control. The Task Control Block pointed
-- to by T is initialized to refer to this new task.
procedure Exit_LL_Task;
-- Exit a low-level task. The resources allocated for the task
-- by Create_LL_Task are recovered. The task no longer executes, and
-- the effects of further operations on task are unspecified.
procedure Abort_Task (T : TCB_Ptr);
-- Abort the task specified by T (the target task). This causes
-- the target task to asynchronously execute the handler procedure
-- installed by the target task using Install_Abort_Handler. The
-- effect of this operation is unspecified if there is no abort
-- handler procedure for the target task.
procedure Test_Abort;
-- ??? Obsolete? This is intended to allow implementation of
-- abortion and ATC in the absence of an asynchronous Abort_Task,
-- but I think that we decided that GNARL can handle this on
-- its own by making sure that there is an Undefer_Abortion at
-- every abortion synchronization point.
type Abort_Handler_Pointer is access procedure (Context : Pre_Call_State);
procedure Install_Abort_Handler (Handler : Abort_Handler_Pointer);
-- Install an abort handler procedure. This procedure is called
-- asynchronously by the calling task whenever a call to Abort_Task
-- specifies the calling task as the target. If the abort handler
-- procedure is asynchronously executed during a GNULLI operation
-- and then calls some other GNULLI operation, the effect is unspecified.
procedure Install_Error_Handler (Handler : System.Address);
-- Install an error handler for the calling task. The handler will
-- be called synchronously if an error is encountered during the
-- execution of the calling task.
procedure LL_Assert (B : Boolean; M : String);
-- If B is False, print the string M to the console and halt the
-- program.
Task_Wrapper_Frame : constant Integer := 72;
-- This is the size of the frame for the Pthread_Wrapper procedure.
type Proc is access procedure (Addr : System.Address);
-- Test and Set support
type TAS_Cell is private;
-- On some systems we can not assume that an arbitrary memory location
-- can be used in an atomic test and set instruction (e.g. on some
-- multiprocessor machines, only memory regions are cache interlocked).
-- TAS_Cell is private to facilitate adaption to a variety of
-- implementations.
procedure Initialize_TAS_Cell (Cell : out TAS_Cell);
pragma Inline (Initialize_TAS_Cell);
-- Initialize a Test And Set Cell. On some targets this will allocate
-- a system-level lock object from a special pool. For most systems,
-- this is a nop.
procedure Finalize_TAS_Cell (Cell : in out TAS_Cell);
pragma Inline (Finalize_TAS_Cell);
-- Finalize a Test and Set cell, freeing any resources allocated by the
-- corresponding Initialize_TAS_Cell.
procedure Clear (Cell : in out TAS_Cell);
pragma Inline (Clear);
-- Set the state of the named TAS_Cell such that a subsequent call to
-- Is_Set will return False. This operation must be atomic with
-- respect to the Is_Set and Test_And_Set operations for the same
-- cell.
procedure Test_And_Set (Cell : in out TAS_Cell; Result : out Boolean);
pragma Inline (Test_And_Set);
-- Modify the state of the named TAS_Cell such that a subsequent call
-- to Is_Set will return True. Result is set to True if Is_Set
-- was False prior to the call, False otherwise. This operation must
-- be atomic with respect to the Clear and Is_Set operations for the
-- same cell.
function Is_Set (Cell : in TAS_Cell) return Boolean;
pragma Inline (Is_Set);
-- Returns the current value of the named TAS_Cell. This operation
-- must be atomic with respect to the Clear and Test_And_Set operations
-- for the same cell.
private
type Lock is
record
mutex : aliased Interfaces.C.Pthreads.pthread_mutex_t;
end record;
type Condition_Variable is
record
CV : aliased Interfaces.C.Pthreads.pthread_cond_t;
end record;
type TAS_Cell is
record
Value : aliased Interfaces.C.unsigned := 0;
end record;
end System.Task_Primitives;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 15 |
{
"extension": "ada",
"max_stars_count": "1",
"max_stars_repo_name": "zrmyers/VulkanAda",
"max_stars_repo_path": "src/vulkan-math/vulkan-math-geometry.ads",
"provenance": "train-00000-of-00001.jsonl.gz:16"
}
|
starcoder
|
--------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 <NAME>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Vulkan.Math.GenFType;
with Vulkan.Math.GenDType;
with Vulkan.Math.Vec3;
with Vulkan.Math.Dvec3;
use Vulkan.Math.GenFType;
use Vulkan.Math.GenDType;
use Vulkan.Math.Vec3;
use Vulkan.Math.Dvec3;
--------------------------------------------------------------------------------
--< @group Vulkan Math Functions
--------------------------------------------------------------------------------
--< @summary
--< This package provides GLSL Geometry Built-in functions.
--<
--< @description
--< All geometry functions operate on vectors as objects.
--------------------------------------------------------------------------------
package Vulkan.Math.Geometry is
pragma Preelaborate;
pragma Pure;
----------------------------------------------------------------------------
--< @summary
--< Calculate the magnitude of the vector.
--<
--< @description
--< Calculate the magnitude of the GenFType vector, using the formula:
--<
--< Magnitude = sqrt(sum(x0^2, ..., xn^2))
--<
--< @param x
--< The vector to determine the magnitude for.
--<
--< @return
--< The magnitude of the vector.
----------------------------------------------------------------------------
function Mag (x : in Vkm_GenFType) return Vkm_Float;
----------------------------------------------------------------------------
--< @summary
--< Calculate the magnitude of the vector.
--<
--< @description
--< Calculate the magnitude of the Vkm_GenDType vector, using the formula:
--<
--< Magnitude = sqrt(sum(x0^2, ..., xn^2))
--<
--< @param x
--< The vector to determine the magnitude for.
--<
--< @return
--< The magnitude of the vector.
----------------------------------------------------------------------------
function Mag (x : in Vkm_GenDType) return Vkm_Double;
----------------------------------------------------------------------------
--< @summary
--< Calculate the distance between two points, p0 and p1.
--<
--< @description
--< Calculate the distance between two GenFType vectors representing points p0
--< and p1, using the formula:
--<
--< Distance = Magnitude(p0 - p1)
--<
--< @param p0
--< A vector which represents the first point.
--<
--< @param p1
--< A vector which represents the seconds point.
--<
--< @return
--< The distance between the two points.
----------------------------------------------------------------------------
function Distance (p0, p1 : in Vkm_GenFType) return Vkm_Float is
(Mag(p0 - p1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the distance between two points, p0 and p1.
--<
--< @description
--< Calculate the distance between two GenDType vectors representing points p0
--< and p1, using the formula:
--<
--< Distance = Magnitude(p0 - p1)
--<
--< @param p0
--< A vector which represents the first point.
--<
--< @param p1
--< A vector which represents the seconds point.
--<
--< @return
--< The distance between the two points.
----------------------------------------------------------------------------
function Distance (p0, p1 : in Vkm_GenDType) return Vkm_Double is
(Mag(p0 - p1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the dot product between two vectors.
--<
--< @description
--< Calculate the dot product between two GenFType vectors.
--<
--< x dot y =
--< \ [x1 ... xN] . | y1 | = x1*y1 + ... xN * yN
--< \ | ... |
--< \ | yN |
--<
--< @param x
--< The left vector in the dot product operation.
--<
--< @param y
--< The right vector in the dot product operation.
--<
--<
--< @return The dot product of the two vectors.
----------------------------------------------------------------------------
function Dot (x, y : in Vkm_GenFType) return Vkm_Float;
----------------------------------------------------------------------------
--< @summary
--< Calculate the dot product between two vectors.
--<
--< @description
--< Calculate the dot product between the two GenDType vectors.
--<
--< x dot y =
--< \ [x1 ... xN] . | y1 | = x1*y1 + ... xN * yN
--< \ | ... |
--< \ | yN |
--<
--< @param x
--< The left vector in the dot product operation.
--<
--< @param y
--< The right vector in the dot product operation.
--<
--< @return
--< The dot product of the two vectors.
----------------------------------------------------------------------------
function Dot (x, y : in Vkm_GenDType) return Vkm_Double;
----------------------------------------------------------------------------
--< @summary
--< Calculate the cross product between two 3 dimmensional vectors.
--<
--< @description
--< Calculate the cross product between two 3 dimmensional GenFType vectors.
--<
--< x cross y =
--< \ | i j k | = i | x1 x2 | -j | x0 x2 | +k | x0 x1 | = | +(x1*y2 - x2*y1) |
--< \ | x0 x1 x2 | | y1 y2 | | y0 y2 | | y0 y1 | | -(x0*y2 - x2*y1) |
--< \ | y0 y1 y2 | | +(x0*y1 - x1*y0) |
--<
--< @param x
--< The left vector in the cross product operation.
--<
--< @param y
--< The right vector in the cross product operation.
--<
--< @return
--< The cross product of the two vectors.
----------------------------------------------------------------------------
function Cross (x, y : in Vkm_Vec3 ) return Vkm_Vec3;
----------------------------------------------------------------------------
--< @summary
--< Calculate the cross product between two 3 dimmensional vectors.
--<
--< @description
--< Calculate the cross product between two 3 dimmensional GenDType vectors.
--<
--< x cross y =
--< \ | i j k | = i | x1 x2 | -j | x0 x2 | +k | x0 x1 | = | +(x1*y2 - x2*y1) |
--< \ | x0 x1 x2 | | y1 y2 | | y0 y2 | | y0 y1 | | -(x0*y2 - x2*y1) |
--< \ | y0 y1 y2 | | +(x0*y1 - x1*y0) |
--<
--< @param x
--< The left vector in the cross product operation.
--<
--< @param y
--< The right vector in the cross product operation.
--<
--< @return
--< The cross product of the two vectors.
----------------------------------------------------------------------------
function Cross (x, y : in Vkm_Dvec3) return Vkm_Dvec3;
----------------------------------------------------------------------------
--< @summary
--< Normalize a vector.
--<
--< @description
--< Normalize the GenFType vector so that it has a magnitude of 1.
--<
--< @param x
--< The vector to normalize.
--<
--< @return
--< The normalized vector.
----------------------------------------------------------------------------
function Normalize(x : in Vkm_GenFType) return Vkm_GenFType is
(x / Mag(x)) with inline;
----------------------------------------------------------------------------
--< @summary
--< Normalize a vector.
--<
--< @description
--< Normalize the GenDType vector so that it has a magnitude of 1.
--<
--< @param x
--< The vector to normalize.
--<
--< @return
--< The normalized vector.
----------------------------------------------------------------------------
function Normalize(x : in Vkm_GenDType) return Vkm_GenDType is
(x / Mag(x)) with inline;
----------------------------------------------------------------------------
--< @summary
--< Force a normal vector to face an incident vector.
--<
--< @description
--< Return a normal vector N as-is if an incident vector I points in the opposite
--< direction of a reference normal vector, Nref. Otherwise, if I is pointing
--< in the same direction as the reference normal, flip the normal vector N.
--<
--< - If Nref dot I is negative, these vectors are not facing the same direction.
--< - If Nref dot I is positive, these vectors are facing in the same direction.
--< - If Nref dot I is zero, these two vectors are orthogonal to each other.
--<
--< @param n
--< The normal vector N
--<
--< @param i
--< The incident vector I
--<
--< @param nref
--< The reference normal vector Nref
--<
--< @return
--< If I dot Nref < 0, return N. Otherwise return -N.
----------------------------------------------------------------------------
function Face_Forward(n, i, nref : in Vkm_GenFType) return Vkm_GenFType is
(if Dot(nref,i) < 0.0 then n else -n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Force a normal vector to face an incident vector.
--<
--< @description
--< Return a normal vector N as-is if an incident vector I points in the opposite
--< direction of a reference normal vector, Nref. Otherwise, if I is pointing
--< in the same direction as the reference normal, flip the normal vector N.
--<
--< - If Nref dot I is negative, these vectors are not facing the same direction.
--< - If Nref dot I is positive, these vectors are facing in the same direction.
--< - If Nref dot I is zero, these two vectors are orthogonal to each other.
--<
--< @param n
--< The normal vector N
--<
--< @param i
--< The incident vector I
--<
--< @param nref
--< The reference normal vector Nref
--<
--< @return
--< If I dot Nref < 0, return N. Otherwise return -N.
----------------------------------------------------------------------------
function Face_Forward(n, i, nref : in Vkm_GenDType) return Vkm_GenDType is
(if Dot(nref,i) < 0.0 then n else -n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the reflection of an incident vector using the normal vector
--< for the surface.
--<
--< @description
--< For the incident vector I and surface orientation N, returns the reflection
--< direction:
--<
--< I - 2 * ( N dot I ) * N.
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The normal vector N. N should already be normalized.
--<
--< @return The reflection direction.
----------------------------------------------------------------------------
function Reflect(i, n : in Vkm_GenFType) return Vkm_GenFType is
(i - 2.0 * Dot(n, i) * n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the reflection of an incident vector using the normal vector
--< for the surface.
--<
--< @description
--< For the incident vector I and surface orientation N, returns the reflection
--< direction:
--<
--< I - 2 * ( N dot I ) * N.
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The normal vector N. N should already be normalized.
--<
--< @return The reflection direction.
----------------------------------------------------------------------------
function Reflect(i, n : in Vkm_GenDType) return Vkm_GenDType is
(i - 2.0 * Dot(n, i) * n) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Calculate the refraction vector for the incident vector I travelling
--< through the surface with normal N and a ratio of refraction eta.
--<
--< @description
--< For the indident vector I and surface normal N, and the ratio of refraction
--< eta, calculate the refraction vector.
--<
--< k = 1.0 - eta^2 (1.0 - dot(N,I)^2)
--< If k < 0, the result is a vector of all zeros.
--< Else , the result is: eta*I - (eta*dot(N,I) + sqrt(k))*N
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The surface normal vector N.
--<
--< @param eta
--< The indices of refraction.
--<
--< @return
--< The refraction vector.
----------------------------------------------------------------------------
function Refract(i, n : in Vkm_GenFType;
eta : in Vkm_Float ) return Vkm_GenFType;
----------------------------------------------------------------------------
--< @summary
--< Calculate the refraction vector for the incident vector I travelling
--< through the surface with normal N and a ratio of refraction eta.
--<
--< @description
--< For the indident vector I and surface normal N, and the ratio of refraction
--< eta, calculate the refraction vector.
--<
--< k = 1.0 - eta^2 (1.0 - dot(N,I)^2)
--< If k < 0, the result is a vector of all zeros.
--< Else , the result is: eta*I - (eta*dot(N,I) + sqrt(k))*N
--<
--< @param i
--< The incident vector I.
--<
--< @param n
--< The surface normal vector N.
--<
--< @param eta
--< The indices of refraction.
--<
--< @return
--< The refraction vector.
----------------------------------------------------------------------------
function Refract(i, n : in Vkm_GenDType;
eta : in Vkm_Double ) return Vkm_GenDType;
end Vulkan.Math.Geometry;
|
2023-09-08T23:13:54.504Z
|
2023-09-08T23:13:54.504Z
| 16 |
{
"extension": "ada",
"max_stars_count": "0",
"max_stars_repo_name": "csb6/libtcod-ada",
"max_stars_repo_path": "src/generated/color_h.ads",
"provenance": "train-00000-of-00001.jsonl.gz:17"
}
|
starcoder
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;
package color_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, Jice and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of 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.
--
--*
-- * A three channel color struct.
--
type TCOD_ColorRGB is record
r : aliased unsigned_char; -- color.h:47
g : aliased unsigned_char; -- color.h:48
b : aliased unsigned_char; -- color.h:49
end record
with Convention => C_Pass_By_Copy; -- color.h:42
subtype TCOD_color_t is TCOD_ColorRGB; -- color.h:51
--*
-- * A four channel color struct.
--
type TCOD_ColorRGBA is record
r : aliased unsigned_char; -- color.h:63
g : aliased unsigned_char; -- color.h:64
b : aliased unsigned_char; -- color.h:65
a : aliased unsigned_char; -- color.h:66
end record
with Convention => C_Pass_By_Copy; -- color.h:56
-- constructors
function TCOD_color_RGB
(r : unsigned_char;
g : unsigned_char;
b : unsigned_char) return TCOD_color_t -- color.h:73
with Import => True,
Convention => C,
External_Name => "TCOD_color_RGB";
function TCOD_color_HSV
(hue : float;
saturation : float;
value : float) return TCOD_color_t -- color.h:74
with Import => True,
Convention => C,
External_Name => "TCOD_color_HSV";
-- basic operations
function TCOD_color_equals (c1 : TCOD_color_t; c2 : TCOD_color_t) return Extensions.bool -- color.h:76
with Import => True,
Convention => C,
External_Name => "TCOD_color_equals";
function TCOD_color_add (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:77
with Import => True,
Convention => C,
External_Name => "TCOD_color_add";
function TCOD_color_subtract (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:78
with Import => True,
Convention => C,
External_Name => "TCOD_color_subtract";
function TCOD_color_multiply (c1 : TCOD_color_t; c2 : TCOD_color_t) return TCOD_color_t -- color.h:79
with Import => True,
Convention => C,
External_Name => "TCOD_color_multiply";
function TCOD_color_multiply_scalar (c1 : TCOD_color_t; value : float) return TCOD_color_t -- color.h:80
with Import => True,
Convention => C,
External_Name => "TCOD_color_multiply_scalar";
function TCOD_color_lerp
(c1 : TCOD_color_t;
c2 : TCOD_color_t;
coef : float) return TCOD_color_t -- color.h:81
with Import => True,
Convention => C,
External_Name => "TCOD_color_lerp";
--*
-- * Blend `src` into `dst` as an alpha blending operation.
-- * \rst
-- * .. versionadded:: 1.16
-- * \endrst
--
procedure TCOD_color_alpha_blend (dst : access TCOD_ColorRGBA; src : access constant TCOD_ColorRGBA) -- color.h:88
with Import => True,
Convention => C,
External_Name => "TCOD_color_alpha_blend";
-- HSV transformations
procedure TCOD_color_set_HSV
(color : access TCOD_color_t;
hue : float;
saturation : float;
value : float) -- color.h:91
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_HSV";
procedure TCOD_color_get_HSV
(color : TCOD_color_t;
hue : access float;
saturation : access float;
value : access float) -- color.h:92
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_HSV";
function TCOD_color_get_hue (color : TCOD_color_t) return float -- color.h:93
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_hue";
procedure TCOD_color_set_hue (color : access TCOD_color_t; hue : float) -- color.h:94
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_hue";
function TCOD_color_get_saturation (color : TCOD_color_t) return float -- color.h:95
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_saturation";
procedure TCOD_color_set_saturation (color : access TCOD_color_t; saturation : float) -- color.h:96
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_saturation";
function TCOD_color_get_value (color : TCOD_color_t) return float -- color.h:97
with Import => True,
Convention => C,
External_Name => "TCOD_color_get_value";
procedure TCOD_color_set_value (color : access TCOD_color_t; value : float) -- color.h:98
with Import => True,
Convention => C,
External_Name => "TCOD_color_set_value";
procedure TCOD_color_shift_hue (color : access TCOD_color_t; shift : float) -- color.h:99
with Import => True,
Convention => C,
External_Name => "TCOD_color_shift_hue";
procedure TCOD_color_scale_HSV
(color : access TCOD_color_t;
saturation_coef : float;
value_coef : float) -- color.h:100
with Import => True,
Convention => C,
External_Name => "TCOD_color_scale_HSV";
-- color map
procedure TCOD_color_gen_map
(map : access TCOD_color_t;
nb_key : int;
key_color : access constant TCOD_color_t;
key_index : access int) -- color.h:102
with Import => True,
Convention => C,
External_Name => "TCOD_color_gen_map";
end color_h;
|
End of preview. Expand
in Data Studio
Starcoder Dataset (The Stack - Sub-sampled)
This dataset is derived from the "Starcoder" version of The Stack, a 6.4 TB dataset of permissively licensed source code in 384 programming languages.
This repository contains the data organized into subsets, one for each programming language or data type.
How to Use
You can load any language-specific subset of the data using the datasets library. You must specify the name parameter with the desired language.
For example, to load the Python or Java subsets:
from datasets import load_dataset
# Load the Python subset
python_data = load_dataset("Sam-Shin/starcoder", name="python", split="train")
# Load the C++ subset
cpp_data = load_dataset("Sam-Shin/starcoder", name="cpp", split="train")
# Load the C# subset
csharp_data = load_dataset("Sam-Shin/starcoder", name="c-sharp", split="train")
print(python_data)
- Downloads last month
- 149