repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
micahwelf/FLTK-Ada | Ada | 3,341 | adb |
with
Interfaces.C.Strings,
System;
use type
System.Address;
package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is
procedure hor_value_slider_set_draw_hook
(W, D : in System.Address);
pragma Import (C, hor_value_slider_set_draw_hook, "hor_value_slider_set_draw_hook");
pragma Inline (hor_value_slider_set_draw_hook);
procedure hor_value_slider_set_handle_hook
(W, H : in System.Address);
pragma Import (C, hor_value_slider_set_handle_hook, "hor_value_slider_set_handle_hook");
pragma Inline (hor_value_slider_set_handle_hook);
function new_fl_hor_value_slider
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_hor_value_slider, "new_fl_hor_value_slider");
pragma Inline (new_fl_hor_value_slider);
procedure free_fl_hor_value_slider
(D : in System.Address);
pragma Import (C, free_fl_hor_value_slider, "free_fl_hor_value_slider");
pragma Inline (free_fl_hor_value_slider);
procedure fl_hor_value_slider_draw
(W : in System.Address);
pragma Import (C, fl_hor_value_slider_draw, "fl_hor_value_slider_draw");
pragma Inline (fl_hor_value_slider_draw);
function fl_hor_value_slider_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_hor_value_slider_handle, "fl_hor_value_slider_handle");
pragma Inline (fl_hor_value_slider_handle);
procedure Finalize
(This : in out Hor_Value_Slider) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Hor_Value_Slider'Class
then
free_fl_hor_value_slider (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Value_Slider (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Hor_Value_Slider is
begin
return This : Hor_Value_Slider do
This.Void_Ptr := new_fl_hor_value_slider
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
hor_value_slider_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
hor_value_slider_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Draw
(This : in out Hor_Value_Slider) is
begin
fl_hor_value_slider_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Hor_Value_Slider;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_hor_value_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Valuators.Sliders.Value.Horizontal;
|
docandrew/troodon | Ada | 25,622 | adb | with Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with System;
with System.Address_Image;
with GL;
with GLext;
with Render;
package body Render.Shaders is
type Symbol is (USELESS) with Size => 64;
---------------------------------------------------------------------------
-- detectShaderVersion
---------------------------------------------------------------------------
procedure detectShaderVersion is
use Interfaces.C.Strings;
glVerMajor : aliased GL.GLint;
glVerMinor : aliased GL.GLint;
begin
Ada.Text_IO.Put_Line ("Troodon: (Shaders) Checking OpenGL and GLSL versions.");
-- Check OpenGL version in use. If it's not high enough, we can't even
-- bother detecting the GLSL version
GL.glGetIntegerv (GLext.GL_MAJOR_VERSION, glVerMajor'Access);
GL.glGetIntegerv (GLext.GL_MINOR_VERSION, glVerMinor'Access);
Ada.Text_IO.Put_Line ("Troodon: (Shaders) Detected OpenGL version" & glVerMajor'Image & "." & glVerMinor'Image);
if glVerMajor <= 2 then
raise ShaderException with "Detected ancient version of OpenGL, too old to " &
"run Troodon. Please upgrade your video drivers or Mesa, or turn on direct rendering " &
"by setting the environment variable LIBGL_ALWAYS_INDIRECT to 0";
end if;
declare
slVerChars : Interfaces.C.Strings.chars_ptr := GL.glGetString (GLext.GL_SHADING_LANGUAGE_VERSION);
begin
if slVerChars = Interfaces.C.Strings.Null_Ptr then
raise ShaderException with "Troodon: (Shaders) Unable to detect GL Shader Language version available. " &
"You may need to upgrade your video drivers, upgrade Mesa, or turn on direct rendering " &
"by setting the environment variable LIBGL_ALWAYS_INDIRECT to 0";
end if;
-- Check GLSL version in use
declare
slVerStr : String := Interfaces.C.Strings.Value (slVerChars);
slMajorVer : Natural := Natural'Value (slVerStr(1..1));
slMinorVer : Natural := Natural'Value (slVerStr(3..3));
begin
Ada.Text_IO.Put_Line ("Detected GLSL version " & slVerStr);
-- Need GLSL 1.3 or better
if slMajorVer <= 1 and slMinorVer < 3 then
raise ShaderException with "Your OpenGL version does not support the shader language version Troodon needs. " &
"You may need to upgrade your video drivers, upgrade Mesa, or turn on direct rendering " &
"by setting the environment variable LIBGL_ALWAYS_INDIRECT to 0";
end if;
end;
end;
end detectShaderVersion;
---------------------------------------------------------------------------
-- printShaderErrors
---------------------------------------------------------------------------
procedure printShaderErrors (obj : GL.GLUint) is
logLen : aliased GL.GLint;
begin
if GLext.glIsShader (obj) = GL.GL_TRUE then
GLext.glGetShaderiv (obj, GLext.GL_INFO_LOG_LENGTH, logLen'Access);
elsif GLext.glIsProgram (obj) = GL.GL_TRUE then
GLext.glGetProgramiv (obj, GLext.GL_INFO_LOG_LENGTH, logLen'Access);
else
Ada.Text_IO.Put_Line ("Troodon: attempted to print errors of a non-shader and non-program GL object");
return;
end if;
if logLen = 0 then
raise Program_Error with "Attempted to print shader/program errors, but no info log present.";
end if;
declare
log : Interfaces.C.char_array(1 .. size_t(logLen));
begin
if GLext.glIsShader (obj) = GL.GL_TRUE then
GLext.glGetShaderInfoLog (shader => obj,
bufSize => logLen,
length => null,
infoLog => log);
else
GLext.glGetProgramInfoLog (program => obj,
bufSize => logLen,
length => null,
infoLog => log);
end if;
Ada.Text_IO.Put_Line (Interfaces.C.To_Ada (log));
end;
end printShaderErrors;
---------------------------------------------------------------------------
-- createShaderProgram
-- Given the addresses of vertex shader and fragment shader source code,
-- and their respective sizes, compile and link these shaders into a shader
-- program. Note that until there's a drawable window, this will fail.
---------------------------------------------------------------------------
function createShaderProgram (vertSource : System.Address;
vertSize : Interfaces.C.size_t;
fragSource : System.Address;
fragSize : Interfaces.C.size_t) return GL.GLuint is
use ASCII;
vertShaderChars : aliased constant Interfaces.C.char_array(1..vertSize) with
Import, Address => vertSource;
fragShaderChars : aliased constant Interfaces.C.char_array(1..fragSize) with
Import, Address => fragSource;
-- Just for printing to console
vertShaderStr : String := To_Ada (vertShaderChars, True);
fragShaderStr : String := To_Ada (fragShaderChars, True);
vertShader : GL.GLuint := GLext.glCreateShader (GLext.GL_VERTEX_SHADER);
fragShader : GL.GLuint := GLext.glCreateShader (GLext.GL_FRAGMENT_SHADER);
-- Needed for compatibility w/ glShaderSource
vertShaderArr : GLext.SourceArray := (1 => vertSource);
fragShaderArr : GLext.SourceArray := (1 => fragSource);
glErr : GL.GLuint;
compileStatus : aliased GL.GLint := GL.GL_FALSE;
linkStatus : aliased GL.GLint := GL.GL_FALSE;
prog : GL.GLuint := 0;
begin
-- Ada.Text_IO.Put_Line (" Vert Shader Size: " & vertSize'Image);
-- Ada.Text_IO.Put_Line (" Vert Shader Addr: " & System.Address_Image(vertSource));
-- Ada.Text_IO.Put_Line (" Loaded Vertex Shader: " & LF & vertShaderStr & LF);
-- Ada.Text_IO.Put_Line (" Frag Shader Size: " & fragSize'Image);
-- Ada.Text_IO.Put_Line (" Frag Shader Addr: " & System.Address_Image(fragSource));
-- Ada.Text_IO.Put_Line (" Loaded Fragment Shader: " & LF & fragShaderStr & LF);
-- Set up Font shaders
-- Easier to call multiple times than set up an array of C strings in Ada
GLext.glShaderSource (shader => vertShader,
count => 1,
string => vertShaderArr,
length => null);
GLext.glShaderSource (shader => fragShader,
count => 1,
string => fragShaderArr,
length => null);
-- Compile shaders
Ada.Text_IO.Put_Line (" Compiling Vertex Shader");
GLext.glCompileShader (vertShader);
GLext.glGetShaderiv (vertShader, GLext.GL_COMPILE_STATUS, compileStatus'Access);
if compileStatus /= GL.GL_TRUE then
Ada.Text_IO.Put_Line ("Troodon: vertex shader compile error, status: " & compileStatus'Image);
printShaderErrors (vertShader);
end if;
Ada.Text_IO.Put_Line (" Compiling Fragment Shader");
GLext.glCompileShader (fragShader);
GLext.glGetShaderiv (fragShader, GLext.GL_COMPILE_STATUS, compileStatus'Access);
if compileStatus /= GL.GL_TRUE then
Ada.Text_IO.Put_Line ("Troodon: fragment shader compile error, status: " & compileStatus'Image);
printShaderErrors (fragShader);
end if;
Ada.Text_IO.Put_Line (" Creating Shader Program");
prog := GLext.glCreateProgram;
if prog = 0 then
glErr := GL.glGetError;
return 0;
end if;
-- Attach shaders to program
Ada.Text_IO.Put_Line (" Attaching Shaders");
GLext.glAttachShader (prog, vertShader);
GLext.glAttachShader (prog, fragShader);
-- Link the program
Ada.Text_IO.Put_Line (" Linking Shader Program");
GLext.glLinkProgram (prog);
GLext.glGetProgramiv (prog, GLext.GL_LINK_STATUS, linkStatus'Access);
if linkStatus /= GL.GL_TRUE then
Ada.Text_IO.Put_Line (" Shader link error, status: " & linkStatus'Image);
printShaderErrors (prog);
return 0;
end if;
GLext.glDeleteShader (vertShader);
GLext.glDeleteShader (fragShader);
return prog;
end createShaderProgram;
---------------------------------------------------------------------------
-- initTextShaders
---------------------------------------------------------------------------
procedure initTextShaders is
use ASCII;
use Interfaces.C;
---------------------------------------------------------------------------
-- Text Vertex Shader
---------------------------------------------------------------------------
text_vertex_shader_start : Symbol with Import;
text_vertex_shader_end : Symbol with Import;
text_vertex_shader_size : Symbol with Import;
textVertexShaderSize : Interfaces.C.size_t with
Import, Address => text_vertex_shader_size'Address;
---------------------------------------------------------------------------
-- Text Fragment Shader
---------------------------------------------------------------------------
text_fragment_shader_start : Symbol with Import;
text_fragment_shader_end : Symbol with Import;
text_fragment_shader_size : Symbol with Import;
textFragmentShaderSize : Interfaces.C.size_t with
Import, Address => text_fragment_shader_size'Address;
begin
-- Ada.Text_IO.Put_Line ("text vert shader size: " & textVertexShaderSize'Image);
-- Ada.Text_IO.Put_Line ("text vert shader addr: " & System.Address_Image(text_vertex_shader_start'Address));
-- Ada.Text_IO.Put_Line ("text frag shader size: " & textFragmentShaderSize'Image);
-- Ada.Text_IO.Put_Line ("text frag shader addr: " & System.Address_Image(text_fragment_shader_start'Address));
textShaderProg := createShaderProgram (vertSource => text_vertex_shader_start'Address,
vertSize => textVertexShaderSize,
fragSource => text_fragment_shader_start'Address,
fragSize => textFragmentShaderSize);
if textShaderProg = 0 then
raise ShaderException with "Unable to load text shaders";
end if;
Ada.Text_IO.Put_Line ("Troodon: Loaded Text Shaders");
-- Get the uniform and attribs from our shaders
textAttribCoord := GLext.glGetAttribLocation (program => textShaderProg,
name => Interfaces.C.To_C ("coord"));
textUniformTex := GLext.glGetUniformLocation (program => textShaderProg,
name => Interfaces.C.To_C ("tex"));
textUniformColor := GLext.glGetUniformLocation (program => textShaderProg,
name => Interfaces.C.To_C ("color"));
textUniformOrtho := GLext.glGetUniformLocation (program => textShaderProg,
name => Interfaces.C.To_C ("ortho"));
textUniformAOnly := GLext.glGetUniformLocation (program => textShaderProg,
name => Interfaces.C.To_C ("alphaOnly"));
if textAttribCoord = -1 or
textUniformTex = -1 or
textUniformColor = -1 or
textUniformOrtho = -1 or
textUniformAOnly = -1 then
raise ShaderException with "Unable to get shader variables from text program.";
end if;
end initTextShaders;
---------------------------------------------------------------------------
-- initCircleShaders
---------------------------------------------------------------------------
procedure initCircleShaders is
---------------------------------------------------------------------------
-- Circle Vertex Shader
---------------------------------------------------------------------------
circle_vertex_shader_start : Symbol with Import;
circle_vertex_shader_end : Symbol with Import;
circle_vertex_shader_size : Symbol with Import;
circleVertexShaderSize : Interfaces.C.size_t with
Import, Address => circle_vertex_shader_size'Address;
---------------------------------------------------------------------------
-- Circle Fragment Shader
---------------------------------------------------------------------------
circle_fragment_shader_start : Symbol with Import;
circle_fragment_shader_end : Symbol with Import;
circle_fragment_shader_size : Symbol with Import;
circleFragmentShaderSize : Interfaces.C.size_t with
Import, Address => circle_fragment_shader_size'Address;
begin
circleShaderProg := createShaderProgram (vertSource => circle_vertex_shader_start'Address,
vertSize => circleVertexShaderSize,
fragSource => circle_fragment_shader_start'Address,
fragSize => circleFragmentShaderSize);
if circleShaderProg = 0 then
raise ShaderException with "Unable to load circle shaders";
end if;
Ada.Text_IO.Put_Line("Troodon: Loaded Circle Shaders");
-- Get the uniform and attribs from our shaders
circleAttribCoord := GLext.glGetAttribLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("coord"));
circleUniformColor := GLext.glGetUniformLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("color"));
circleUniformCenter := GLext.glGetUniformLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("center"));
circleUniformRadius := GLext.glGetUniformLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("radius"));
circleUniformOrtho := GLext.glGetUniformLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("ortho"));
circleUniformScrH := GLext.glGetUniformLocation (program => circleShaderProg,
name => Interfaces.C.To_C ("screenHeight"));
if circleAttribCoord = -1 or
circleUniformColor = -1 or
circleUniformCenter = -1 or
circleUniformRadius = -1 or
circleUniformOrtho = -1 or
circleUniformScrH = -1 then
raise ShaderException with "Unable to get shader variables from circle program.";
end if;
end initCircleShaders;
---------------------------------------------------------------------------
-- initLineShaders
---------------------------------------------------------------------------
procedure initLineShaders is
line_vertex_shader_start : Symbol with Import;
line_vertex_shader_end : Symbol with Import;
line_vertex_shader_size : Symbol with Import;
lineVertexShaderSize : Interfaces.C.size_t with
Import, Address => line_vertex_shader_size'Address;
line_fragment_shader_start : Symbol with Import;
line_fragment_shader_end : Symbol with Import;
line_fragment_shader_size : Symbol with Import;
lineFragmentShaderSize : Interfaces.C.size_t with
Import, Address => line_fragment_shader_size'Address;
begin
lineShaderProg := createShaderProgram (vertSource => line_vertex_shader_start'Address,
vertSize => lineVertexShaderSize,
fragSource => line_fragment_shader_start'Address,
fragSize => lineFragmentShaderSize);
if lineShaderProg = 0 then
raise ShaderException with "Unable to load line shaders";
end if;
Ada.Text_IO.Put_Line("Troodon: Loaded Line Shaders");
lineAttribCoord := GLext.glGetAttribLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("coord"));
lineUniformOrtho := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("ortho"));
lineUniformFrom := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("lineFrom"));
lineUniformTo := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("lineTo"));
lineUniformWidth := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("width"));
lineUniformColor := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("color"));
lineUniformScrH := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("screenHeight"));
lineUniformAA := GLext.glGetUniformLocation (program => lineShaderProg,
name => Interfaces.C.To_C ("antiAliased"));
if lineAttribCoord = -1 or
lineUniformOrtho = -1 or
lineUniformFrom = -1 or
lineUniformTo = -1 or
lineUniformWidth = -1 or
lineUniformColor = -1 or
lineUniformScrH = -1 or
lineUniformAA = -1 then
raise ShaderException with "Unable to get shader variables from line program.";
end if;
end initLineShaders;
---------------------------------------------------------------------------
-- initWinShaders
---------------------------------------------------------------------------
procedure initWinShaders is
win_vertex_shader_start : Symbol with Import;
win_vertex_shader_end : Symbol with Import;
win_vertex_shader_size : Symbol with Import;
winVertexShaderSize : Interfaces.C.size_t with
Import, Address => win_vertex_shader_size'Address;
win_fragment_shader_start : Symbol with Import;
win_fragment_shader_end : Symbol with Import;
win_fragment_shader_size : Symbol with Import;
winFragmentShaderSize : Interfaces.C.size_t with
Import, Address => win_fragment_shader_size'Address;
begin
winShaderProg := createShaderProgram (vertSource => win_vertex_shader_start'Address,
vertSize => winVertexShaderSize,
fragSource => win_fragment_shader_start'Address,
fragSize => winFragmentShaderSize);
if winShaderProg = 0 then
raise ShaderException with "Unable to load window shaders";
end if;
Ada.Text_IO.Put_Line("Troodon: Loaded Window Shaders");
winAttribCoord := GLext.glGetAttribLocation (program => winShaderProg,
name => Interfaces.C.To_C ("coord"));
winUniformOrtho := GLext.glGetUniformLocation (program => winShaderProg,
name => Interfaces.C.To_C ("ortho"));
winUniformTex := GLext.glGetUniformLocation (program => winShaderProg,
name => Interfaces.C.To_C ("tex"));
winUniformAlpha := GLext.glGetUniformLocation (program => winShaderProg,
name => Interfaces.C.To_C ("alpha"));
if winAttribCoord = -1 or
winUniformOrtho = -1 or
winUniformTex = -1 or
winUniformAlpha = -1 then
raise ShaderException with "Unable to get shader variables from win program.";
end if;
end initWinShaders;
---------------------------------------------------------------------------
-- initShadowShaders
---------------------------------------------------------------------------
procedure initShadowShaders is
---------------------------------------------------------------------------
-- Shadow Vertex Shader
---------------------------------------------------------------------------
shadow_vertex_shader_start : Symbol with Import;
shadow_vertex_shader_end : Symbol with Import;
shadow_vertex_shader_size : Symbol with Import;
shadowVertexShaderSize : Interfaces.C.size_t with
Import, Address => shadow_vertex_shader_size'Address;
---------------------------------------------------------------------------
-- Shadow Fragment Shader
---------------------------------------------------------------------------
shadow_fragment_shader_start : Symbol with Import;
shadow_fragment_shader_end : Symbol with Import;
shadow_fragment_shader_size : Symbol with Import;
shadowFragmentShaderSize : Interfaces.C.size_t with
Import, Address => shadow_fragment_shader_size'Address;
begin
shadowShaderProg := createShaderProgram (vertSource => shadow_vertex_shader_start'Address,
vertSize => shadowVertexShaderSize,
fragSource => shadow_fragment_shader_start'Address,
fragSize => shadowFragmentShaderSize);
if shadowShaderProg = 0 then
raise ShaderException with "Unable to load shadow shaders";
end if;
Ada.Text_IO.Put_Line("Troodon: Loaded Shadow Shaders");
-- Get the uniform and attribs from our shaders
shadowAttribCoord := GLext.glGetAttribLocation (program => shadowShaderProg,
name => Interfaces.C.To_C ("coord"));
shadowUniformColor := GLext.glGetUniformLocation (program => shadowShaderProg,
name => Interfaces.C.To_C ("color"));
shadowUniformOrtho := GLext.glGetUniformLocation (program => shadowShaderProg,
name => Interfaces.C.To_C ("ortho"));
shadowUniformShadow := GLext.glGetUniformLocation (program => shadowShaderProg,
name => Interfaces.C.To_C ("shadow"));
shadowUniformScreenH := GLext.glGetUniformLocation (program => shadowShaderProg,
name => Interfaces.C.To_C ("screenHeight"));
if shadowAttribCoord = -1 or
shadowUniformColor = -1 or
shadowUniformOrtho = -1 or
shadowUniformShadow = -1 or
shadowUniformScreenH = -1 then
raise ShaderException with "Unable to get shader variables from shadow program.";
end if;
end initShadowShaders;
---------------------------------------------------------------------------
-- start
---------------------------------------------------------------------------
procedure start is
begin
detectShaderVersion;
initTextShaders;
initCircleShaders;
initLineShaders;
initWinShaders;
initShadowShaders;
end start;
---------------------------------------------------------------------------
-- stop
---------------------------------------------------------------------------
procedure stop is
begin
GLext.glDeleteProgram (textShaderProg);
GLext.glDeleteProgram (circleShaderProg);
GLext.glDeleteProgram (lineShaderProg);
GLext.glDeleteProgram (winShaderProg);
GLext.glDeleteProgram (shadowShaderProg);
end stop;
end Render.Shaders; |
zhmu/ananas | Ada | 50 | ads | package Debug3 is
procedure Proc;
end Debug3;
|
reznikmm/matreshka | Ada | 4,440 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis.Statements;
with Properties.Tools;
package body Properties.Statements.While_Loop_Statement is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
Cond : constant Asis.Declaration :=
Asis.Statements.While_Condition (Element);
List : constant Asis.Statement_List :=
Asis.Statements.Loop_Statements (Element);
Text : League.Strings.Universal_String;
Down : League.Strings.Universal_String;
begin
Text.Append ("while (");
Down := Engine.Text.Get_Property (Cond, Name);
Text.Append (Down);
Text.Append ("){");
Down := Engine.Text.Get_Property
(List => List,
Name => Name,
Empty => League.Strings.Empty_Universal_String,
Sum => Properties.Tools.Join'Access);
Text.Append (Down);
Text.Append ("};");
return Text;
end Code;
end Properties.Statements.While_Loop_Statement;
|
Componolit/libsparkcrypto | Ada | 2,917 | ads | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- @author Alexander Senier
-- @date 2019-01-21
--
-- Copyright (C) 2018 Componolit GmbH
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.SHA2_Generic;
with LSC.Types;
pragma Elaborate_All (LSC.SHA2_Generic);
package LSC.SHA2
is
pragma Pure;
subtype SHA256_Hash_Index is Types.Natural_Index range 1 .. 32;
subtype SHA256_Hash_Type is Types.Bytes (SHA256_Hash_Index);
function Hash_SHA256 is new SHA2_Generic.Hash_SHA256
(Types.Natural_Index, Types.Byte, Types.Bytes,
SHA256_Hash_Index, Types.Byte, SHA256_Hash_Type);
subtype SHA384_Hash_Index is Types.Natural_Index range 1 .. 48;
subtype SHA384_Hash_Type is Types.Bytes (SHA384_Hash_Index);
function Hash_SHA384 is new SHA2_Generic.Hash_SHA384
(Types.Natural_Index, Types.Byte, Types.Bytes,
SHA384_Hash_Index, Types.Byte, SHA384_Hash_Type);
subtype SHA512_Hash_Index is Types.Natural_Index range 1 .. 64;
subtype SHA512_Hash_Type is Types.Bytes (SHA512_Hash_Index);
function Hash_SHA512 is new SHA2_Generic.Hash_SHA512
(Types.Natural_Index, Types.Byte, Types.Bytes,
SHA512_Hash_Index, Types.Byte, SHA512_Hash_Type);
end LSC.SHA2;
|
reznikmm/matreshka | Ada | 4,625 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Script.Macro_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Script_Macro_Name_Attribute_Node is
begin
return Self : Script_Macro_Name_Attribute_Node do
Matreshka.ODF_Script.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Script_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Script_Macro_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Macro_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Script_URI,
Matreshka.ODF_String_Constants.Macro_Name_Attribute,
Script_Macro_Name_Attribute_Node'Tag);
end Matreshka.ODF_Script.Macro_Name_Attributes;
|
jhumphry/auto_counters | Ada | 2,728 | ads | -- unique_c_resources.ads
-- A convenience package to wrap a C type that requires initialization and
-- finalization.
-- Copyright (c) 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Ada.Finalization;
generic
type T is private;
with function Initialize return T;
with procedure Finalize (X : in T);
package Unique_C_Resources is
type Unique_T is new Ada.Finalization.Limited_Controlled with private;
-- Unique_T wraps a type T which is anticipated to be a pointer to an opaque
-- struct provided by a library written in C. Typically it is necessary
-- to call library routines to initialize the underlying resources and to
-- release them when no longer required. Unique_T ensures that it is the only
-- holder of the resources so they are freed when the Unique_T is destroyed.
function Make_Unique_T (X : in T) return Unique_T with Inline;
-- Usually a Unique_T will be default initialized with the function used
-- to instantiate the package in the formal parameter Initialize. The
-- Make_Unique_T function can be used where an explicit initialization
-- is preferred.
function Element (U : Unique_T) return T with Inline;
-- Element returns the underlying value of the Unique_T representing the
-- resources managed by the C library.
type Unique_T_No_Default(<>) is new Unique_T with private;
-- Unique_T_No_Default manages a C resource that requires initialization and
-- finalization just as Unique_T does, except that no default initialization
-- is felt to be appropriate so values must always be made with
-- Make_Unique_T.
private
type Unique_T is new Ada.Finalization.Limited_Controlled with
record
Element : T;
end record;
overriding procedure Initialize (Object : in out Unique_T) with Inline;
overriding procedure Finalize (Object : in out Unique_T) with Inline;
type Unique_T_No_Default is new Unique_T with null record;
end Unique_C_Resources;
|
stcarrez/ada-ado | Ada | 48 | ads | package Regtests.Simple is
end Regtests.Simple;
|
Sawchord/Ada_Drivers_Library | Ada | 3,537 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, 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 MPU60x0.I2C is
function Rep is new Ada.Unchecked_Conversion (SDO_Pin, UInt8);
overriding
procedure Read_Port (This : I2C_MPU60x0_Device;
Address : UInt8;
Data : out Byte_Array) is
Status : I2C_Status;
Communication_Error : exception;
begin
This.Port.Mem_Read (UInt10 (Rep (This.SDO)), UInt16 (Address),
Memory_Size_8b, I2C_Data (Data (Data'Range)),
Status);
if Status /= Ok then
raise Communication_Error;
end if;
end Read_Port;
overriding
procedure Write_Port (This : I2C_MPU60x0_Device;
Address : UInt8;
Data : UInt8) is
Port_Data : constant I2C_Data (1 .. 1) := (1 => Data);
Status : I2C_Status;
Communication_Error : exception;
begin
This.Port.Mem_Write (UInt10 (Rep (This.SDO)), UInt16 (Address),
Memory_Size_8b, Port_Data, Status);
if Status /= Ok then
raise Communication_Error;
end if;
end Write_Port;
end MPU60x0.I2C;
|
reznikmm/matreshka | Ada | 4,403 | adb | -- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc_separates.a,v 1.1 88/08/08 12:07:39 arcadia Exp $
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to [email protected]
-- Send bug reports for ayacc to [email protected]
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : ayacc_separates.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:28:51
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxayacc_separates.ada
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc_separates.a,v 1.1 88/08/08 12:07:39 arcadia Exp $
-- $Log: ayacc_separates.a,v $
--Revision 1.1 88/08/08 12:07:39 arcadia
--Initial revision
--
-- Revision 0.0 86/02/19 18:36:14 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- Revision 0.1 88/03/16
-- Additional argument added to allow user to specify file extension
-- to be used for generated Ada files. -- kn
with String_Pkg; use String_Pkg;
separate (Ayacc)
procedure Initialize is
use Ayacc_File_Names, Options;
Input_File, Extension, Options : String_Type := Create ("");
type Switch is ( On , Off );
C_Lex_Flag,
Debug_Flag,
Summary_Flag,
-- UMASS CODES :
Error_Recovery_Flag,
-- END OF UMASS CODES.
Verbose_Flag : Switch;
Invalid_Command_Line : exception;
procedure Get_Arguments (File : out String_Type;
C_Lex : out Switch;
Debug : out Switch;
Summary : out Switch;
Verbose : out Switch;
-- UMASS CODES :
Error_Recovery : out Switch;
-- END OF UMASS CODES.
Extension : out String_Type) is separate;
begin
Get_Arguments (Input_File,
C_Lex_Flag,
Debug_Flag,
Summary_Flag,
Verbose_Flag,
-- UMASS CODES :
Error_Recovery_Flag,
-- END OF UMASS CODES.
Extension);
New_Line;
Put_Line (" Ayacc (File => """ & Value (Input_File) & """,");
Put_Line (" C_Lex => " &
Value (Mixed (Switch'Image(C_Lex_Flag))) & ',');
Put_Line (" Debug => " &
Value (Mixed (Switch'Image(Debug_Flag))) & ',');
Put_Line (" Summary => " &
Value (Mixed (Switch'Image(Summary_Flag))) & ',');
Put_Line (" Verbose => " &
Value (Mixed (Switch'Image(Verbose_Flag))) & ",");
-- UMASS CODES :
Put_Line (" Error_Recovery => " &
Value (Mixed (Switch'Image(Error_Recovery_Flag))) & ");");
-- END OF UMASS CODES.
New_Line;
if C_Lex_Flag = On then
Options := Options & Create ("i");
end if;
if Debug_Flag = On then
Options := Options & Create ("d");
end if;
if Summary_Flag = On then
Options := Options & Create ("s");
end if;
if Verbose_Flag = On then
Options := Options & Create ("v");
end if;
-- UMASS CODES :
if Error_Recovery_Flag = On then
Options := Options & Create ("e");
end if;
-- END OF UMASS CODES.
Set_File_Names (Value (Input_File), Value(Extension));
Set_Options (Value (Options));
exception
when Invalid_Command_Line =>
raise Illegal_Argument_List;
end Initialize;
|
charlie5/aIDE | Ada | 1,761 | adb | with
AdaM.Factory;
package body AdaM.Declaration.of_generic
is
-- Storage Pool
--
record_Version : constant := 1;
pool_Size : constant := 5_000;
package Pool is new AdaM.Factory.Pools (".adam-store",
"Declarations.of_generic",
pool_Size,
record_Version,
Declaration.of_generic.item,
Declaration.of_generic.view);
-- Forge
--
procedure define (Self : in out Item)
is
begin
null;
end define;
overriding
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
function new_Declaration return View
is
new_View : constant Declaration.of_generic.view := Pool.new_Item;
begin
define (Declaration.of_generic.item (new_View.all));
return new_View;
end new_Declaration;
procedure free (Self : in out Declaration.of_generic.view)
is
begin
destruct (Declaration.of_generic.item (Self.all));
Pool.free (Self);
end free;
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id
is
begin
return Pool.to_Id (Self);
end Id;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View)
renames Pool.View_write;
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View)
renames Pool.View_read;
end AdaM.Declaration.of_generic;
|
flyx/OpenGLAda | Ada | 5,305 | adb | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Blending;
with GL.Buffers;
with GL.Types.Colors;
with GL.Fixed.Matrix;
with GL.Immediate;
with GL.Toggles;
with Glfw.Windows.Context;
with Glfw.Input.Mouse;
with Glfw.Input.Keys;
with Glfw.Monitors;
procedure Glfw_Test.Mouse is
Base_Title : constant String
:= "Click and drag rectangles. Hold mods for coloring. ";
type Test_Window is new Glfw.Windows.Window with record
Start_X, Start_Y : GL.Types.Double;
Color : GL.Types.Colors.Color;
Redraw : Boolean := False;
end record;
overriding
procedure Init (Object : not null access Test_Window;
Width, Height : Glfw.Size;
Title : String;
Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor;
Share : access Glfw.Windows.Window'Class := null);
overriding
procedure Mouse_Position_Changed (Object : not null access Test_Window;
X, Y : Glfw.Input.Mouse.Coordinate);
overriding
procedure Mouse_Button_Changed (Object : not null access Test_Window;
Button : Glfw.Input.Mouse.Button;
State : Glfw.Input.Button_State;
Mods : Glfw.Input.Keys.Modifiers);
procedure Init (Object : not null access Test_Window;
Width, Height : Glfw.Size;
Title : String;
Monitor : Glfw.Monitors.Monitor := Glfw.Monitors.No_Monitor;
Share : access Glfw.Windows.Window'Class := null) is
Upcast : constant Glfw.Windows.Window_Reference
:= Glfw.Windows.Window (Object.all)'Access;
begin
Upcast.Init (Width, Height, Title, Monitor, Share);
Object.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Position);
Object.Enable_Callback (Glfw.Windows.Callbacks.Mouse_Button);
end Init;
procedure Mouse_Position_Changed (Object : not null access Test_Window;
X, Y : Glfw.Input.Mouse.Coordinate) is
use GL.Types.Doubles;
use type Glfw.Input.Button_State;
begin
Object.Set_Title (Base_Title & "(" & X'Img & ", " & Y'Img & ")");
if not Object.Redraw and then
Object.Mouse_Button_State (0) = Glfw.Input.Pressed then
GL.Immediate.Set_Color (Object.Color);
GL.Toggles.Enable (GL.Toggles.Blend);
GL.Blending.Set_Blend_Func
(GL.Blending.Src_Alpha, GL.Blending.One_Minus_Src_Alpha);
declare
Token : GL.Immediate.Input_Token
:= GL.Immediate.Start (GL.Types.Quads);
begin
Token.Add_Vertex (Vector2'(Object.Start_X, Object.Start_Y));
Token.Add_Vertex (Vector2'(Object.Start_X, GL.Types.Double (Y)));
Token.Add_Vertex (Vector2'(GL.Types.Double (X), GL.Types.Double (Y)));
Token.Add_Vertex (Vector2'(GL.Types.Double (X), Object.Start_Y));
end;
Object.Redraw := True;
end if;
end Mouse_Position_Changed;
procedure Mouse_Button_Changed (Object : not null access Test_Window;
Button : Glfw.Input.Mouse.Button;
State : Glfw.Input.Button_State;
Mods : Glfw.Input.Keys.Modifiers) is
use GL.Types.Colors;
use type Glfw.Input.Mouse.Button;
use type Glfw.Input.Button_State;
Colored : Boolean := False;
X, Y : Glfw.Input.Mouse.Coordinate;
begin
if Button /= 0 or else State /= Glfw.Input.Pressed then
return;
end if;
if Mods.Shift then
Object.Color (R) := 1.0;
Colored := True;
else
Object.Color (R) := 0.0;
end if;
if Mods.Control then
Object.Color (G) := 1.0;
Colored := True;
else
Object.Color (G) := 0.0;
end if;
if Mods.Alt then
Object.Color (B) := 1.0;
Colored := True;
else
Object.Color (B) := 0.0;
end if;
if Mods.Super then
Object.Color (A) := 0.5;
else
Object.Color (A) := 1.0;
end if;
if not Colored then
Object.Color := (0.1, 0.1, 0.1, Object.Color (A));
end if;
Object.Get_Cursor_Pos (X, Y);
Object.Start_X := GL.Types.Double (X);
Object.Start_Y := GL.Types.Double (Y);
end Mouse_Button_Changed;
My_Window : aliased Test_Window;
use GL.Fixed.Matrix;
use GL.Buffers;
use type GL.Types.Double;
begin
Glfw.Init;
Enable_Print_Errors;
My_Window'Access.Init (800, 600, Base_Title);
Glfw.Windows.Context.Make_Current (My_Window'Access);
Projection.Load_Identity;
Projection.Apply_Orthogonal (0.0, 800.0, 600.0, 0.0, -1.0, 1.0);
while not My_Window'Access.Should_Close loop
Clear (Buffer_Bits'(others => True));
while not My_Window.Redraw and not My_Window'Access.Should_Close loop
Glfw.Input.Wait_For_Events;
end loop;
GL.Flush;
My_Window.Redraw := False;
Glfw.Windows.Context.Swap_Buffers (My_Window'Access);
end loop;
Glfw.Shutdown;
end Glfw_Test.Mouse;
|
reznikmm/gela | Ada | 67,006 | ads | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- --
-- This specification is derived from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) and ASIS 1999 Issues. --
-- --
-- The copyright notice and the license provisions that follow apply to the --
-- part following the private keyword. --
-- --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision$ $Date$
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 13 package Asis.Elements
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
package Asis.Elements is
-- pragma Preelaborate;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Asis.Elements encapsulates a set of queries that operate on all elements
-- and some queries specific to A_Pragma elements.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 13.1 function Unit_Declaration
-------------------------------------------------------------------------------
-- Gateway queries between Compilation_Units and Elements.
-------------------------------------------------------------------------------
function Unit_Declaration (Compilation_Unit : in Asis.Compilation_Unit)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Compilation_Unit - Specifies the unit to query
--
-- Returns the element representing the declaration of the compilation_unit.
--
-- Returns a Nil_Element if the unit is A_Nonexistent_Declaration,
-- A_Nonexistent_Body, A_Configuration_Compilation, or An_Unknown_Unit.
--
-- All Unit_Kinds are appropriate except Not_A_Unit.
--
-- Returns Declaration_Kinds:
-- Not_A_Declaration
-- A_Function_Body_Declaration
-- A_Function_Declaration
-- A_Function_Instantiation
-- A_Generic_Function_Declaration
-- A_Generic_Package_Declaration
-- A_Generic_Procedure_Declaration
-- A_Package_Body_Declaration
-- A_Package_Declaration
-- A_Package_Instantiation
-- A_Procedure_Body_Declaration
-- A_Procedure_Declaration
-- A_Procedure_Instantiation
-- A_Task_Body_Declaration
-- A_Package_Renaming_Declaration
-- A_Procedure_Renaming_Declaration
-- A_Function_Renaming_Declaration
-- A_Generic_Package_Renaming_Declaration
-- A_Generic_Procedure_Renaming_Declaration
-- A_Generic_Function_Renaming_Declaration
-- A_Protected_Body_Declaration
--
-------------------------------------------------------------------------------
-- 13.2 function Enclosing_Compilation_Unit
-------------------------------------------------------------------------------
function Enclosing_Compilation_Unit (Element : in Asis.Element)
return Asis.Compilation_Unit;
-------------------------------------------------------------------------------
-- Element - Specifies an Element whose Compilation_Unit is desired
--
-- Returns the Compilation_Unit that contains the given Element.
--
-- Raises ASIS_Inappropriate_Element if the Element is a Nil_Element.
--
-------------------------------------------------------------------------------
-- 13.3 function Context_Clause_Elements
-------------------------------------------------------------------------------
function Context_Clause_Elements
(Compilation_Unit : in Asis.Compilation_Unit;
Include_Pragmas : in Boolean := False)
return Asis.Context_Clause_List;
-------------------------------------------------------------------------------
-- Compilation_Unit - Specifies the unit to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns a list of with clauses, use clauses, and pragmas that explicitly
-- appear in the context clause of the compilation unit, in their order of
-- appearance.
--
-- Returns a Nil_Element_List if the unit has A_Nonexistent_Declaration,
-- A_Nonexistent_Body, or An_Unknown_Unit Unit_Kind.
--
-- |IR Implementation Requirement:
-- |IR
-- |IR All pragma Elaborate elements for this unit will appear in this list.
-- |IR Other pragmas will appear in this list, or in the Compilation_Pragmas
-- |IR list, or both.
--
-- |IP Implementation Permissions:
-- |IP
-- |IP Implementors are encouraged to use this list to return all pragmas
-- |IP whose full effect is determined by their exact textual position.
-- |IP Pragmas that do not have placement dependencies may be returned in
-- |IP either list. Only pragmas that appear in the unit's context clause
-- |IP are returned by this query. All other pragmas, affecting the
-- |IP compilation of this unit, are available from the Compilation_Pragmas
-- |IP query.
--
-- Ada predefined packages, such as package Standard, may or may not have
-- context-clause elements available for processing by applications. The
-- physical existence of a package Standard is implementation specific.
-- The same is true for other Ada predefined packages, such as Ada.Text_Io and
-- Ada.Direct_Io. The Origin query can be used to determine whether or not
-- a particular unit is an Ada Predefined unit.
--
-- |IP Implementation Permissions:
-- |IP
-- |IP Results of this query may vary across ASIS implementations. Some
-- |IP implementations normalize all multi-name with clauses and use clauses
-- |IP into an equivalent sequence of single-name with clause and use clauses.
-- |IP Similarly, an implementation may retain only a single reference to
-- |IP a name that appeared more than once in the original context clause.
-- |IP Some implementors will return only pragma
-- |IP Elaborate elements in this list and return all other pragmas via the
-- |IP Compilation_Pragmas query.
--
-- All Unit_Kinds are appropriate except Not_A_Unit.
--
-- Returns Element_Kinds:
-- A_Pragma
-- A_Clause
--
-- Returns Clause_Kinds:
-- A_With_Clause
-- A_Use_Package_Clause
--
-------------------------------------------------------------------------------
-- 13.4 function Configuration_Pragmas
-------------------------------------------------------------------------------
function Configuration_Pragmas (The_Context : in Asis.Context)
return Asis.Pragma_Element_List;
-------------------------------------------------------------------------------
-- The_Context - Specifies the Context to query
--
-- Returns a list of pragmas that apply to all future compilation_unit
-- elements compiled into The_Context. Pragmas returned by this query should
-- have appeared in a compilation that had no compilation_unit elements.
-- To the extent that order is meaningful, the pragmas should be in
-- their order of appearance in the compilation. (The order is implementation
-- dependent, many pragmas have the same effect regardless of order.)
--
-- Returns a Nil_Element_List if there are no such configuration pragmas.
--
-- Returns Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- 13.5 function Compilation_Pragmas
-------------------------------------------------------------------------------
function Compilation_Pragmas (Compilation_Unit : in Asis.Compilation_Unit)
return Asis.Pragma_Element_List;
-------------------------------------------------------------------------------
-- Compilation_Unit - Specifies the unit to query
--
-- Returns a list of pragmas that apply to the compilation of the unit.
-- To the extent that order is meaningful, the pragmas should be in
-- their order of appearance in the compilation. (The order is implementation
-- dependent, many pragmas have the same effect regardless of order.)
--
-- There are two sources for the pragmas that appear in this list:
--
-- - Program unit pragmas appearing at the place of a compilation_unit.
-- See Reference Manual 10.1.5(4).
--
-- - Configuration pragmas appearing before the first
-- compilation_unit of a compilation. See Reference Manual 10.1.5(8).
--
-- This query does not return Elaborate pragmas from the unit context
-- clause of the compilation unit; they do not apply to the compilation,
-- only to the unit.
--
-- Use the Context_Clause_Elements query to obtain a list of all pragmas
-- (including Elaborate pragmas) from the context clause of a compilation
-- unit.
--
-- Pragmas from this query may be duplicates of some or all of the
-- non-Elaborate pragmas available from the Context_Clause_Elements query.
-- Such duplication is simply the result of the textual position of the
-- pragma--globally effective pragmas may appear textually within the context
-- clause of a particular unit, and be returned as part of the Context_Clause
-- for that unit.
--
-- Ada predefined packages, such as package Standard, may or may not have
-- pragmas available for processing by applications. The physical
-- existence of a package Standard is implementation specific. The same
-- is true for other Ada predefined packages, such as Ada.Text_Io and
-- Ada.Direct_Io. The Origin query can be used to determine whether or
-- not a particular unit is an Ada Predefined unit.
--
-- Returns a Nil_Element_List if the compilation unit:
--
-- - has no such applicable pragmas.
--
-- - is an An_Unknown_Unit, A_Nonexistent_Declaration, or A_Nonexistent_Body.
--
-- All Unit_Kinds are appropriate except Not_A_Unit.
--
-- Returns Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- Element_Kinds Hierarchy
--
-- Element_Kinds Value Subordinate Kinds
-------------------------------------------------------------------------------
--
-- Key: Read "->" as "can be further categorized by its"
--
-- A_Pragma -> Pragma_Kinds
--
-- A_Defining_Name -> Defining_Name_Kinds
-- -> Operator_Kinds
--
-- A_Declaration -> Declaration_Kinds
-- -> Declaration_Origin
-- -> Mode_Kinds
-- -> Subprogram_Default_Kinds
--
-- A_Definition -> Definition_Kinds
-- -> Trait_Kinds
-- -> Type_Kinds
-- -> Formal_Type_Kinds
-- -> Access_Type_Kinds
-- -> Root_Type_Kinds
-- -> Constraint_Kinds
-- -> Discrete_Range_Kinds
--
-- An_Expression -> Expression_Kinds
-- -> Operator_Kinds
-- -> Attribute_Kinds
--
-- An_Association -> Association_Kinds
--
-- A_Statement -> Statement_Kinds
--
-- A_Path -> Path_Kinds
--
-- A_Clause -> Clause_Kinds
-- -> Representation_Clause_Kinds
--
-- An_Exception_Handler
--
-------------------------------------------------------------------------------
-- 13.6 function Element_Kind
-------------------------------------------------------------------------------
function Element_Kind (Element : in Asis.Element)
return Asis.Element_Kinds;
-------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the Element_Kinds value of Element.
-- Returns Not_An_Element for a Nil_Element.
--
-- All element kinds are expected.
--
-------------------------------------------------------------------------------
-- 13.7 function Pragma_Kind
-------------------------------------------------------------------------------
function Pragma_Kind (Pragma_Element : in Asis.Pragma_Element)
return Asis.Pragma_Kinds;
-------------------------------------------------------------------------------
-- Pragma_Element - Specifies the element to query
--
-- Returns the Pragma_Kinds value of Pragma_Element.
-- Returns Not_A_Pragma for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- 13.8 function Defining_Name_Kind
-------------------------------------------------------------------------------
function Defining_Name_Kind (Defining_Name : in Asis.Defining_Name)
return Asis.Defining_Name_Kinds;
-------------------------------------------------------------------------------
-- Defining_Name - Specifies the element to query
--
-- Returns the Defining_Name_Kinds value of the Defining_Name.
--
-- Returns Not_A_Defining_Name for any unexpected element such as a
-- Nil_Element, A_Clause, or A_Statement.
--
-- Expected Element_Kinds:
-- A_Defining_Name
--
-------------------------------------------------------------------------------
-- 13.9 function Declaration_Kind
-------------------------------------------------------------------------------
function Declaration_Kind (Declaration : in Asis.Declaration)
return Asis.Declaration_Kinds;
-------------------------------------------------------------------------------
-- Declaration - Specifies the element to query
--
-- Returns the Declaration_Kinds value of the Declaration.
--
-- Returns Not_A_Declaration for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Statement.
--
-- Expected Element_Kinds:
-- A_Declaration
--
-------------------------------------------------------------------------------
-- 13.10 function Trait_Kind (Obsolescent) - see clause X
-------------------------------------------------------------------------------
function Trait_Kind (Element : in Asis.Element)
return Asis.Trait_Kinds;
-------------------------------------------------------------------------------
-- Element - Specifies the Element to query
--
-- Returns the Trait_Kinds value of the Element.
--
-- Returns Not_A_Trait for any unexpected element such as a
-- Nil_Element, A_Statement, or An_Expression.
--
-- Expected Declaration_Kinds:
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
-- A_Variable_Declaration
-- A_Constant_Declaration
-- A_Deferred_Constant_Declaration
-- A_Discriminant_Specification
-- A_Loop_Parameter_Specification
-- A_Procedure_Declaration
-- A_Function_Declaration
-- A_Parameter_Specification
--
-- Expected Definition_Kinds:
-- A_Component_Definition
-- A_Private_Type_Definition
-- A_Tagged_Private_Type_Definition
-- A_Private_Extension_Definition
--
-- Expected Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
--
-- Expected Formal_Type_Kinds:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
-- A_Formal_Derived_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.11 function Declaration_Origin
-------------------------------------------------------------------------------
function Declaration_Origin (Declaration : in Asis.Declaration)
return Asis.Declaration_Origins;
-------------------------------------------------------------------------------
-- Declaration - Specifies the Declaration to query
--
-- Returns the Declaration_Origins value of the Declaration.
--
-- Returns Not_A_Declaration_Origin for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Clause.
--
-- Expected Element_Kinds:
-- A_Declaration
--
-------------------------------------------------------------------------------
-- 13.12 function Mode_Kind
-------------------------------------------------------------------------------
function Mode_Kind (Declaration : in Asis.Declaration)
return Asis.Mode_Kinds;
-------------------------------------------------------------------------------
-- Declaration - Specifies the element to query
--
-- Returns the Mode_Kinds value of the Declaration.
--
-- Returns A_Default_In_Mode for an access parameter.
--
-- Returns Not_A_Mode for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Statement.
--
-- Expected Declaration_Kinds:
-- A_Parameter_Specification
-- A_Formal_Object_Declaration
--
-------------------------------------------------------------------------------
-- 13.13 function Default_Kind
-------------------------------------------------------------------------------
function Default_Kind (Declaration : in Asis.Generic_Formal_Parameter)
return Asis.Subprogram_Default_Kinds;
-------------------------------------------------------------------------------
-- Declaration - Specifies the element to query
--
-- Returns the Subprogram_Default_Kinds value of the Declaration.
--
-- Returns Not_A_Default for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Statement.
--
-- Expected Declaration_Kinds:
-- A_Formal_Function_Declaration
-- A_Formal_Procedure_Declaration
--
-------------------------------------------------------------------------------
-- 13.14 function Definition_Kind
-------------------------------------------------------------------------------
function Definition_Kind (Definition : in Asis.Definition)
return Asis.Definition_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Definition to query
--
-- Returns the Definition_Kinds value of the Definition.
--
-- Returns Not_A_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Element_Kinds:
-- A_Definition
--
-------------------------------------------------------------------------------
-- 13.15 function Type_Kind
-------------------------------------------------------------------------------
function Type_Kind (Definition : in Asis.Type_Definition)
return Asis.Type_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Type_Definition to query
--
-- Returns the Type_Kinds value of the Definition.
--
-- Returns Not_A_Type_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- A_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.16 function Formal_Type_Kind
-------------------------------------------------------------------------------
function Formal_Type_Kind
(Definition : in Asis.Formal_Type_Definition)
return Asis.Formal_Type_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Formal_Type_Definition to query
--
-- Returns the Formal_Type_Kinds value of the Definition.
--
-- Returns Not_A_Formal_Type_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- A_Formal_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.17 function Access_Type_Kind
-------------------------------------------------------------------------------
function Access_Type_Kind
(Definition : in Asis.Access_Type_Definition)
return Asis.Access_Type_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Access_Type_Definition to query
--
-- Returns the Access_Type_Kinds value of the Definition.
--
-- Returns Not_An_Access_Type_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Type_Kinds:
-- An_Access_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Interface_Kind
-------------------------------------------------------------------------------
function Interface_Kind
(Definition : Asis.Definition)
return Asis.Interface_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Definition to query.
--
-- Returns the Interface_Kinds value of the Definition.
--
-- Returns Not_An_Interface for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- A_Type_Definition
-- A_Formal_Type_Definition
--
-- Expected Type_Kinds:
-- An_Interface_Type_Definition
--
-- Expected Formal_Type_Kinds:
-- A_Formal_Interface_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Access_Definition_Kind
-------------------------------------------------------------------------------
function Access_Definition_Kind -- 3.3.1(2) / 3.10(6)
(Definition : Asis.Definition)
return Asis.Access_Definition_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Definition to query.
--
-- Returns the Access_Definition_Kinds value of the Definition.
--
-- Returns Not_An_Access_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- An_Access_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Null_Exclusion
-------------------------------------------------------------------------------
function Has_Null_Exclusion -- 3.2.2(3/2), 3.7(5/2), 3.10 (2/2,6/2),
(Element : Asis.Element) -- 6.1(13/2,15/2), 8.5.1(2/2), 12.4(2/2)
return Boolean;
-------------------------------------------------------------------------------
-- Element - Specifies the element to check.
--
-- Checks if the argument element has a null_exclusion specifier.
--
-- Returns False for any unexpected element such as a Nil_Element,
-- A_Statement or A_Clause.
--
-- Expected Definition_Kinds:
-- A_Type_Definition
-- An_Access_Definition
-- A_Subtype_Indication
--
-- Expected Type_Kinds:
-- An_Access_Type_Definition
--
-- Expected Declaration_Kinds:
-- A_Discriminant_Specification
-- A_Parameter_Specification
-- A_Formal_Object_Declaration
-- An_Object_Renaming_Declaration
--
-------------------------------------------------------------------------------
-- 13.18 function Root_Type_Kind
-------------------------------------------------------------------------------
function Root_Type_Kind
(Definition : in Asis.Root_Type_Definition)
return Asis.Root_Type_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the Root_Type_Definition to query
--
-- Returns the Root_Type_Kinds value of the Definition.
--
-- Returns Not_A_Root_Type_Definition for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Type_Kinds:
-- A_Root_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.19 function Constraint_Kind
-------------------------------------------------------------------------------
function Constraint_Kind
(Definition : in Asis.Constraint)
return Asis.Constraint_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the constraint to query
--
-- Returns the Constraint_Kinds value of the Definition.
--
-- Returns Not_A_Constraint for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- A_Constraint
--
-------------------------------------------------------------------------------
-- 13.20 function Discrete_Range_Kind
-------------------------------------------------------------------------------
function Discrete_Range_Kind
(Definition : in Asis.Discrete_Range)
return Asis.Discrete_Range_Kinds;
-------------------------------------------------------------------------------
-- Definition - Specifies the discrete_range to query
--
-- Returns the Discrete_Range_Kinds value of the Definition.
--
-- Returns Not_A_Discrete_Range for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Definition_Kinds:
-- A_Discrete_Subtype_Definition
-- A_Discrete_Range
--
-------------------------------------------------------------------------------
-- 13.21 function Expression_Kind
-------------------------------------------------------------------------------
function Expression_Kind (Expression : in Asis.Expression)
return Asis.Expression_Kinds;
-------------------------------------------------------------------------------
-- Expression - Specifies the Expression to query
--
-- Returns the Expression_Kinds value of the Expression.
--
-- Returns Not_An_Expression for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 13.22 function Operator_Kind
-------------------------------------------------------------------------------
function Operator_Kind (Element : in Asis.Element)
return Asis.Operator_Kinds;
-------------------------------------------------------------------------------
-- Element - Specifies the Element to query
--
-- Returns the Operator_Kinds value of the A_Defining_Name or An_Expression
-- element.
--
-- Returns Not_An_Operator for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Defining_Name_Kinds:
-- A_Defining_Operator_Symbol
--
-- Expected Expression_Kinds:
-- An_Operator_Symbol
--
-------------------------------------------------------------------------------
-- 13.23 function Attribute_Kind
-------------------------------------------------------------------------------
function Attribute_Kind (Expression : in Asis.Expression)
return Asis.Attribute_Kinds;
-------------------------------------------------------------------------------
-- Expression - Specifies the Expression to query
--
-- Returns the Attribute_Kinds value of the Expression.
--
-- Returns Not_An_Attribute for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Expression_Kinds:
-- An_Attribute_Reference
--
-------------------------------------------------------------------------------
-- 13.24 function Association_Kind
-------------------------------------------------------------------------------
function Association_Kind (Association : in Asis.Association)
return Asis.Association_Kinds;
-------------------------------------------------------------------------------
-- Association - Specifies the Association to query
--
-- Returns the Association_Kinds value of the Association.
--
-- Returns Not_An_Association for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Element_Kinds:
-- An_Association
--
-------------------------------------------------------------------------------
-- 13.25 function Statement_Kind
-------------------------------------------------------------------------------
function Statement_Kind (Statement : in Asis.Statement)
return Asis.Statement_Kinds;
-------------------------------------------------------------------------------
-- Statement - Specifies the element to query
--
-- Returns the Statement_Kinds value of the statement.
--
-- Returns Not_A_Statement for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Declaration.
--
-- Expected Element_Kinds:
-- A_Statement
--
-------------------------------------------------------------------------------
-- 13.26 function Path_Kind
-------------------------------------------------------------------------------
function Path_Kind (Path : in Asis.Path) return Asis.Path_Kinds;
-------------------------------------------------------------------------------
-- Path - Specifies the Path to query
--
-- Returns the Path_Kinds value of the Path.
--
-- Returns Not_A_Path for any unexpected element such as a
-- Nil_Element, A_Statement, or A_Declaration.
--
-- Expected Element_Kinds:
-- A_Path
--
-------------------------------------------------------------------------------
-- 13.27 function Clause_Kind
-------------------------------------------------------------------------------
function Clause_Kind (Clause : in Asis.Clause)
return Asis.Clause_Kinds;
-------------------------------------------------------------------------------
-- Clause - Specifies the element to query
--
-- Returns the Clause_Kinds value of the Clause.
--
-- Returns Not_A_Clause for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Declaration.
--
-- Expected Element_Kinds:
-- A_Clause
--
-------------------------------------------------------------------------------
-- 13.28 function Representation_Clause_Kind
-------------------------------------------------------------------------------
function Representation_Clause_Kind
(Clause : in Asis.Representation_Clause)
return Asis.Representation_Clause_Kinds;
-------------------------------------------------------------------------------
-- Clause - Specifies the element to query
--
-- Returns the Representation_Clause_Kinds value of the Clause.
--
-- Returns Not_A_Representation_Clause for any unexpected element such as a
-- Nil_Element, A_Definition, or A_Declaration.
--
-- Expected Clause_Kinds:
-- A_Representation_Clause
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Abstract
-------------------------------------------------------------------------------
function Has_Abstract (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the element to query.
--
-- Returns True if the reserved word *abstract* appears in the Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Declaration_Kinds:
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration
-- A_Function_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
-- A_Procedure_Declaration
-- A_Type_Declaration
--
-- or an element that has one of the following Definition_Kinds:
-- A_Private_Extension_Definition
-- A_Private_Type_Definition (Gela: couldn't be abstract)
-- A_Tagged_Private_Type_Definition
-- A_Type_Definition
-- A_Tagged_Record_Type_Definition (Added by Gela)
-- A_Derived_Type_Definition (Added by Gela)
-- A_Derived_Record_Extension_Definition (Added by Gela)
--
-- or an element that has one of the following Formal_Type_Kinds:
-- A_Formal_Private_Type_Definition (Gela: couldn't have abstract)
-- A_Formal_Tagged_Private_Type_Definition
-- A_Formal_Derived_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Aliased
-------------------------------------------------------------------------------
function Has_Aliased (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *aliased* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Declaration_Kinds:
-- A_Constant_Declaration
-- A_Deferred_Constant_Declaration
-- A_Return_Object_Specification
-- A_Variable_Declaration
--
-- Element expects an element that has one of the following Declaration_Kinds:
-- A_Component_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Limited
-------------------------------------------------------------------------------
function Has_Limited (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *limited* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Clause_Kinds:
-- A_With_Clause
--
-- or an element that has one of the following Declaration_Kinds:
-- A_Type_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
--
-- or an element that has one of the following Definition_Kinds:
-- A_Type_Definition
-- A_Private_Type_Definition
-- A_Tagged_Private_Type_Definition
-- A_Private_Extension_Definition
-- An_Interface_Type_Definition
-- A_Tagged_Record_Type_Definition (Added by Gela)
-- A_Record_Type_Definition (Added by Gela)
-- A_Derived_Type_Definition (Added by Gela)
-- A_Derived_Record_Extension_Definition (Added by Gela)
--
-- or an element that has one of the following Formal_Type_Kinds:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
-- A_Formal_Derived_Type_Definition
-- A_Formal_Interface_Type_Definition (Added by Gela)
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Private
-------------------------------------------------------------------------------
function Has_Private (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the element to query.
--
-- Returns True if the reserved word *private* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Declaration_Kinds:
-- A_Type_Declaration
-- A_Private_Type_Declaration
--
-- or an element that has one of the following Definition_Kinds:
-- A_Private_Extension_Definition
-- A_Private_Type_Definition
-- A_Tagged_Private_Type_Definition
-- A_Type_Definition
--
-- or an element that has one of the following Formal_Type_Kinds:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
-- A_Formal_Derived_Type_Definition (Added by Gela)
--
-- or an element that has one of the following Clause_Kinds:
-- A_With_Clause
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Protected
-------------------------------------------------------------------------------
function Has_Protected (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *protected* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Definition_Kinds:
-- An_Interface_Type_Definition
-- A_Protected_Definition
--
-- or an element that has one of the following Declaration_Kinds
-- A_Protected_Body_Declaration
-- A_Protected_Type_Declaration
-- A_Single_Protected_Declaration
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Reverse
-------------------------------------------------------------------------------
function Has_Reverse (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *reverse* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Declaration_Kinds:
-- A_Loop_Parameter_Specification
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Synchronized
-------------------------------------------------------------------------------
function Has_Synchronized (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *synchronized* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Definition_Kinds:
-- An_Interface_Type_Definition
-- A_Private_Extension_Definition
-- A_Formal_Derived_Type_Definition (Added by Gela)
--
-- Returns False for any other Element including a Nil_Element.
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Tagged
-------------------------------------------------------------------------------
function Has_Tagged (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *tagged* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Definition_Kinds:
-- A_Tagged_Incomplete_Type_Definition
-- A_Tagged_Private_Type_Definition
-- A_Tagged_Record_Type_Definition (Gela: isn't a Definition_Kind!)
--
-- or an element that has one of the following Type_Kinds:
-- A_Tagged_Record_Type_Definition
--
-- or an element that has one of the following Formal_Type_Kinds:
-- A_Formal_Tagged_Private_Type_Definition
--
-------------------------------------------------------------------------------
-- 13.xx function Has_Task
-------------------------------------------------------------------------------
function Has_Task (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the Element to query.
--
-- Returns True if the reserved word *task* appears in Element, and
-- False otherwise.
--
-- Returns False for any unexpected element, including a Nil_Element.
--
-- Element expects an element that has one of the following Definition_Kinds:
-- An_Interface_Type_Definition
-- A_Task_Definition
--
-- or an element that has one of the following Declaration_Kinds
-- A_Task_Type_Declaration
-- A_Single_task_Declaration
-- A_Task_Body_Declaration
--
-- Returns False for any other Element including a Nil_Element.
--
-------------------------------------------------------------------------------
-- 13.xx function Is_Null_Procedure
-------------------------------------------------------------------------------
function Is_Null_Procedure (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the element to query.
--
-- Returns True for a declaration of a procedure or formal procedure that is
-- declared as null.
--
-- Returns False for any other Element including a Nil_Element.
--
-- Expected Element_Kinds:
-- A_Declaration
--
-- Expected Declaration_Kinds:
-- A_Procedure_Declaration
-- A_Formal_Procedure_Declaration
--
-- Note:
-- This routine tests for the syntactic element null_procedure_declaration;
-- calling Is_Null_Procedure on a renaming of a null procedure will return
-- False. Use the routine ASIS.Callable_Views.Is_Null to determine if a
-- declaration is semantically a null procedure (including renames).
--
-- AASIS Note: A generic procedure cannot be null, while generic formal
-- procedures can be null.
--
-------------------------------------------------------------------------------
-- 13.xx function Is_Abstract_Subprogram
-------------------------------------------------------------------------------
function Is_Abstract_Subprogram (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element specifies the element to query.
--
-- Returns True for a declaration of a subprogram or formal subprogram that
-- is declared as abstract.
--
-- Returns False for any other Element including a Nil_Element.
--
-- Expected Element_Kinds:
-- A_Declaration
--
-- Expected Declaration_Kinds:
-- A_Procedure_Declaration
-- A_Function_Declaration
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration
--
-- Note: This routine tests for the syntactic element
-- abstract_subprogram_declaration; calling Is_Abstract_Subprogram on a
-- renaming of an abstract subprogram will return False. Use the routine
-- ASIS.Callable_Views.Is_Abstract to determine if a declaration is
-- semantically an abstract subprogram (including renames).
--
-- AASIS Note: A generic subprogram cannot be abstract, while generic formal
-- subprograms can be abstract.
--
-------------------------------------------------------------------------------
-- 13.29 function Is_Nil
-------------------------------------------------------------------------------
function Is_Nil (Right : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Right - Specifies the element to check
--
-- Returns True if the program element is the Nil_Element.
--
-------------------------------------------------------------------------------
-- 13.30 function Is_Nil
-------------------------------------------------------------------------------
function Is_Nil (Right : in Asis.Element_List) return Boolean;
-------------------------------------------------------------------------------
-- Right - Specifies the element list to check
--
-- Returns True if the element list has a length of zero.
--
-------------------------------------------------------------------------------
-- 13.31 function Is_Equal
-------------------------------------------------------------------------------
function Is_Equal (Left : in Asis.Element;
Right : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Left - Specifies the left element to compare
-- Right - Specifies the right element to compare
--
-- Returns True if Left and Right represent the same physical element,
-- from the same physical compilation unit. The two elements may or
-- may not be from the same open ASIS Context variable.
--
-- Implies:
--
-- Is_Equal (Enclosing_Compilation_Unit (Left),
-- Enclosing_Compilation_Unit (Right)) = True
--
-------------------------------------------------------------------------------
-- 13.32 function Is_Identical
-------------------------------------------------------------------------------
function Is_Identical (Left : in Asis.Element;
Right : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Left - Specifies the left element
-- Right - Specifies the right element
--
-- Returns True if Left and Right represent the same physical element,
-- from the same physical compilation unit, from the same open ASIS
-- Context variable.
--
-- Implies:
--
-- Is_Identical (Enclosing_Compilation_Unit (Left),
-- Enclosing_Compilation_Unit (Right)) = True
--
-------------------------------------------------------------------------------
-- 13.33 function Is_Part_Of_Implicit
-------------------------------------------------------------------------------
function Is_Part_Of_Implicit (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns True for any Element that is, or that forms part of, any
-- implicitly declared or specified program Element structure.
--
-- Returns True for any implicit generic child unit specifications or their
-- subcomponents. Reference Manual 10.1.1(19).
--
-- Returns False for a Nil_Element, or any Element that correspond to text
-- which was specified explicitly (typed, entered, written).
--
-- Generic instance specifications and bodies, while implicit, are treated
-- as a special case. These elements will not normally test as
-- Is_Part_Of_Implicit. Rather, they are Is_Part_Of_Instance. They only test
-- as Is_Part_Of_Implicit if one of the following rules applies. This is
-- done so that it is possible to determine whether a declaration, which
-- happens to occur within an instance, is an implicit result of
-- another declaration which occurs explicitly within the generic template.
--
-- Implicit Elements are those that represent these portions of the Ada
-- language:
--
-- - Reference Manual 4.5.(9)
--
-- o All predefined operator declarations and their component elements are
-- Is_Part_Of_Implicit
--
-- - Reference Manual 3.4(16)
--
-- o Implicit predefined operators of the derived type.
--
-- - Reference Manual 3.4(17-22)
--
-- o Implicit inherited subprogram declarations and their component elements
-- are Is_Part_Of_Implicit
--
-- - Reference Manual 6.4(9) and 12.3(7)
--
-- o Implicit actual parameter expressions (defaults).
--
-- o The A_Parameter_Association that includes a defaulted parameter value
-- Is_Normalized and also Is_Part_Of_Implicit. The Formal_Parameter and
-- the Actual_Parameter values from such Associations are not
-- Is_Part_Of_Implicit unless they are from default initializations for an
-- inherited subprogram declaration and have an Enclosing_Element that is
-- the parameter specification of the subprogram declaration. (Those
-- elements are shared with (were created by) the original subprogram
-- declaration, or they are naming expressions representing the actual
-- generic subprogram selected at the place of an instantiation for
-- A_Box_Default.)
--
-- o All A_Parameter_Association Kinds from a Normalized list are
-- Is_Part_Of_Implicit.
--
-- - Reference Manual 6.6 (6)
--
-- o Inequality operator declarations for limited private types are
-- Is_Part_Of_Implicit.
--
-- o Depending on the ASIS implementation, a "/=" appearing in the
-- compilation may result in a "NOT" and an "=" in the internal
-- representation. These two elements test as Is_Part_Of_Implicit
-- because they do not represent text from the original compilation
-- text.
--
-- - Reference Manual 12.3 (16)
--
-- o implicit generic instance specifications and bodies are not
-- Is_Part_Of_Implicit; they are Is_Part_Of_Instance and are only
-- implicit if some other rule makes them so.
--
-------------------------------------------------------------------------------
-- 13.34 function Is_Part_Of_Inherited
-------------------------------------------------------------------------------
function Is_Part_Of_Inherited (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns True for any Element that is, or that forms part of, an
-- inherited primitive subprogram declaration.
--
-- Returns False for any other Element including a Nil_Element.
--
-------------------------------------------------------------------------------
-- 13.35 function Is_Part_Of_Instance
-------------------------------------------------------------------------------
function Is_Part_Of_Instance (Element : in Asis.Element) return Boolean;
-------------------------------------------------------------------------------
-- Element - Specifies the element to test
--
-- Returns True if the Element is part of an implicit generic specification
-- instance or an implicit generic body instance.
--
-- Returns False for explicit, inherited, and predefined Elements that are
-- not the result of a generic expansion.
--
-- Returns False for any implicit generic child unit specifications or
-- their subcomponents. Reference Manual 10.1.1(19).
--
-- Returns False for a Nil_Element.
--
-- Instantiations are not themselves Is_Part_Of_Instance unless they are
-- encountered while traversing a generic instance.
--
-------------------------------------------------------------------------------
-- 13.36 function Enclosing_Element
-------------------------------------------------------------------------------
function Enclosing_Element (Element : in Asis.Element) return Asis.Element;
function Enclosing_Element (Element : in Asis.Element;
Expected_Enclosing_Element : in Asis.Element)
return Asis.Element;
-------------------------------------------------------------------------------
-- Element - Specifies the element to query
-- Expected_Enclosing_Element - Specifies an enclosing element expected to
-- contain the element
--
-- Returns the Element that immediately encloses the given element. This
-- query is intended to exactly reverse any single parent-to-child element
-- traversal. For any structural query that returns a subcomponent of an
-- element (or that returns a list of subcomponent elements), the original
-- element can be determined by passing the subcomponent element to this
-- query.
--
-- |AN Application Note:
-- |AN
-- |AN Semantic queries (queries that test the meaning of a program rather
-- |AN than its structure) return Elements that usually do not have the
-- |AN original argument Element as their parent.
--
-- Returns a Nil_Element if:
--
-- - the element is the declaration part of a compilation unit
-- (Unit_Declaration).
--
-- - the element is with clause or use clause of a context clause
-- (Context_Clause_Elements).
--
-- - the element is a pragma for a compilation unit
-- (Compilation_Pragmas and Context_Clause_Elements).
--
-- Use Enclosing_Compilation_Unit to get the enclosing compilation unit for
-- any element value other than Nil_Element.
--
-- Raises ASIS_Inappropriate_Element if the Element is a Nil_Element.
--
-- Examples:
--
-- - Given a A_Declaration/A_Full_Type_Declaration in the declarative region
-- of a block statement, returns the A_Statement/A_Block_Statement Element
-- that encloses the type declaration.
--
-- - Given A_Statement, from the sequence of statements within a loop
-- statement, returns the enclosing A_Statement/A_Loop_Statement.
--
-- - Given the An_Expression/An_Identifier selector from an expanded name,
-- returns the An_Expression/A_Selected_Component that represents the
-- combination of the prefix, the dot, and the selector.
--
-- - Given the A_Declaration corresponding to the implicit redeclaration of
-- a child generic for an instantiated parent generic, returns the expanded
-- generic specific template from the parent generic instantiation
-- corresponding to any implicit generic child unit specification given as
-- an argument. Reference Manual 10.1.1(19).
--
-- |AN Application Note:
-- |AN
-- |AN The optional Expected_Enclosing_Element parameter is used only to opti-
-- |AN mizethis query. This speed up is only present for ASIS implementations
-- |AN where the underlying implementor's environment does not have "parent
-- |AN pointers". For these implementations, this query is implemented as a
-- |AN "search". The Enclosing_Compilation_Unit is searched for the argument
-- |AN Element. The Expected_Enclosing_Element parameter provides a means of
-- |AN shortening the search.
-- |AN Note: If the argument Element is not a sub-element of the
-- |AN Expected_Enclosing_Element parameter, or if the
-- |AN Expected_Enclosing_Element is a Nil_Element, the result of the
-- |AN call is a Nil_Element.
-- |AN
-- |AN Implementations that do not require the Expected_Enclosing_Element
-- |AN parameter may ignore it. They are encouraged, but not required, to
-- |AN testthe Expected_Enclosing_Element parameter and to determine if it
-- |AN is an invalid Element value (its associated Environment Context may
-- |AN be closed)
-- |AN
-- |AN Portable applications should not use the Expected_Enclosing_Element
-- |AN parameter since it can lead to unexpected differences when porting an
-- |AN application between ASIS implementations where one implementation uses
-- |AN the parameter and the other implementation does not. Passing a "wrong"
-- |AN Expected_Enclosing_Element to an implementation that ignores it, is
-- |AN harmless. Passing a "wrong" Expected_Enclosing_Element to an
-- |AN implementation that may utilize it, can lead to an unexpected
-- |AN Nil_Element result.
--
-------------------------------------------------------------------------------
-- 13.37 function Pragmas
-------------------------------------------------------------------------------
function Pragmas (The_Element : in Asis.Element)
return Asis.Pragma_Element_List;
-------------------------------------------------------------------------------
-- The_Element - Specifies the element to query
--
-- Returns the list of pragmas, in their order of appearance, that appear
-- directly within the given The_Element. Returns only those pragmas that are
-- immediate component elements of the given The_Element. Pragmas embedded
-- within other component elements are not returned. For example, returns
-- the pragmas in a package specification, in the statement list of a loop,
-- or in a record component list.
--
-- This query returns exactly those pragmas that are returned by the
-- various queries, that accept these same argument kinds, and that
-- return Declaration_List and Statement_List, where the inclusion of
-- Pragmas is controlled by an Include_Pragmas parameter.
--
-- Returns a Nil_Element_List if there are no pragmas.
--
-- Appropriate Element_Kinds:
-- A_Path (pragmas from the statement list +
-- pragmas immediately preceding the
-- reserved word "when" of the first
-- alternative)
-- An_Exception_Handler (pragmas from the statement list + pragmas
-- immediately preceding the reserved word
-- "when" of the first exception handler)
--
-- Appropriate Declaration_Kinds:
--
-- A_Procedure_Body_Declaration (pragmas from declarative region + statements)
-- A_Function_Body_Declaration (pragmas from declarative region + statements)
-- A_Package_Declaration (pragmas from visible + private declarative
-- regions)
-- A_Package_Body_Declaration (pragmas from declarative region + statements)
-- A_Task_Body_Declaration (pragmas from declarative region + statements)
-- A_Protected_Body_Declaration (pragmas from declarative region)
-- An_Entry_Body_Declaration (pragmas from declarative region + statements)
-- A_Generic_Procedure_Declaration (pragmas from formal declarative region)
-- A_Generic_Function_Declaration (pragmas from formal declarative region)
-- A_Generic_Package_Declaration (pragmas from formal + visible +
-- private declarative regions)
--
-- Appropriate Definition_Kinds:
-- A_Record_Definition (pragmas from the component list)
-- A_Variant_Part (pragmas immediately preceding the
-- first reserved word "when" + between
-- variants)
-- A_Variant (pragmas from the component list)
-- A_Task_Definition (pragmas from visible + private
-- declarative regions)
-- A_Protected_Definition (pragmas from visible + private
-- declarative regions)
--
-- Appropriate Statement_Kinds:
-- A_Loop_Statement (pragmas from statement list)
-- A_While_Loop_Statement (pragmas from statement list)
-- A_For_Loop_Statement (pragmas from statement list)
-- A_Block_Statement (pragmas from declarative region + statements)
-- An_Accept_Statement (pragmas from statement list +
--
-- Appropriate Representation_Clause_Kinds:
-- A_Record_Representation_Clause (pragmas from component specifications)
--
-- Returns Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- 13.38 function Corresponding_Pragmas
-------------------------------------------------------------------------------
function Corresponding_Pragmas (Element : in Asis.Element)
return Asis.Pragma_Element_List;
-------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the list of pragmas semantically associated with the given element,
-- in their order of appearance, or, in any order that does not affect their
-- relative interpretations. These are pragmas that directly affect the
-- given element. For example, a pragma Pack affects the type it names.
--
-- Returns a Nil_Element_List if there are no semantically associated pragmas.
--
-- |AN Application Note:
-- |AN
-- |AN If the argument is a inherited entry declaration from a derived task
-- |AN type, all pragmas returned are elements taken from the original task
-- |AN type's declarative item list. Their Enclosing_Element is the original
-- |AN type definition and not the derived type definition.
--
-- Appropriate Element_Kinds:
-- A_Declaration
-- A_Statement
--
-- Returns Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- 13.39 function Pragma_Name_Image
-------------------------------------------------------------------------------
function Pragma_Name_Image
(Pragma_Element : in Asis.Pragma_Element) return Program_Text;
-------------------------------------------------------------------------------
-- Pragma_Element - Specifies the element to query
--
-- Returns the program text image of the simple name of the pragma.
--
-- The case of names returned by this query may vary between implementors.
-- Implementors are encouraged, but not required, to return names in the
-- same case as was used in the original compilation text.
--
-- Appropriate Element_Kinds:
-- A_Pragma
--
-------------------------------------------------------------------------------
-- 13.40 function Pragma_Argument_Associations
-------------------------------------------------------------------------------
function Pragma_Argument_Associations
(Pragma_Element : in Asis.Pragma_Element)
return Asis.Association_List;
-------------------------------------------------------------------------------
-- Pragma_Element - Specifies the element to query
--
-- Returns a list of the Pragma_Argument_Associations of the pragma, in their
-- order of appearance.
--
-- Appropriate Element_Kinds:
-- A_Pragma
--
-- Returns Element_Kinds:
-- A_Pragma_Argument_Association
--
-------------------------------------------------------------------------------
-- 13.41 function Debug_Image
-------------------------------------------------------------------------------
function Debug_Image (Element : in Asis.Element) return Wide_String;
-------------------------------------------------------------------------------
-- Element - Specifies the program element to convert
--
-- Returns a string value containing implementation-defined debug
-- information associated with the element.
--
-- The return value uses Asis.Text.Delimiter_Image to separate the lines
-- of multi-line results. The return value does not end with
-- Asis.Text.Delimiter_Image.
--
-- These values are intended for two purposes. They are suitable for
-- inclusion in problem reports sent to the ASIS implementor. They can
-- be presumed to contain information useful when debugging the implementation
-- itself. They are also suitable for use by the ASIS application when
-- printing simple application debugging messages during application
-- development. They are intended to be, to some worthwhile degree,
-- intelligible to the user.
--
-------------------------------------------------------------------------------
-- 13.42 function Hash
-------------------------------------------------------------------------------
function Hash (Element : in Asis.Element) return Asis.ASIS_Integer;
-- The purpose of the hash function is to provide a convenient name for an
-- object of type Asis.Element in order to facilitate application defined I/O
-- and/or other application defined processing.
--
-- The hash function maps Asis.Element objects into N discrete classes
-- ("buckets") of objects. A good hash function is uniform across its range.
-- It is important to note that the distribution of objects in the
-- application's domain will affect the distribution of the hash function.
-- A good hash measured against one domain will not necessarily be good when
-- fed objects from a different set.
--
-- A continuous uniform hash can be divided by any N and provide a uniform
-- distribution of objects to each of the N discrete classes. A hash value is
-- not unique for each hashed Asis.Element. The application is responsible for
-- handling name collisions of the hashed value.
--
-- The hash function returns a hashed value of type ASIS_Integer. If desired,
-- a user could easily map ASIS_Integer'Range to any smaller range for the
-- hash based on application constraints (i.e., the application implementor
-- can tune the time-space tradeoffs by choosing a small table, implying
-- slower lookups within each "bucket", or a large table, implying faster
-- lookups within each "bucket").
-------------------------------------------------------------------------------
end Asis.Elements;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
reznikmm/webidl | Ada | 800 | adb | -- SPDX-FileCopyrightText: 2021 Max Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package body WebIDL.Lexers is
procedure Initialize
(Self : in out Lexer'Class;
Text : League.String_Vectors.Universal_String_Vector) is
begin
Self.Handler.Initialize;
Self.Source.Set_String_Vector (Text);
Self.Scanner.Set_Source (Self.Source'Unchecked_Access);
Self.Scanner.Set_Handler (Self.Handler'Unchecked_Access);
end Initialize;
----------------
-- Next_Token --
----------------
overriding procedure Next_Token
(Self : in out Lexer;
Value : out WebIDL.Tokens.Token)
is
begin
Self.Scanner.Get_Token (Value);
end Next_Token;
end WebIDL.Lexers;
|
reznikmm/matreshka | Ada | 3,977 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Edition_Attributes;
package Matreshka.ODF_Text.Edition_Attributes is
type Text_Edition_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Edition_Attributes.ODF_Text_Edition_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Edition_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Edition_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Edition_Attributes;
|
guillaume-lin/tsc | Ada | 15,557 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000,2004 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.2 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- TODO use Default_Character where appropriate
-- This is an Ada version of ncurses
-- I translated this because it tests the most features.
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Trace; use Terminal_Interface.Curses.Trace;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;
-- with Ada.Characters.Handling;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Unbounded;
with ncurses2.util; use ncurses2.util;
with ncurses2.getch_test;
with ncurses2.attr_test;
with ncurses2.color_test;
with ncurses2.demo_panels;
with ncurses2.color_edit;
with ncurses2.slk_test;
with ncurses2.acs_display;
with ncurses2.color_edit;
with ncurses2.acs_and_scroll;
with ncurses2.flushinp_test;
with ncurses2.test_sgr_attributes;
with ncurses2.menu_test;
with ncurses2.demo_pad;
with ncurses2.demo_forms;
with ncurses2.overlap_test;
with ncurses2.trace_set;
with ncurses2.getopt; use ncurses2.getopt;
package body ncurses2.m is
use Int_IO;
function To_trace (n : Integer) return Trace_Attribute_Set;
procedure usage;
procedure Set_Terminal_Modes;
function Do_Single_Test (c : Character) return Boolean;
function To_trace (n : Integer) return Trace_Attribute_Set is
a : Trace_Attribute_Set := (others => False);
m : Integer;
rest : Integer;
begin
m := n mod 2;
if 1 = m then
a.Times := True;
end if;
rest := n / 2;
m := rest mod 2;
if 1 = m then
a.Tputs := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Update := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Cursor_Move := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Character_Output := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Virtual_Puts := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Input_Events := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.TTY_State := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Internal_Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Character_Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Termcap_TermInfo := True;
end if;
return a;
end To_trace;
-- these are type Stdscr_Init_Proc;
function rip_footer (
Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, rip_footer);
function rip_footer (
Win : Window;
Columns : Column_Count) return Integer is
begin
Set_Background (Win, (Ch => ' ',
Attr => (Reverse_Video => True, others => False),
Color => 0));
Erase (Win);
Move_Cursor (Win, 0, 0);
Add (Win, "footer:" & Columns'Img & " columns");
Refresh_Without_Update (Win);
return 0; -- Curses_OK;
end rip_footer;
function rip_header (
Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, rip_header);
function rip_header (
Win : Window;
Columns : Column_Count) return Integer is
begin
Set_Background (Win, (Ch => ' ',
Attr => (Reverse_Video => True, others => False),
Color => 0));
Erase (Win);
Move_Cursor (Win, 0, 0);
Add (Win, "header:" & Columns'Img & " columns");
-- 'Img is a GNAT extention
Refresh_Without_Update (Win);
return 0; -- Curses_OK;
end rip_header;
procedure usage is
-- type Stringa is access String;
use Ada.Strings.Unbounded;
-- tbl : constant array (Positive range <>) of Stringa := (
tbl : constant array (Positive range <>) of Unbounded_String
:= (
To_Unbounded_String ("Usage: ncurses [options]"),
To_Unbounded_String (""),
To_Unbounded_String ("Options:"),
To_Unbounded_String (" -a f,b set default-colors " &
"(assumed white-on-black)"),
To_Unbounded_String (" -d use default-colors if terminal " &
"supports them"),
To_Unbounded_String (" -e fmt specify format for soft-keys " &
"test (e)"),
To_Unbounded_String (" -f rip-off footer line " &
"(can repeat)"),
To_Unbounded_String (" -h rip-off header line " &
"(can repeat)"),
To_Unbounded_String (" -s msec specify nominal time for " &
"panel-demo (default: 1, to hold)"),
To_Unbounded_String (" -t mask specify default trace-level " &
"(may toggle with ^T)")
);
begin
for n in tbl'Range loop
Put_Line (Standard_Error, To_String (tbl (n)));
end loop;
-- exit(EXIT_FAILURE);
-- TODO should we use Set_Exit_Status and throw and exception?
end usage;
procedure Set_Terminal_Modes is begin
Set_Raw_Mode (SwitchOn => False);
Set_Cbreak_Mode (SwitchOn => True);
Set_Echo_Mode (SwitchOn => False);
Allow_Scrolling (Mode => True);
Use_Insert_Delete_Line (Do_Idl => True);
Set_KeyPad_Mode (SwitchOn => True);
end Set_Terminal_Modes;
nap_msec : Integer := 1;
function Do_Single_Test (c : Character) return Boolean is
begin
case c is
when 'a' =>
getch_test;
when 'b' =>
attr_test;
when 'c' =>
if not Has_Colors then
Cannot ("does not support color.");
else
color_test;
end if;
when 'd' =>
if not Has_Colors then
Cannot ("does not support color.");
elsif not Can_Change_Color then
Cannot ("has hardwired color values.");
else
color_edit;
end if;
when 'e' =>
slk_test;
when 'f' =>
acs_display;
when 'o' =>
demo_panels (nap_msec);
when 'g' =>
acs_and_scroll;
when 'i' =>
flushinp_test (Standard_Window);
when 'k' =>
test_sgr_attributes;
when 'm' =>
menu_test;
when 'p' =>
demo_pad;
when 'r' =>
demo_forms;
when 's' =>
overlap_test;
when 't' =>
trace_set;
when '?' =>
null;
when others => return False;
end case;
return True;
end Do_Single_Test;
command : Character;
my_e_param : Soft_Label_Key_Format := Four_Four;
assumed_colors : Boolean := False;
default_colors : Boolean := False;
default_fg : Color_Number := White;
default_bg : Color_Number := Black;
-- nap_msec was an unsigned long integer in the C version,
-- yet napms only takes an int!
c : Integer;
c2 : Character;
optind : Integer := 1; -- must be initialized to one.
optarg : getopt.stringa;
length : Integer;
tmpi : Integer;
package myio is new Ada.Text_IO.Integer_IO (Integer);
use myio;
save_trace : Integer := 0;
save_trace_set : Trace_Attribute_Set;
function main return Integer is
begin
loop
Qgetopt (c, Argument_Count, Argument'Access,
"a:de:fhs:t:", optind, optarg);
exit when c = -1;
c2 := Character'Val (c);
case c2 is
when 'a' =>
-- Ada doesn't have scanf, it doesn't even have a
-- regular expression library.
assumed_colors := True;
myio.Get (optarg.all, Integer (default_fg), length);
myio.Get (optarg.all (length + 2 .. optarg.all'Length),
Integer (default_bg), length);
when 'd' =>
default_colors := True;
when 'e' =>
myio.Get (optarg.all, tmpi, length);
if Integer (tmpi) > 3 then
usage;
return 1;
end if;
my_e_param := Soft_Label_Key_Format'Val (tmpi);
when 'f' =>
Rip_Off_Lines (-1, rip_footer'Access);
when 'h' =>
Rip_Off_Lines (1, rip_header'Access);
when 's' =>
myio.Get (optarg.all, nap_msec, length);
when 't' =>
myio.Get (optarg.all, save_trace, length);
when others =>
usage;
return 1;
end case;
end loop;
-- the C version had a bunch of macros here.
-- if (!isatty(fileno(stdin)))
-- isatty is not available in the standard Ada so skip it.
save_trace_set := To_trace (save_trace);
Trace_On (save_trace_set);
Init_Soft_Label_Keys (my_e_param);
Init_Screen;
Set_Background (Ch => (Ch => Blank,
Attr => Normal_Video,
Color => Color_Pair'First));
if Has_Colors then
Start_Color;
if default_colors then
Use_Default_Colors;
elsif assumed_colors then
Assume_Default_Colors (default_fg, default_bg);
end if;
end if;
Set_Terminal_Modes;
Save_Curses_Mode (Curses);
End_Windows;
-- TODO add macro #if blocks.
Put_Line ("Welcome to " & Curses_Version & ". Press ? for help.");
loop
Put_Line ("This is the ncurses main menu");
Put_Line ("a = keyboard and mouse input test");
Put_Line ("b = character attribute test");
Put_Line ("c = color test pattern");
Put_Line ("d = edit RGB color values");
Put_Line ("e = exercise soft keys");
Put_Line ("f = display ACS characters");
Put_Line ("g = display windows and scrolling");
Put_Line ("i = test of flushinp()");
Put_Line ("k = display character attributes");
Put_Line ("m = menu code test");
Put_Line ("o = exercise panels library");
Put_Line ("p = exercise pad features");
Put_Line ("q = quit");
Put_Line ("r = exercise forms code");
Put_Line ("s = overlapping-refresh test");
Put_Line ("t = set trace level");
Put_Line ("? = repeat this command summary");
Put ("> ");
Flush;
command := Ada.Characters.Latin_1.NUL;
-- get_input:
-- loop
declare
Ch : Character;
begin
Get (Ch);
-- TODO if read(ch) <= 0
-- TODO ada doesn't have an Is_Space function
command := Ch;
-- TODO if ch = '\n' or '\r' are these in Ada?
end;
-- end loop get_input;
declare
begin
if Do_Single_Test (command) then
Flush_Input;
Set_Terminal_Modes;
Reset_Curses_Mode (Curses);
Clear;
Refresh;
End_Windows;
if command = '?' then
Put_Line ("This is the ncurses capability tester.");
Put_Line ("You may select a test from the main menu by " &
"typing the");
Put_Line ("key letter of the choice (the letter to left " &
"of the =)");
Put_Line ("at the > prompt. The commands `x' or `q' will " &
"exit.");
end if;
-- continue; --why continue in the C version?
end if;
exception
when Curses_Exception => End_Windows;
end;
exit when command = 'q';
end loop;
return 0; -- TODO ExitProgram(EXIT_SUCCESS);
end main;
end ncurses2.m;
|
sungyeon/drake | Ada | 347 | ads | pragma License (Unrestricted);
-- Ada 2012, specialized for Windows
package System.Multiprocessors is
pragma Preelaborate;
type CPU_Range is range 0 .. Integer'Last;
Not_A_Specific_CPU : constant CPU_Range := 0;
subtype CPU is CPU_Range range 1 .. CPU_Range'Last;
function Number_Of_CPUs return CPU;
end System.Multiprocessors;
|
persan/a-libpcap | Ada | 57,675 | ads | -- begin read only
pragma Ada_2012;
pragma Style_Checks (Off);
pragma Warnings (Off); -- Since this is automaticly generated
with Interfaces.C; use Interfaces.C;
package PCAP.Low_Level.pcap_bpf_h is
BPF_RELEASE : constant := 199606; -- /usr/include/pcap/bpf.h:79
-- unsupported macro: BPF_ALIGNMENT sizeof(bpf_int32)
-- arg-macro: function BPF_WORDALIGN (x)
-- return ((x)+(BPF_ALIGNMENT-1))and~(BPF_ALIGNMENT-1);
DLT_NULL : constant := 0; -- /usr/include/pcap/bpf.h:132
DLT_EN10MB : constant := 1; -- /usr/include/pcap/bpf.h:133
DLT_EN3MB : constant := 2; -- /usr/include/pcap/bpf.h:134
DLT_AX25 : constant := 3; -- /usr/include/pcap/bpf.h:135
DLT_PRONET : constant := 4; -- /usr/include/pcap/bpf.h:136
DLT_CHAOS : constant := 5; -- /usr/include/pcap/bpf.h:137
DLT_IEEE802 : constant := 6; -- /usr/include/pcap/bpf.h:138
DLT_ARCNET : constant := 7; -- /usr/include/pcap/bpf.h:139
DLT_SLIP : constant := 8; -- /usr/include/pcap/bpf.h:140
DLT_PPP : constant := 9; -- /usr/include/pcap/bpf.h:141
DLT_FDDI : constant := 10; -- /usr/include/pcap/bpf.h:142
DLT_ATM_RFC1483 : constant := 11; -- /usr/include/pcap/bpf.h:153
DLT_RAW : constant := 12; -- /usr/include/pcap/bpf.h:158
DLT_SLIP_BSDOS : constant := 15; -- /usr/include/pcap/bpf.h:173
DLT_PPP_BSDOS : constant := 16; -- /usr/include/pcap/bpf.h:174
DLT_ATM_CLIP : constant := 19; -- /usr/include/pcap/bpf.h:209
DLT_REDBACK_SMARTEDGE : constant := 32; -- /usr/include/pcap/bpf.h:215
DLT_PPP_SERIAL : constant := 50; -- /usr/include/pcap/bpf.h:222
DLT_PPP_ETHER : constant := 51; -- /usr/include/pcap/bpf.h:223
DLT_SYMANTEC_FIREWALL : constant := 99; -- /usr/include/pcap/bpf.h:232
DLT_MATCHING_MIN : constant := 104; -- /usr/include/pcap/bpf.h:251
DLT_C_HDLC : constant := 104; -- /usr/include/pcap/bpf.h:267
-- unsupported macro: DLT_CHDLC DLT_C_HDLC
DLT_IEEE802_11 : constant := 105; -- /usr/include/pcap/bpf.h:270
DLT_FRELAY : constant := 107; -- /usr/include/pcap/bpf.h:285
DLT_LOOP : constant := 108; -- /usr/include/pcap/bpf.h:297
DLT_ENC : constant := 109; -- /usr/include/pcap/bpf.h:308
DLT_LINUX_SLL : constant := 113; -- /usr/include/pcap/bpf.h:321
DLT_LTALK : constant := 114; -- /usr/include/pcap/bpf.h:326
DLT_ECONET : constant := 115; -- /usr/include/pcap/bpf.h:331
DLT_IPFILTER : constant := 116; -- /usr/include/pcap/bpf.h:336
DLT_PFLOG : constant := 117; -- /usr/include/pcap/bpf.h:341
DLT_CISCO_IOS : constant := 118; -- /usr/include/pcap/bpf.h:346
DLT_PRISM_HEADER : constant := 119; -- /usr/include/pcap/bpf.h:353
DLT_AIRONET_HEADER : constant := 120; -- /usr/include/pcap/bpf.h:359
DLT_HHDLC : constant := 121; -- /usr/include/pcap/bpf.h:402
DLT_IP_OVER_FC : constant := 122; -- /usr/include/pcap/bpf.h:413
DLT_SUNATM : constant := 123; -- /usr/include/pcap/bpf.h:429
DLT_RIO : constant := 124; -- /usr/include/pcap/bpf.h:435
DLT_PCI_EXP : constant := 125; -- /usr/include/pcap/bpf.h:436
DLT_AURORA : constant := 126; -- /usr/include/pcap/bpf.h:437
DLT_IEEE802_11_RADIO : constant := 127; -- /usr/include/pcap/bpf.h:444
DLT_TZSP : constant := 128; -- /usr/include/pcap/bpf.h:454
DLT_ARCNET_LINUX : constant := 129; -- /usr/include/pcap/bpf.h:467
DLT_JUNIPER_MLPPP : constant := 130; -- /usr/include/pcap/bpf.h:475
DLT_JUNIPER_MLFR : constant := 131; -- /usr/include/pcap/bpf.h:476
DLT_JUNIPER_ES : constant := 132; -- /usr/include/pcap/bpf.h:477
DLT_JUNIPER_GGSN : constant := 133; -- /usr/include/pcap/bpf.h:478
DLT_JUNIPER_MFR : constant := 134; -- /usr/include/pcap/bpf.h:479
DLT_JUNIPER_ATM2 : constant := 135; -- /usr/include/pcap/bpf.h:480
DLT_JUNIPER_SERVICES : constant := 136; -- /usr/include/pcap/bpf.h:481
DLT_JUNIPER_ATM1 : constant := 137; -- /usr/include/pcap/bpf.h:482
DLT_APPLE_IP_OVER_IEEE1394 : constant := 138; -- /usr/include/pcap/bpf.h:499
DLT_MTP2_WITH_PHDR : constant := 139; -- /usr/include/pcap/bpf.h:505
DLT_MTP2 : constant := 140; -- /usr/include/pcap/bpf.h:506
DLT_MTP3 : constant := 141; -- /usr/include/pcap/bpf.h:507
DLT_SCCP : constant := 142; -- /usr/include/pcap/bpf.h:508
DLT_DOCSIS : constant := 143; -- /usr/include/pcap/bpf.h:513
DLT_LINUX_IRDA : constant := 144; -- /usr/include/pcap/bpf.h:530
DLT_IBM_SP : constant := 145; -- /usr/include/pcap/bpf.h:535
DLT_IBM_SN : constant := 146; -- /usr/include/pcap/bpf.h:536
DLT_USER0 : constant := 147; -- /usr/include/pcap/bpf.h:563
DLT_USER1 : constant := 148; -- /usr/include/pcap/bpf.h:564
DLT_USER2 : constant := 149; -- /usr/include/pcap/bpf.h:565
DLT_USER3 : constant := 150; -- /usr/include/pcap/bpf.h:566
DLT_USER4 : constant := 151; -- /usr/include/pcap/bpf.h:567
DLT_USER5 : constant := 152; -- /usr/include/pcap/bpf.h:568
DLT_USER6 : constant := 153; -- /usr/include/pcap/bpf.h:569
DLT_USER7 : constant := 154; -- /usr/include/pcap/bpf.h:570
DLT_USER8 : constant := 155; -- /usr/include/pcap/bpf.h:571
DLT_USER9 : constant := 156; -- /usr/include/pcap/bpf.h:572
DLT_USER10 : constant := 157; -- /usr/include/pcap/bpf.h:573
DLT_USER11 : constant := 158; -- /usr/include/pcap/bpf.h:574
DLT_USER12 : constant := 159; -- /usr/include/pcap/bpf.h:575
DLT_USER13 : constant := 160; -- /usr/include/pcap/bpf.h:576
DLT_USER14 : constant := 161; -- /usr/include/pcap/bpf.h:577
DLT_USER15 : constant := 162; -- /usr/include/pcap/bpf.h:578
DLT_IEEE802_11_RADIO_AVS : constant := 163; -- /usr/include/pcap/bpf.h:590
DLT_JUNIPER_MONITOR : constant := 164; -- /usr/include/pcap/bpf.h:598
DLT_BACNET_MS_TP : constant := 165; -- /usr/include/pcap/bpf.h:603
DLT_PPP_PPPD : constant := 166; -- /usr/include/pcap/bpf.h:619
-- unsupported macro: DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD
-- unsupported macro: DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD
DLT_JUNIPER_PPPOE : constant := 167; -- /usr/include/pcap/bpf.h:634
DLT_JUNIPER_PPPOE_ATM : constant := 168; -- /usr/include/pcap/bpf.h:635
DLT_GPRS_LLC : constant := 169; -- /usr/include/pcap/bpf.h:637
DLT_GPF_T : constant := 170; -- /usr/include/pcap/bpf.h:638
DLT_GPF_F : constant := 171; -- /usr/include/pcap/bpf.h:639
DLT_GCOM_T1E1 : constant := 172; -- /usr/include/pcap/bpf.h:645
DLT_GCOM_SERIAL : constant := 173; -- /usr/include/pcap/bpf.h:646
DLT_JUNIPER_PIC_PEER : constant := 174; -- /usr/include/pcap/bpf.h:653
DLT_ERF_ETH : constant := 175; -- /usr/include/pcap/bpf.h:661
DLT_ERF_POS : constant := 176; -- /usr/include/pcap/bpf.h:662
DLT_LINUX_LAPD : constant := 177; -- /usr/include/pcap/bpf.h:670
DLT_JUNIPER_ETHER : constant := 178; -- /usr/include/pcap/bpf.h:679
DLT_JUNIPER_PPP : constant := 179; -- /usr/include/pcap/bpf.h:680
DLT_JUNIPER_FRELAY : constant := 180; -- /usr/include/pcap/bpf.h:681
DLT_JUNIPER_CHDLC : constant := 181; -- /usr/include/pcap/bpf.h:682
DLT_MFR : constant := 182; -- /usr/include/pcap/bpf.h:687
DLT_JUNIPER_VP : constant := 183; -- /usr/include/pcap/bpf.h:695
DLT_A429 : constant := 184; -- /usr/include/pcap/bpf.h:704
DLT_A653_ICM : constant := 185; -- /usr/include/pcap/bpf.h:711
DLT_USB : constant := 186; -- /usr/include/pcap/bpf.h:717
DLT_BLUETOOTH_HCI_H4 : constant := 187; -- /usr/include/pcap/bpf.h:723
DLT_IEEE802_16_MAC_CPS : constant := 188; -- /usr/include/pcap/bpf.h:729
DLT_USB_LINUX : constant := 189; -- /usr/include/pcap/bpf.h:735
DLT_CAN20B : constant := 190; -- /usr/include/pcap/bpf.h:744
DLT_IEEE802_15_4_LINUX : constant := 191; -- /usr/include/pcap/bpf.h:750
DLT_PPI : constant := 192; -- /usr/include/pcap/bpf.h:756
DLT_IEEE802_16_MAC_CPS_RADIO : constant := 193; -- /usr/include/pcap/bpf.h:762
DLT_JUNIPER_ISM : constant := 194; -- /usr/include/pcap/bpf.h:770
DLT_IEEE802_15_4 : constant := 195; -- /usr/include/pcap/bpf.h:778
DLT_SITA : constant := 196; -- /usr/include/pcap/bpf.h:784
DLT_ERF : constant := 197; -- /usr/include/pcap/bpf.h:791
DLT_RAIF1 : constant := 198; -- /usr/include/pcap/bpf.h:798
DLT_IPMB : constant := 199; -- /usr/include/pcap/bpf.h:805
DLT_JUNIPER_ST : constant := 200; -- /usr/include/pcap/bpf.h:812
DLT_BLUETOOTH_HCI_H4_WITH_PHDR : constant := 201; -- /usr/include/pcap/bpf.h:818
DLT_AX25_KISS : constant := 202; -- /usr/include/pcap/bpf.h:827
DLT_LAPD : constant := 203; -- /usr/include/pcap/bpf.h:834
DLT_PPP_WITH_DIR : constant := 204; -- /usr/include/pcap/bpf.h:842
DLT_C_HDLC_WITH_DIR : constant := 205; -- /usr/include/pcap/bpf.h:843
DLT_FRELAY_WITH_DIR : constant := 206; -- /usr/include/pcap/bpf.h:844
DLT_LAPB_WITH_DIR : constant := 207; -- /usr/include/pcap/bpf.h:845
DLT_IPMB_LINUX : constant := 209; -- /usr/include/pcap/bpf.h:856
DLT_FLEXRAY : constant := 210; -- /usr/include/pcap/bpf.h:862
DLT_MOST : constant := 211; -- /usr/include/pcap/bpf.h:869
DLT_LIN : constant := 212; -- /usr/include/pcap/bpf.h:876
DLT_X2E_SERIAL : constant := 213; -- /usr/include/pcap/bpf.h:882
DLT_X2E_XORAYA : constant := 214; -- /usr/include/pcap/bpf.h:888
DLT_IEEE802_15_4_NONASK_PHY : constant := 215; -- /usr/include/pcap/bpf.h:899
DLT_LINUX_EVDEV : constant := 216; -- /usr/include/pcap/bpf.h:907
DLT_GSMTAP_UM : constant := 217; -- /usr/include/pcap/bpf.h:914
DLT_GSMTAP_ABIS : constant := 218; -- /usr/include/pcap/bpf.h:915
DLT_MPLS : constant := 219; -- /usr/include/pcap/bpf.h:922
DLT_USB_LINUX_MMAPPED : constant := 220; -- /usr/include/pcap/bpf.h:928
DLT_DECT : constant := 221; -- /usr/include/pcap/bpf.h:934
DLT_AOS : constant := 222; -- /usr/include/pcap/bpf.h:945
DLT_WIHART : constant := 223; -- /usr/include/pcap/bpf.h:954
DLT_FC_2 : constant := 224; -- /usr/include/pcap/bpf.h:960
DLT_FC_2_WITH_FRAME_DELIMS : constant := 225; -- /usr/include/pcap/bpf.h:974
DLT_IPNET : constant := 226; -- /usr/include/pcap/bpf.h:1022
DLT_CAN_SOCKETCAN : constant := 227; -- /usr/include/pcap/bpf.h:1031
DLT_IPV4 : constant := 228; -- /usr/include/pcap/bpf.h:1037
DLT_IPV6 : constant := 229; -- /usr/include/pcap/bpf.h:1038
DLT_IEEE802_15_4_NOFCS : constant := 230; -- /usr/include/pcap/bpf.h:1045
DLT_DBUS : constant := 231; -- /usr/include/pcap/bpf.h:1063
DLT_JUNIPER_VS : constant := 232; -- /usr/include/pcap/bpf.h:1069
DLT_JUNIPER_SRX_E2E : constant := 233; -- /usr/include/pcap/bpf.h:1070
DLT_JUNIPER_FIBRECHANNEL : constant := 234; -- /usr/include/pcap/bpf.h:1071
DLT_DVB_CI : constant := 235; -- /usr/include/pcap/bpf.h:1083
DLT_MUX27010 : constant := 236; -- /usr/include/pcap/bpf.h:1090
DLT_STANAG_5066_D_PDU : constant := 237; -- /usr/include/pcap/bpf.h:1096
DLT_JUNIPER_ATM_CEMIC : constant := 238; -- /usr/include/pcap/bpf.h:1102
DLT_NFLOG : constant := 239; -- /usr/include/pcap/bpf.h:1110
DLT_NETANALYZER : constant := 240; -- /usr/include/pcap/bpf.h:1120
DLT_NETANALYZER_TRANSPARENT : constant := 241; -- /usr/include/pcap/bpf.h:1131
DLT_IPOIB : constant := 242; -- /usr/include/pcap/bpf.h:1138
DLT_MPEG_2_TS : constant := 243; -- /usr/include/pcap/bpf.h:1145
DLT_NG40 : constant := 244; -- /usr/include/pcap/bpf.h:1153
DLT_NFC_LLCP : constant := 245; -- /usr/include/pcap/bpf.h:1163
DLT_PFSYNC : constant := 246; -- /usr/include/pcap/bpf.h:1173
DLT_INFINIBAND : constant := 247; -- /usr/include/pcap/bpf.h:1181
DLT_SCTP : constant := 248; -- /usr/include/pcap/bpf.h:1188
DLT_USBPCAP : constant := 249; -- /usr/include/pcap/bpf.h:1195
DLT_RTAC_SERIAL : constant := 250; -- /usr/include/pcap/bpf.h:1203
DLT_BLUETOOTH_LE_LL : constant := 251; -- /usr/include/pcap/bpf.h:1210
DLT_WIRESHARK_UPPER_PDU : constant := 252; -- /usr/include/pcap/bpf.h:1223
DLT_NETLINK : constant := 253; -- /usr/include/pcap/bpf.h:1228
DLT_BLUETOOTH_LINUX_MONITOR : constant := 254; -- /usr/include/pcap/bpf.h:1233
DLT_BLUETOOTH_BREDR_BB : constant := 255; -- /usr/include/pcap/bpf.h:1239
DLT_BLUETOOTH_LE_LL_WITH_PHDR : constant := 256; -- /usr/include/pcap/bpf.h:1244
DLT_PROFIBUS_DL : constant := 257; -- /usr/include/pcap/bpf.h:1249
DLT_PKTAP : constant := 258; -- /usr/include/pcap/bpf.h:1298
DLT_EPON : constant := 259; -- /usr/include/pcap/bpf.h:1306
DLT_IPMI_HPM_2 : constant := 260; -- /usr/include/pcap/bpf.h:1312
DLT_MATCHING_MAX : constant := 260; -- /usr/include/pcap/bpf.h:1314
-- arg-macro: function DLT_CLASS (x)
-- return (x) and 16#03ff0000#;
DLT_CLASS_NETBSD_RAWAF : constant := 16#02240000#; -- /usr/include/pcap/bpf.h:1330
-- arg-macro: function DLT_NETBSD_RAWAF (af)
-- return DLT_CLASS_NETBSD_RAWAF or (af);
-- arg-macro: function DLT_NETBSD_RAWAF_AF (x)
-- return (x) and 16#0000ffff#;
-- arg-macro: function DLT_IS_NETBSD_RAWAF (x)
-- return DLT_CLASS(x) = DLT_CLASS_NETBSD_RAWAF;
-- arg-macro: function BPF_CLASS (code)
-- return (code) and 16#07#;
BPF_LD : constant := 16#00#; -- /usr/include/pcap/bpf.h:1351
BPF_LDX : constant := 16#01#; -- /usr/include/pcap/bpf.h:1352
BPF_ST : constant := 16#02#; -- /usr/include/pcap/bpf.h:1353
BPF_STX : constant := 16#03#; -- /usr/include/pcap/bpf.h:1354
BPF_ALU : constant := 16#04#; -- /usr/include/pcap/bpf.h:1355
BPF_JMP : constant := 16#05#; -- /usr/include/pcap/bpf.h:1356
BPF_RET : constant := 16#06#; -- /usr/include/pcap/bpf.h:1357
BPF_MISC : constant := 16#07#; -- /usr/include/pcap/bpf.h:1358
-- arg-macro: function BPF_SIZE (code)
-- return (code) and 16#18#;
BPF_W : constant := 16#00#; -- /usr/include/pcap/bpf.h:1362
BPF_H : constant := 16#08#; -- /usr/include/pcap/bpf.h:1363
BPF_B : constant := 16#10#; -- /usr/include/pcap/bpf.h:1364
-- arg-macro: function BPF_MODE (code)
-- return (code) and 16#e0#;
BPF_IMM : constant := 16#00#; -- /usr/include/pcap/bpf.h:1367
BPF_ABS : constant := 16#20#; -- /usr/include/pcap/bpf.h:1368
BPF_IND : constant := 16#40#; -- /usr/include/pcap/bpf.h:1369
BPF_MEM : constant := 16#60#; -- /usr/include/pcap/bpf.h:1370
BPF_LEN : constant := 16#80#; -- /usr/include/pcap/bpf.h:1371
BPF_MSH : constant := 16#a0#; -- /usr/include/pcap/bpf.h:1372
-- arg-macro: function BPF_OP (code)
-- return (code) and 16#f0#;
BPF_ADD : constant := 16#00#; -- /usr/include/pcap/bpf.h:1378
BPF_SUB : constant := 16#10#; -- /usr/include/pcap/bpf.h:1379
BPF_MUL : constant := 16#20#; -- /usr/include/pcap/bpf.h:1380
BPF_DIV : constant := 16#30#; -- /usr/include/pcap/bpf.h:1381
BPF_OR : constant := 16#40#; -- /usr/include/pcap/bpf.h:1382
BPF_AND : constant := 16#50#; -- /usr/include/pcap/bpf.h:1383
BPF_LSH : constant := 16#60#; -- /usr/include/pcap/bpf.h:1384
BPF_RSH : constant := 16#70#; -- /usr/include/pcap/bpf.h:1385
BPF_NEG : constant := 16#80#; -- /usr/include/pcap/bpf.h:1386
BPF_MOD : constant := 16#90#; -- /usr/include/pcap/bpf.h:1387
BPF_XOR : constant := 16#a0#; -- /usr/include/pcap/bpf.h:1388
BPF_JA : constant := 16#00#; -- /usr/include/pcap/bpf.h:1395
BPF_JEQ : constant := 16#10#; -- /usr/include/pcap/bpf.h:1396
BPF_JGT : constant := 16#20#; -- /usr/include/pcap/bpf.h:1397
BPF_JGE : constant := 16#30#; -- /usr/include/pcap/bpf.h:1398
BPF_JSET : constant := 16#40#; -- /usr/include/pcap/bpf.h:1399
-- arg-macro: function BPF_SRC (code)
-- return (code) and 16#08#;
BPF_K : constant := 16#00#; -- /usr/include/pcap/bpf.h:1412
BPF_X : constant := 16#08#; -- /usr/include/pcap/bpf.h:1413
-- arg-macro: function BPF_RVAL (code)
-- return (code) and 16#18#;
BPF_A : constant := 16#10#; -- /usr/include/pcap/bpf.h:1417
-- arg-macro: function BPF_MISCOP (code)
-- return (code) and 16#f8#;
BPF_TAX : constant := 16#00#; -- /usr/include/pcap/bpf.h:1422
BPF_TXA : constant := 16#80#; -- /usr/include/pcap/bpf.h:1439
-- arg-macro: procedure BPF_STMT (code, k)
-- { (u_short)(code), 0, 0, k }
-- arg-macro: procedure BPF_JUMP (code, k, jt, jf)
-- { (u_short)(code), jt, jf, k }
BPF_MEMWORDS : constant := 16; -- /usr/include/pcap/bpf.h:1483
---
-- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
-- * The Regents of the University of California. All rights reserved.
-- *
-- * This code is derived from the Stanford/CMU enet packet filter,
-- * (net/enet.c) distributed as part of 4.3BSD, and code contributed
-- * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
-- * Berkeley Laboratory.
-- *
-- * 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. All advertising materials mentioning features or use of this software
-- * must display the following acknowledgement:
-- * This product includes software developed by the University of
-- * California, Berkeley and its contributors.
-- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
-- *
-- * @(#)bpf.h 7.1 (Berkeley) 5/7/91
--
-- * This is libpcap's cut-down version of bpf.h; it includes only
-- * the stuff needed for the code generator and the userland BPF
-- * interpreter, and the libpcap APIs for setting filters, etc..
-- *
-- * "pcap-bpf.c" will include the native OS version, as it deals with
-- * the OS's BPF implementation.
-- *
-- * At least two programs found by Google Code Search explicitly includes
-- * <pcap/bpf.h> (even though <pcap.h>/<pcap/pcap.h> includes it for you),
-- * so moving that stuff to <pcap/pcap.h> would break the build for some
-- * programs.
--
-- * If we've already included <net/bpf.h>, don't re-define this stuff.
-- * We assume BSD-style multiple-include protection in <net/bpf.h>,
-- * which is true of all but the oldest versions of FreeBSD and NetBSD,
-- * or Tru64 UNIX-style multiple-include protection (or, at least,
-- * Tru64 UNIX 5.x-style; I don't have earlier versions available to check),
-- * or AIX-style multiple-include protection (or, at least, AIX 5.x-style;
-- * I don't have earlier versions available to check).
-- *
-- * We do not check for BPF_MAJOR_VERSION, as that's defined by
-- * <linux/filter.h>, which is directly or indirectly included in some
-- * programs that also include pcap.h, and <linux/filter.h> doesn't
-- * define stuff we need.
-- *
-- * This also provides our own multiple-include protection.
--
-- BSD style release date
subtype bpf_int32 is int; -- /usr/include/pcap/bpf.h:85
subtype bpf_u_int32 is unsigned; -- /usr/include/pcap/bpf.h:86
-- * Alignment macros. BPF_WORDALIGN rounds up to the next
-- * even multiple of BPF_ALIGNMENT.
-- *
-- * Tcpdump's print-pflog.c uses this, so we define it here.
--
-- * Structure for "pcap_compile()", "pcap_setfilter()", etc..
--
type bpf_insn;
type bpf_program is record
bf_len : aliased unsigned; -- /usr/include/pcap/bpf.h:106
bf_insns : access bpf_insn; -- /usr/include/pcap/bpf.h:107
end record
with Convention => C_Pass_By_Copy; -- /usr/include/pcap/bpf.h:105
-- * Link-layer header type codes.
-- *
-- * Do *NOT* add new values to this list without asking
-- * "[email protected]" for a value. Otherwise, you run
-- * the risk of using a value that's already being used for some other
-- * purpose, and of having tools that read libpcap-format captures not
-- * being able to handle captures with your new DLT_ value, with no hope
-- * that they will ever be changed to do so (as that would destroy their
-- * ability to read captures using that value for that other purpose).
-- *
-- * See
-- *
-- * http://www.tcpdump.org/linktypes.html
-- *
-- * for detailed descriptions of some of these link-layer header types.
--
-- * These are the types that are the same on all platforms, and that
-- * have been defined by <net/bpf.h> for ages.
--
-- * These are types that are different on some platforms, and that
-- * have been defined by <net/bpf.h> for ages. We use #ifdefs to
-- * detect the BSDs that define them differently from the traditional
-- * libpcap <net/bpf.h>
-- *
-- * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS,
-- * but I don't know what the right #define is for BSD/OS.
--
-- * Given that the only OS that currently generates BSD/OS SLIP or PPP
-- * is, well, BSD/OS, arguably everybody should have chosen its values
-- * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they
-- * didn't. So it goes.
--
-- * 17 was used for DLT_PFLOG in OpenBSD; it no longer is.
-- *
-- * It was DLT_LANE8023 in SuSE 6.3, so we defined LINKTYPE_PFLOG
-- * as 117 so that pflog captures would use a link-layer header type
-- * value that didn't collide with any other values. On all
-- * platforms other than OpenBSD, we defined DLT_PFLOG as 117,
-- * and we mapped between LINKTYPE_PFLOG and DLT_PFLOG.
-- *
-- * OpenBSD eventually switched to using 117 for DLT_PFLOG as well.
-- *
-- * Don't use 17 for anything else.
--
-- * 18 is used for DLT_PFSYNC in OpenBSD, NetBSD, DragonFly BSD and
-- * Mac OS X; don't use it for anything else. (FreeBSD uses 121,
-- * which collides with DLT_HHDLC, even though it doesn't use 18
-- * for anything and doesn't appear to have ever used it for anything.)
-- *
-- * We define it as 18 on those platforms; it is, unfortunately, used
-- * for DLT_CIP in Suse 6.3, so we don't define it as DLT_PFSYNC
-- * in general. As the packet format for it, like that for
-- * DLT_PFLOG, is not only OS-dependent but OS-version-dependent,
-- * we don't support printing it in tcpdump except on OSes that
-- * have the relevant header files, so it's not that useful on
-- * other platforms.
--
-- * Apparently Redback uses this for its SmartEdge 400/800. I hope
-- * nobody else decided to use it, too.
--
-- * These values are defined by NetBSD; other platforms should refrain from
-- * using them for other purposes, so that NetBSD savefiles with link
-- * types of 50 or 51 can be read as this type on all platforms.
--
-- * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses
-- * a link-layer type of 99 for the tcpdump it supplies. The link-layer
-- * header has 6 bytes of unknown data, something that appears to be an
-- * Ethernet type, and 36 bytes that appear to be 0 in at least one capture
-- * I've seen.
--
-- * Values between 100 and 103 are used in capture file headers as
-- * link-layer header type LINKTYPE_ values corresponding to DLT_ types
-- * that differ between platforms; don't use those values for new DLT_
-- * new types.
--
-- * Values starting with 104 are used for newly-assigned link-layer
-- * header type values; for those link-layer header types, the DLT_
-- * value returned by pcap_datalink() and passed to pcap_open_dead(),
-- * and the LINKTYPE_ value that appears in capture files, are the
-- * same.
-- *
-- * DLT_MATCHING_MIN is the lowest such value; DLT_MATCHING_MAX is
-- * the highest such value.
--
-- * This value was defined by libpcap 0.5; platforms that have defined
-- * it with a different value should define it here with that value -
-- * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
-- * whatever value that happens to be, so programs will correctly
-- * handle files with that link type regardless of the value of
-- * DLT_C_HDLC.
-- *
-- * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
-- * compatibility with programs written for BSD/OS.
-- *
-- * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
-- * for source compatibility with programs written for libpcap 0.5.
--
-- * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW,
-- * except when it isn't. (I.e., sometimes it's just raw IP, and
-- * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL,
-- * so that we don't have to worry about the link-layer header.)
--
-- * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides
-- * with other values.
-- * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header
-- * (DLCI, etc.).
--
-- * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
-- * that the AF_ type in the link-layer header is in network byte order.
-- *
-- * DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so
-- * we don't use 12 for it in OSes other than OpenBSD.
--
-- * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
-- * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
-- * than OpenBSD.
--
-- * Values between 110 and 112 are reserved for use in capture file headers
-- * as link-layer types corresponding to DLT_ types that might differ
-- * between platforms; don't use those values for new DLT_ types
-- * other than the corresponding DLT_ types.
--
-- * This is for Linux cooked sockets.
--
-- * Apple LocalTalk hardware.
--
-- * Acorn Econet.
--
-- * Reserved for use with OpenBSD ipfilter.
--
-- * OpenBSD DLT_PFLOG.
--
-- * Registered for Cisco-internal use.
--
-- * For 802.11 cards using the Prism II chips, with a link-layer
-- * header including Prism monitor mode information plus an 802.11
-- * header.
--
-- * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
-- * (see Doug Ambrisko's FreeBSD patches).
--
-- * Sigh.
-- *
-- * This was reserved for Siemens HiPath HDLC on 2002-01-25, as
-- * requested by Tomas Kukosa.
-- *
-- * On 2004-02-25, a FreeBSD checkin to sys/net/bpf.h was made that
-- * assigned 121 as DLT_PFSYNC. Its libpcap does DLT_ <-> LINKTYPE_
-- * mapping, so it probably supports capturing on the pfsync device
-- * but not saving the captured data to a pcap file.
-- *
-- * OpenBSD, from which pf came, however, uses 18 for DLT_PFSYNC;
-- * their libpcap does no DLT_ <-> LINKTYPE_ mapping, so it would
-- * use 18 in pcap files as well.
-- *
-- * NetBSD and DragonFly BSD also use 18 for DLT_PFSYNC; their
-- * libpcaps do DLT_ <-> LINKTYPE_ mapping, and neither has an entry
-- * for DLT_PFSYNC, so it might not be able to write out dump files
-- * with 18 as the link-layer header type. (Earlier versions might
-- * not have done mapping, in which case they'd work the same way
-- * OpenBSD does.)
-- *
-- * Mac OS X defines it as 18, but doesn't appear to use it as of
-- * Mac OS X 10.7.3. Its libpcap does DLT_ <-> LINKTYPE_ mapping.
-- *
-- * We'll define DLT_PFSYNC as 121 on FreeBSD and define it as 18 on
-- * all other platforms. We'll define DLT_HHDLC as 121 on everything
-- * except for FreeBSD; anybody who wants to compile, on FreeBSD, code
-- * that uses DLT_HHDLC is out of luck.
-- *
-- * We'll define LINKTYPE_PFSYNC as 18, *even on FreeBSD*, and map
-- * it, so that savefiles won't use 121 for PFSYNC - they'll all
-- * use 18. Code that uses pcap_datalink() to determine the link-layer
-- * header type of a savefile won't, when built and run on FreeBSD,
-- * be able to distinguish between LINKTYPE_PFSYNC and LINKTYPE_HHDLC
-- * capture files; code that doesn't, such as the code in Wireshark,
-- * will be able to distinguish between them.
--
-- * This is for RFC 2625 IP-over-Fibre Channel.
-- *
-- * This is not for use with raw Fibre Channel, where the link-layer
-- * header starts with a Fibre Channel frame header; it's for IP-over-FC,
-- * where the link-layer header starts with an RFC 2625 Network_Header
-- * field.
--
-- * This is for Full Frontal ATM on Solaris with SunATM, with a
-- * pseudo-header followed by an AALn PDU.
-- *
-- * There may be other forms of Full Frontal ATM on other OSes,
-- * with different pseudo-headers.
-- *
-- * If ATM software returns a pseudo-header with VPI/VCI information
-- * (and, ideally, packet type information, e.g. signalling, ILMI,
-- * LANE, LLC-multiplexed traffic, etc.), it should not use
-- * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump
-- * and the like don't have to infer the presence or absence of a
-- * pseudo-header and the form of the pseudo-header.
--
--
-- * Reserved as per request from Kent Dahlgren <[email protected]>
-- * for private use.
--
-- * Header for 802.11 plus a number of bits of link-layer information
-- * including radio information, used by some recent BSD drivers as
-- * well as the madwifi Atheros driver for Linux.
--
-- * Reserved for the TZSP encapsulation, as per request from
-- * Chris Waters <[email protected]>
-- * TZSP is a generic encapsulation for any other link type,
-- * which includes a means to include meta-information
-- * with the packet, e.g. signal strength and channel
-- * for 802.11 packets.
--
-- * BSD's ARCNET headers have the source host, destination host,
-- * and type at the beginning of the packet; that's what's handed
-- * up to userland via BPF.
-- *
-- * Linux's ARCNET headers, however, have a 2-byte offset field
-- * between the host IDs and the type; that's what's handed up
-- * to userland via PF_PACKET sockets.
-- *
-- * We therefore have to have separate DLT_ values for them.
--
-- * Juniper-private data link types, as per request from
-- * Hannes Gredler <[email protected]>. The DLT_s are used
-- * for passing on chassis-internal metainformation such as
-- * QOS profiles, etc..
--
-- * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund
-- * <[email protected]>. The header that's presented is an Ethernet-like
-- * header:
-- *
-- * #define FIREWIRE_EUI64_LEN 8
-- * struct firewire_header {
-- * u_char firewire_dhost[FIREWIRE_EUI64_LEN];
-- * u_char firewire_shost[FIREWIRE_EUI64_LEN];
-- * u_short firewire_type;
-- * };
-- *
-- * with "firewire_type" being an Ethernet type value, rather than,
-- * for example, raw GASP frames being handed up.
--
-- * Various SS7 encapsulations, as per a request from Jeff Morriss
-- * <jeff.morriss[AT]ulticom.com> and subsequent discussions.
--
-- * DOCSIS MAC frames.
--
-- * Linux-IrDA packets. Protocol defined at http://www.irda.org.
-- * Those packets include IrLAP headers and above (IrLMP...), but
-- * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy
-- * framing can be handled by the hardware and depend on the bitrate.
-- * This is exactly the format you would get capturing on a Linux-IrDA
-- * interface (irdaX), but not on a raw serial port.
-- * Note the capture is done in "Linux-cooked" mode, so each packet include
-- * a fake packet header (struct sll_header). This is because IrDA packet
-- * decoding is dependant on the direction of the packet (incomming or
-- * outgoing).
-- * When/if other platform implement IrDA capture, we may revisit the
-- * issue and define a real DLT_IRDA...
-- * Jean II
--
-- * Reserved for IBM SP switch and IBM Next Federation switch.
--
-- * Reserved for private use. If you have some link-layer header type
-- * that you want to use within your organization, with the capture files
-- * using that link-layer header type not ever be sent outside your
-- * organization, you can use these values.
-- *
-- * No libpcap release will use these for any purpose, nor will any
-- * tcpdump release use them, either.
-- *
-- * Do *NOT* use these in capture files that you expect anybody not using
-- * your private versions of capture-file-reading tools to read; in
-- * particular, do *NOT* use them in products, otherwise you may find that
-- * people won't be able to use tcpdump, or snort, or Ethereal, or... to
-- * read capture files from your firewall/intrusion detection/traffic
-- * monitoring/etc. appliance, or whatever product uses that DLT_ value,
-- * and you may also find that the developers of those applications will
-- * not accept patches to let them read those files.
-- *
-- * Also, do not use them if somebody might send you a capture using them
-- * for *their* private type and tools using them for *your* private type
-- * would have to read them.
-- *
-- * Instead, ask "[email protected]" for a new DLT_ value,
-- * as per the comment above, and use the type you're given.
--
-- * For future use with 802.11 captures - defined by AbsoluteValue
-- * Systems to store a number of bits of link-layer information
-- * including radio information:
-- *
-- * http://www.shaftnet.org/~pizza/software/capturefrm.txt
-- *
-- * but it might be used by some non-AVS drivers now or in the
-- * future.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>. The DLT_s are used
-- * for passing on chassis-internal metainformation such as
-- * QOS profiles, etc..
--
-- * BACnet MS/TP frames.
--
-- * Another PPP variant as per request from Karsten Keil <[email protected]>.
-- *
-- * This is used in some OSes to allow a kernel socket filter to distinguish
-- * between incoming and outgoing packets, on a socket intended to
-- * supply pppd with outgoing packets so it can do dial-on-demand and
-- * hangup-on-lack-of-demand; incoming packets are filtered out so they
-- * don't cause pppd to hold the connection up (you don't want random
-- * input packets such as port scans, packets from old lost connections,
-- * etc. to force the connection to stay up).
-- *
-- * The first byte of the PPP header (0xff03) is modified to accomodate
-- * the direction - 0x00 = IN, 0x01 = OUT.
--
-- * Names for backwards compatibility with older versions of some PPP
-- * software; new software should use DLT_PPP_PPPD.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>. The DLT_s are used
-- * for passing on chassis-internal metainformation such as
-- * QOS profiles, cookies, etc..
--
-- * Requested by Oolan Zimmer <[email protected]> for use in Gcom's T1/E1 line
-- * monitoring equipment.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>. The DLT_ is used
-- * for internal communication to Physical Interface Cards (PIC)
--
-- * Link types requested by Gregor Maier <[email protected]> of Endace
-- * Measurement Systems. They add an ERF header (see
-- * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
-- * the link-layer header.
--
-- * Requested by Daniele Orlandi <[email protected]> for raw LAPD
-- * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
-- * includes additional information before the LAPD header, so it's
-- * not necessarily a generic LAPD header.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
-- * The DLT_ are used for prepending meta-information
-- * like interface index, interface name
-- * before standard Ethernet, PPP, Frelay & C-HDLC Frames
--
-- * Multi Link Frame Relay (FRF.16)
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
-- * The DLT_ is used for internal communication with a
-- * voice Adapter Card (PIC)
--
-- * Arinc 429 frames.
-- * DLT_ requested by Gianluca Varenni <[email protected]>.
-- * Every frame contains a 32bit A429 label.
-- * More documentation on Arinc 429 can be found at
-- * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
--
-- * Arinc 653 Interpartition Communication messages.
-- * DLT_ requested by Gianluca Varenni <[email protected]>.
-- * Please refer to the A653-1 standard for more information.
--
-- * USB packets, beginning with a USB setup header; requested by
-- * Paolo Abeni <[email protected]>.
--
-- * Bluetooth HCI UART transport layer (part H:4); requested by
-- * Paolo Abeni.
--
-- * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
-- * <[email protected]>.
--
-- * USB packets, beginning with a Linux USB header; requested by
-- * Paolo Abeni <[email protected]>.
--
-- * Controller Area Network (CAN) v. 2.0B packets.
-- * DLT_ requested by Gianluca Varenni <[email protected]>.
-- * Used to dump CAN packets coming from a CAN Vector board.
-- * More documentation on the CAN v2.0B frames can be found at
-- * http://www.can-cia.org/downloads/?269
--
-- * IEEE 802.15.4, with address fields padded, as is done by Linux
-- * drivers; requested by Juergen Schimmer.
--
-- * Per Packet Information encapsulated packets.
-- * DLT_ requested by Gianluca Varenni <[email protected]>.
--
-- * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
-- * requested by Charles Clancy.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
-- * The DLT_ is used for internal communication with a
-- * integrated service module (ISM).
--
-- * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
-- * nothing); requested by Mikko Saarnivala <[email protected]>.
-- * For this one, we expect the FCS to be present at the end of the frame;
-- * if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be used.
--
-- * Various link-layer types, with a pseudo-header, for SITA
-- * (http://www.sita.aero/); requested by Fulko Hew ([email protected]).
--
-- * Various link-layer types, with a pseudo-header, for Endace DAG cards;
-- * encapsulates Endace ERF records. Requested by Stephen Donnelly
-- * <[email protected]>.
--
-- * Special header prepended to Ethernet packets when capturing from a
-- * u10 Networks board. Requested by Phil Mulholland
-- * <[email protected]>.
--
-- * IPMB packet for IPMI, beginning with the I2C slave address, followed
-- * by the netFn and LUN, etc.. Requested by Chanthy Toeung
-- * <[email protected]>.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
-- * The DLT_ is used for capturing data on a secure tunnel interface.
--
-- * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
-- * that includes direction information; requested by Paolo Abeni.
--
-- * AX.25 packet with a 1-byte KISS header; see
-- *
-- * http://www.ax25.net/kiss.htm
-- *
-- * as per Richard Stearn <[email protected]>.
--
-- * LAPD packets from an ISDN channel, starting with the address field,
-- * with no pseudo-header.
-- * Requested by Varuna De Silva <[email protected]>.
--
-- * Variants of various link-layer headers, with a one-byte direction
-- * pseudo-header prepended - zero means "received by this host",
-- * non-zero (any non-zero value) means "sent by this host" - as per
-- * Will Barker <[email protected]>.
--
-- * 208 is reserved for an as-yet-unspecified proprietary link-layer
-- * type, as requested by Will Barker.
--
-- * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
-- * <[email protected]>.
--
-- * FlexRay automotive bus - http://www.flexray.com/ - as requested
-- * by Hannes Kaelber <[email protected]>.
--
-- * Media Oriented Systems Transport (MOST) bus for multimedia
-- * transport - http://www.mostcooperation.com/ - as requested
-- * by Hannes Kaelber <[email protected]>.
--
-- * Local Interconnect Network (LIN) bus for vehicle networks -
-- * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
-- * <[email protected]>.
--
-- * X2E-private data link type used for serial line capture,
-- * as requested by Hannes Kaelber <[email protected]>.
--
-- * X2E-private data link type used for the Xoraya data logger
-- * family, as requested by Hannes Kaelber <[email protected]>.
--
-- * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
-- * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
-- * of 0 as preamble, one octet of SFD, one octet of frame length+
-- * reserved bit, and then the MAC-layer data, starting with the
-- * frame control field).
-- *
-- * Requested by Max Filippov <[email protected]>.
--
--
-- * David Gibson <[email protected]> requested this for
-- * captures from the Linux kernel /dev/input/eventN devices. This
-- * is used to communicate keystrokes and mouse movements from the
-- * Linux kernel to display systems, such as Xorg.
--
-- * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
-- *
-- * Requested by Harald Welte <[email protected]>.
--
-- * MPLS, with an MPLS label as the link-layer header.
-- * Requested by Michele Marchetto <[email protected]> on behalf
-- * of OpenBSD.
--
-- * USB packets, beginning with a Linux USB header, with the USB header
-- * padded to 64 bytes; required for memory-mapped access.
--
-- * DECT packets, with a pseudo-header; requested by
-- * Matthias Wenzel <[email protected]>.
--
-- * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <[email protected]>
-- * Date: Mon, 11 May 2009 11:18:30 -0500
-- *
-- * DLT_AOS. We need it for AOS Space Data Link Protocol.
-- * I have already written dissectors for but need an OK from
-- * legal before I can submit a patch.
-- *
--
-- * Wireless HART (Highway Addressable Remote Transducer)
-- * From the HART Communication Foundation
-- * IES/PAS 62591
-- *
-- * Requested by Sam Roberts <[email protected]>.
--
-- * Fibre Channel FC-2 frames, beginning with a Frame_Header.
-- * Requested by Kahou Lei <[email protected]>.
--
-- * Fibre Channel FC-2 frames, beginning with an encoding of the
-- * SOF, and ending with an encoding of the EOF.
-- *
-- * The encodings represent the frame delimiters as 4-byte sequences
-- * representing the corresponding ordered sets, with K28.5
-- * represented as 0xBC, and the D symbols as the corresponding
-- * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
-- * is represented as 0xBC 0xB5 0x55 0x55.
-- *
-- * Requested by Kahou Lei <[email protected]>.
--
-- * Solaris ipnet pseudo-header; requested by Darren Reed <[email protected]>.
-- *
-- * The pseudo-header starts with a one-byte version number; for version 2,
-- * the pseudo-header is:
-- *
-- * struct dl_ipnetinfo {
-- * u_int8_t dli_version;
-- * u_int8_t dli_family;
-- * u_int16_t dli_htype;
-- * u_int32_t dli_pktlen;
-- * u_int32_t dli_ifindex;
-- * u_int32_t dli_grifindex;
-- * u_int32_t dli_zsrc;
-- * u_int32_t dli_zdst;
-- * };
-- *
-- * dli_version is 2 for the current version of the pseudo-header.
-- *
-- * dli_family is a Solaris address family value, so it's 2 for IPv4
-- * and 26 for IPv6.
-- *
-- * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
-- * packets, and 2 for packets arriving from another zone on the same
-- * machine.
-- *
-- * dli_pktlen is the length of the packet data following the pseudo-header
-- * (so the captured length minus dli_pktlen is the length of the
-- * pseudo-header, assuming the entire pseudo-header was captured).
-- *
-- * dli_ifindex is the interface index of the interface on which the
-- * packet arrived.
-- *
-- * dli_grifindex is the group interface index number (for IPMP interfaces).
-- *
-- * dli_zsrc is the zone identifier for the source of the packet.
-- *
-- * dli_zdst is the zone identifier for the destination of the packet.
-- *
-- * A zone number of 0 is the global zone; a zone number of 0xffffffff
-- * means that the packet arrived from another host on the network, not
-- * from another zone on the same machine.
-- *
-- * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
-- * which of those it is.
--
-- * CAN (Controller Area Network) frames, with a pseudo-header as supplied
-- * by Linux SocketCAN. See Documentation/networking/can.txt in the Linux
-- * source.
-- *
-- * Requested by Felix Obenhuber <[email protected]>.
--
-- * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
-- * whether it's v4 or v6. Requested by Darren Reed <[email protected]>.
--
-- * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
-- * nothing), and with no FCS at the end of the frame; requested by
-- * Jon Smirl <[email protected]>.
--
-- * Raw D-Bus:
-- *
-- * http://www.freedesktop.org/wiki/Software/dbus
-- *
-- * messages:
-- *
-- * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
-- *
-- * starting with the endianness flag, followed by the message type, etc.,
-- * but without the authentication handshake before the message sequence:
-- *
-- * http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
-- *
-- * Requested by Martin Vidner <[email protected]>.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
--
-- * DVB-CI (DVB Common Interface for communication between a PC Card
-- * module and a DVB receiver). See
-- *
-- * http://www.kaiser.cx/pcap-dvbci.html
-- *
-- * for the specification.
-- *
-- * Requested by Martin Kaiser <[email protected]>.
--
-- * Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but
-- * *not* the same as, 27.010). Requested by Hans-Christoph Schemmel
-- * <[email protected]>.
--
-- * STANAG 5066 D_PDUs. Requested by M. Baris Demiray
-- * <[email protected]>.
--
-- * Juniper-private data link type, as per request from
-- * Hannes Gredler <[email protected]>.
--
-- * NetFilter LOG messages
-- * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
-- *
-- * Requested by Jakub Zawadzki <[email protected]>
--
-- * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
-- * for Ethernet packets with a 4-byte pseudo-header and always
-- * with the payload including the FCS, as supplied by their
-- * netANALYZER hardware and software.
-- *
-- * Requested by Holger P. Frommer <[email protected]>
--
-- * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
-- * for Ethernet packets with a 4-byte pseudo-header and FCS and
-- * with the Ethernet header preceded by 7 bytes of preamble and
-- * 1 byte of SFD, as supplied by their netANALYZER hardware and
-- * software.
-- *
-- * Requested by Holger P. Frommer <[email protected]>
--
-- * IP-over-InfiniBand, as specified by RFC 4391.
-- *
-- * Requested by Petr Sumbera <[email protected]>.
--
-- * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
-- *
-- * Requested by Guy Martin <[email protected]>.
--
-- * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
-- * used by their ng40 protocol tester.
-- *
-- * Requested by Jens Grimmer <[email protected]>.
--
-- * Pseudo-header giving adapter number and flags, followed by an NFC
-- * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
-- * as specified by NFC Forum Logical Link Control Protocol Technical
-- * Specification LLCP 1.1.
-- *
-- * Requested by Mike Wakerly <[email protected]>.
--
-- * 245 is used as LINKTYPE_PFSYNC; do not use it for any other purpose.
-- *
-- * DLT_PFSYNC has different values on different platforms, and all of
-- * them collide with something used elsewhere. On platforms that
-- * don't already define it, define it as 245.
--
-- * Raw InfiniBand packets, starting with the Local Routing Header.
-- *
-- * Requested by Oren Kladnitsky <[email protected]>.
--
-- * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6).
-- *
-- * Requested by Michael Tuexen <[email protected]>.
--
-- * USB packets, beginning with a USBPcap header.
-- *
-- * Requested by Tomasz Mon <[email protected]>
--
-- * Schweitzer Engineering Laboratories "RTAC" product serial-line
-- * packets.
-- *
-- * Requested by Chris Bontje <[email protected]>.
--
-- * Bluetooth Low Energy air interface link-layer packets.
-- *
-- * Requested by Mike Kershaw <[email protected]>.
--
-- * DLT type for upper-protocol layer PDU saves from wireshark.
-- *
-- * the actual contents are determined by two TAGs stored with each
-- * packet:
-- * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
-- * original packet.
-- *
-- * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
-- * that can make sense of the data stored.
--
-- * DLT type for the netlink protocol (nlmon devices).
--
-- * Bluetooth Linux Monitor headers for the BlueZ stack.
--
-- * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as
-- * captured by Ubertooth.
--
-- * Bluetooth Low Energy link layer packets, as captured by Ubertooth.
--
-- * PROFIBUS data link layer.
--
-- * Apple's DLT_PKTAP headers.
-- *
-- * Sadly, the folks at Apple either had no clue that the DLT_USERn values
-- * are for internal use within an organization and partners only, and
-- * didn't know that the right way to get a link-layer header type is to
-- * ask tcpdump.org for one, or knew and didn't care, so they just
-- * used DLT_USER2, which causes problems for everything except for
-- * their version of tcpdump.
-- *
-- * So I'll just give them one; hopefully this will show up in a
-- * libpcap release in time for them to get this into 10.10 Big Sur
-- * or whatever Mavericks' successor is called. LINKTYPE_PKTAP
-- * will be 258 *even on OS X*; that is *intentional*, so that
-- * PKTAP files look the same on *all* OSes (different OSes can have
-- * different numerical values for a given DLT_, but *MUST NOT* have
-- * different values for what goes in a file, as files can be moved
-- * between OSes!).
-- *
-- * When capturing, on a system with a Darwin-based OS, on a device
-- * that returns 149 (DLT_USER2 and Apple's DLT_PKTAP) with this
-- * version of libpcap, the DLT_ value for the pcap_t will be DLT_PKTAP,
-- * and that will continue to be DLT_USER2 on Darwin-based OSes. That way,
-- * binary compatibility with Mavericks is preserved for programs using
-- * this version of libpcap. This does mean that if you were using
-- * DLT_USER2 for some capture device on OS X, you can't do so with
-- * this version of libpcap, just as you can't with Apple's libpcap -
-- * on OS X, they define DLT_PKTAP to be DLT_USER2, so programs won't
-- * be able to distinguish between PKTAP and whatever you were using
-- * DLT_USER2 for.
-- *
-- * If the program saves the capture to a file using this version of
-- * libpcap's pcap_dump code, the LINKTYPE_ value in the file will be
-- * LINKTYPE_PKTAP, which will be 258, even on Darwin-based OSes.
-- * That way, the file will *not* be a DLT_USER2 file. That means
-- * that the latest version of tcpdump, when built with this version
-- * of libpcap, and sufficiently recent versions of Wireshark will
-- * be able to read those files and interpret them correctly; however,
-- * Apple's version of tcpdump in OS X 10.9 won't be able to handle
-- * them. (Hopefully, Apple will pick up this version of libpcap,
-- * and the corresponding version of tcpdump, so that tcpdump will
-- * be able to handle the old LINKTYPE_USER2 captures *and* the new
-- * LINKTYPE_PKTAP captures.)
--
-- * Ethernet packets preceded by a header giving the last 6 octets
-- * of the preamble specified by 802.3-2012 Clause 65, section
-- * 65.1.3.2 "Transmit".
--
-- * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format"
-- * in the PICMG HPM.2 specification.
--
-- * DLT and savefile link type values are split into a class and
-- * a member of that class. A class value of 0 indicates a regular
-- * DLT_/LINKTYPE_ value.
--
-- * NetBSD-specific generic "raw" link type. The class value indicates
-- * that this is the generic raw type, and the lower 16 bits are the
-- * address family we're dealing with. Those values are NetBSD-specific;
-- * do not assume that they correspond to AF_ values for your operating
-- * system.
--
-- * The instruction encodings.
-- *
-- * Please inform [email protected] if you use any
-- * of the reserved values, so that we can note that they're used
-- * (and perhaps implement it in the reference BPF implementation
-- * and encourage its implementation elsewhere).
--
-- * The upper 8 bits of the opcode aren't used. BSD/OS used 0x8000.
--
-- instruction classes
-- ld/ldx fields
-- 0x18 reserved; used by BSD/OS
-- 0xc0 reserved; used by BSD/OS
-- 0xe0 reserved; used by BSD/OS
-- alu/jmp fields
-- 0xb0 reserved
-- 0xc0 reserved
-- 0xd0 reserved
-- 0xe0 reserved
-- 0xf0 reserved
-- 0x50 reserved; used on BSD/OS
-- 0x60 reserved
-- 0x70 reserved
-- 0x80 reserved
-- 0x90 reserved
-- 0xa0 reserved
-- 0xb0 reserved
-- 0xc0 reserved
-- 0xd0 reserved
-- 0xe0 reserved
-- 0xf0 reserved
-- ret - BPF_K and BPF_X also apply
-- 0x18 reserved
-- misc
-- 0x08 reserved
-- 0x10 reserved
-- 0x18 reserved
-- #define BPF_COP 0x20 NetBSD "coprocessor" extensions
-- 0x28 reserved
-- 0x30 reserved
-- 0x38 reserved
-- #define BPF_COPX 0x40 NetBSD "coprocessor" extensions
-- also used on BSD/OS
-- 0x48 reserved
-- 0x50 reserved
-- 0x58 reserved
-- 0x60 reserved
-- 0x68 reserved
-- 0x70 reserved
-- 0x78 reserved
-- 0x88 reserved
-- 0x90 reserved
-- 0x98 reserved
-- 0xa0 reserved
-- 0xa8 reserved
-- 0xb0 reserved
-- 0xb8 reserved
-- 0xc0 reserved; used on BSD/OS
-- 0xc8 reserved
-- 0xd0 reserved
-- 0xd8 reserved
-- 0xe0 reserved
-- 0xe8 reserved
-- 0xf0 reserved
-- 0xf8 reserved
-- * The instruction data structure.
--
type bpf_insn is record
code : aliased unsigned_short; -- /usr/include/pcap/bpf.h:1460
jt : aliased unsigned_char; -- /usr/include/pcap/bpf.h:1461
jf : aliased unsigned_char; -- /usr/include/pcap/bpf.h:1462
k : aliased bpf_u_int32; -- /usr/include/pcap/bpf.h:1463
end record
with Convention => C_Pass_By_Copy; -- /usr/include/pcap/bpf.h:1459
-- * Macros for insn array initializers.
--
-- * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
--
end PCAP.Low_Level.pcap_bpf_h;
-- end read only
|
zhmu/ananas | Ada | 3,542 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- SYSTEM.TASK_PRIMITIVES.OPERATIONS.SPECIFIC --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- 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 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a POSIX-like version of this package
separate (System.Task_Primitives.Operations)
package body Specific is
ATCB_Key : aliased pthread_key_t;
-- Key used to find the Ada Task_Id associated with a thread
----------------
-- Initialize --
----------------
procedure Initialize (Environment_Task : Task_Id) is
pragma Warnings (Off, Environment_Task);
Result : Interfaces.C.int;
begin
Result := pthread_key_create (ATCB_Key'Access, null);
pragma Assert (Result = 0);
end Initialize;
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean is
begin
return pthread_getspecific (ATCB_Key) /= System.Null_Address;
end Is_Valid_Task;
---------
-- Set --
---------
procedure Set (Self_Id : Task_Id) is
Result : Interfaces.C.int;
begin
Result := pthread_setspecific (ATCB_Key, To_Address (Self_Id));
pragma Assert (Result = 0);
end Set;
----------
-- Self --
----------
function Self return Task_Id is
begin
return To_Task_Id (pthread_getspecific (ATCB_Key));
end Self;
end Specific;
|
reznikmm/matreshka | Ada | 3,830 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Vertical is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Start_Line_Spacing_Vertical_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Start_Line_Spacing_Vertical_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Vertical;
|
zhmu/ananas | Ada | 70 | ads | package Lto19_Pkg2 is
function UB return Natural;
end Lto19_Pkg2;
|
reznikmm/matreshka | Ada | 3,769 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Caption_Sequence_Name_Attributes is
pragma Preelaborate;
type ODF_Text_Caption_Sequence_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Caption_Sequence_Name_Attribute_Access is
access all ODF_Text_Caption_Sequence_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Caption_Sequence_Name_Attributes;
|
persan/advent-of-code-2020 | Ada | 135 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_22.Main is
begin
Put_Line ("Day-22");
end Adventofcode.Day_22.Main;
|
AdaCore/Ada_Drivers_Library | Ada | 2,680 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This file provides utility functions for ARM Cortex microcontrollers
package Memory_Barriers is
procedure Data_Synchronization_Barrier with Inline;
-- Injects instruction "DSB Sy" i.e., a "full system" domain barrier
procedure DSB renames Data_Synchronization_Barrier;
end Memory_Barriers;
|
flyx/OpenGLAda | Ada | 25,193 | ads | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C.Strings;
with Interfaces.C.Pointers;
with System;
with Glfw.Input.Keys;
with Glfw.Input.Mouse;
with Glfw.Input.Joysticks;
with Glfw.Monitors;
with Glfw.Errors;
with Glfw.Enums;
with Glfw.Windows.Context;
private package Glfw.API is
-----------------------------------------------------------------------------
-- Types
-----------------------------------------------------------------------------
type Address_List is array (Positive range <>) of aliased System.Address;
pragma Convention (C, Address_List);
package Address_List_Pointers is new Interfaces.C.Pointers
(Positive, System.Address, Address_List, System.Null_Address);
package VMode_List_Pointers is new Interfaces.C.Pointers
(Positive, Monitors.Video_Mode, Monitors.Video_Mode_List, (others => 0));
package Axis_Position_List_Pointers is new Interfaces.C.Pointers
(Positive, Input.Joysticks.Axis_Position, Input.Joysticks.Axis_Positions,
0.0);
package Joystick_Button_State_List_Pointers is new Interfaces.C.Pointers
(Positive, Input.Joysticks.Joystick_Button_State,
Input.Joysticks.Joystick_Button_States, Input.Joysticks.Released);
type Unsigned_Short_List is array (Positive range <>) of aliased
Interfaces.C.unsigned_short;
package Unsigned_Short_List_Pointers is new Interfaces.C.Pointers
(Positive, Interfaces.C.unsigned_short, Unsigned_Short_List, 0);
type Raw_Gamma_Ramp is record
Red, Green, Blue : Unsigned_Short_List_Pointers.Pointer;
Size : Interfaces.C.unsigned;
end record;
pragma Convention (C, Raw_Gamma_Ramp);
-----------------------------------------------------------------------------
-- Callbacks
-----------------------------------------------------------------------------
type Error_Callback is access procedure (Code : Errors.Kind;
Description : C.Strings.chars_ptr);
type Window_Position_Callback is access procedure
(Window : System.Address; X, Y : C.int);
type Window_Size_Callback is access procedure
(Window : System.Address; Width, Height : C.int);
type Window_Close_Callback is access procedure
(Window : System.Address);
type Window_Refresh_Callback is access procedure
(Window : System.Address);
type Window_Focus_Callback is access procedure
(Window : System.Address; Focussed : Bool);
type Window_Iconify_Callback is access procedure
(Window : System.Address; Iconified : Bool);
type Framebuffer_Size_Callback is access procedure
(Window : System.Address; Width, Height : C.int);
type Mouse_Button_Callback is access procedure (Window : System.Address;
Button : Input.Mouse.Button;
State : Input.Button_State;
Mods : Input.Keys.Modifiers);
type Cursor_Position_Callback is access procedure
(Window : System.Address; X, Y : Input.Mouse.Coordinate);
type Cursor_Enter_Callback is access procedure
(Window : System.Address; Action : Input.Mouse.Enter_Action);
type Scroll_Callback is access procedure
(Window : System.Address; X, Y : Input.Mouse.Scroll_Offset);
type Key_Callback is access procedure (Window : System.Address;
Key : Input.Keys.Key;
Scancode : Input.Keys.Scancode;
Action : Input.Keys.Action;
Mods : Input.Keys.Modifiers);
type Character_Callback is access procedure
(Window : System.Address; Unicode_Char : Interfaces.C.unsigned);
type Monitor_Callback is access procedure
(Monitor : System.Address; Event : Monitors.Event);
pragma Convention (C, Error_Callback);
pragma Convention (C, Window_Position_Callback);
pragma Convention (C, Window_Size_Callback);
pragma Convention (C, Window_Close_Callback);
pragma Convention (C, Window_Refresh_Callback);
pragma Convention (C, Window_Focus_Callback);
pragma Convention (C, Window_Iconify_Callback);
pragma Convention (C, Framebuffer_Size_Callback);
pragma Convention (C, Mouse_Button_Callback);
pragma Convention (C, Cursor_Position_Callback);
pragma Convention (C, Cursor_Enter_Callback);
pragma Convention (C, Scroll_Callback);
pragma Convention (C, Key_Callback);
pragma Convention (C, Character_Callback);
pragma Convention (C, Monitor_Callback);
-----------------------------------------------------------------------------
-- Basics
-----------------------------------------------------------------------------
function Init return C.int;
pragma Import (Convention => C, Entity => Init,
External_Name => "glfwInit");
procedure Glfw_Terminate;
pragma Import (Convention => C, Entity => Glfw_Terminate,
External_Name => "glfwTerminate");
procedure Get_Version (Major, Minor, Revision : out C.int);
pragma Import (Convention => C, Entity => Get_Version,
External_Name => "glfwGetVersion");
function Get_Version_String return C.Strings.chars_ptr;
pragma Import (Convention => C, Entity => Get_Version_String,
External_Name => "glfwGetVersionString");
function Get_Time return C.double;
pragma Import (Convention => C, Entity => Get_Time,
External_Name => "glfwGetTime");
procedure Set_Time (Value : C.double);
pragma Import (Convention => C, Entity => Set_Time,
External_Name => "glfwSetTime");
procedure Sleep (Time : C.double);
pragma Import (Convention => C, Entity => Sleep,
External_Name => "glfwSleep");
function Extension_Supported (Name : C.char_array) return Bool;
pragma Import (Convention => C, Entity => Extension_Supported,
External_Name => "glfwExtensionSupported");
function Set_Error_Callback (CB_Fun : Error_Callback) return Error_Callback;
pragma Import (Convention => C, Entity => Set_Error_Callback,
External_Name => "glfwSetErrorCallback");
-----------------------------------------------------------------------------
-- Monitors
-----------------------------------------------------------------------------
function Get_Monitors (Count : access Interfaces.C.int)
return Address_List_Pointers.Pointer;
pragma Import (Convention => C, Entity => Get_Monitors,
External_Name => "glfwGetMonitors");
function Get_Primary_Monitor return System.Address;
pragma Import (Convention => C, Entity => Get_Primary_Monitor,
External_Name => "glfwGetPrimaryMonitor");
procedure Get_Monitor_Pos (Monitor : System.Address;
XPos, YPos : out Interfaces.C.int);
pragma Import (Convention => C, Entity => Get_Monitor_Pos,
External_Name => "glfwGetMonitorPos");
procedure Get_Monitor_Physical_Size (Monitor : System.Address;
Width, Height : out Interfaces.C.int);
pragma Import (Convention => C, Entity => Get_Monitor_Physical_Size,
External_Name => "glfwGetMonitorPhysicalSize");
function Get_Monitor_Name (Monitor : System.Address)
return Interfaces.C.Strings.chars_ptr;
pragma Import (Convention => C, Entity => Get_Monitor_Name,
External_Name => "glfwGetMonitorName");
function Set_Monitor_Callback (Monitor : System.Address;
CB_Fun : Monitor_Callback)
return Monitor_Callback;
pragma Import (Convention => C, Entity => Set_Monitor_Callback,
External_Name => "glfwSetMonitorCallback");
function Get_Video_Modes (Monitor : System.Address;
Count : access Interfaces.C.int)
return VMode_List_Pointers.Pointer;
pragma Import (Convention => C, Entity => Get_Video_Modes,
External_Name => "glfwGetVideoModes");
function Get_Video_Mode (Monitor : System.Address)
return access constant Monitors.Video_Mode;
pragma Import (Convention => C, Entity => Get_Video_Mode,
External_Name => "glfwGetVideoMode");
procedure Set_Gamma (Monitor : System.Address; Gamma : Interfaces.C.C_float);
pragma Import (Convention => C, Entity => Set_Gamma,
External_Name => "glfwSetGamma");
function Get_Gamma_Ramp (Monitor : System.Address)
return access constant Raw_Gamma_Ramp;
pragma Import (Convention => C, Entity => Get_Gamma_Ramp,
External_Name => "glfwGetGammaRamp");
procedure Set_Gamma_Ramp (Monitor : System.Address;
Value : access constant Raw_Gamma_Ramp);
pragma Import (Convention => C, Entity => Set_Gamma_Ramp,
External_Name => "glfwSetGammaRamp");
-----------------------------------------------------------------------------
-- Windows
-----------------------------------------------------------------------------
procedure Default_Window_Hints;
pragma Import (Convention => C, Entity => Default_Window_Hints,
External_Name => "glfwDefaultWindowHints");
procedure Window_Hint (Target : Glfw.Enums.Window_Info; Info : C.int);
procedure Window_Hint (Target : Glfw.Enums.Window_Info; Info : Bool);
procedure Window_Hint (Target : Glfw.Enums.Window_Info;
Info : Windows.Context.OpenGL_Profile_Kind);
procedure Window_Hint (Target : Glfw.Enums.Window_Info;
Info : Windows.Context.API_Kind);
procedure Window_Hint (Target : Glfw.Enums.Window_Info;
Info : Glfw.Windows.Context.Robustness_Kind);
pragma Import (Convention => C, Entity => Window_Hint,
External_Name => "glfwWindowHint");
function Create_Window (Width, Height : Interfaces.C.int;
Title : Interfaces.C.char_array;
Monitor : System.Address;
Share : System.Address)
return System.Address;
pragma Import (Convention => C, Entity => Create_Window,
External_Name => "glfwCreateWindow");
procedure Destroy_Window (Window : System.Address);
pragma Import (Convention => C, Entity => Destroy_Window,
External_Name => "glfwDestroyWindow");
function Window_Should_Close (Window : System.Address)
return Bool;
pragma Import (Convention => C, Entity => Window_Should_Close,
External_Name => "glfwWindowShouldClose");
procedure Set_Window_Should_Close (Window : System.Address;
Value : Bool);
pragma Import (Convention => C, Entity => Set_Window_Should_Close,
External_Name => "glfwSetWindowShouldClose");
procedure Set_Window_Title (Window : System.Address;
Title : Interfaces.C.char_array);
pragma Import (Convention => C, Entity => Set_Window_Title,
External_Name => "glfwSetWindowTitle");
procedure Get_Window_Pos (Window : System.Address;
Xpos, Ypos : out Windows.Coordinate);
pragma Import (Convention => C, Entity => Get_Window_Pos,
External_Name => "glfwGetWindowPos");
procedure Set_Window_Pos (Window : System.Address;
Xpos, Ypos : Windows.Coordinate);
pragma Import (Convention => C, Entity => Set_Window_Pos,
External_Name => "glfwSetWindowPos");
procedure Get_Window_Size (Window : System.Address;
Width, Height : out Size);
pragma Import (Convention => C, Entity => Get_Window_Size,
External_Name => "glfwGetWindowSize");
procedure Set_Window_Size (Window : System.Address;
Width, Height : Size);
pragma Import (Convention => C, Entity => Set_Window_Size,
External_Name => "glfwSetWindowSize");
procedure Get_Framebuffer_Size (Window : System.Address;
Width, Height : out Size);
pragma Import (Convention => C, Entity => Get_Framebuffer_Size,
External_Name => "glfwGetFramebufferSize");
procedure Iconify_Window (Window : System.Address);
pragma Import (Convention => C, Entity => Iconify_Window,
External_Name => "glfwIconifyWindow");
procedure Restore_Window (Window : System.Address);
pragma Import (Convention => C, Entity => Restore_Window,
External_Name => "glfwRestoreWindow");
procedure Show_Window (Window : System.Address);
pragma Import (Convention => C, Entity => Show_Window,
External_Name => "glfwShowWindow");
procedure Hide_Window (Window : System.Address);
pragma Import (Convention => C, Entity => Hide_Window,
External_Name => "glfwHideWindow");
function Get_Window_Monitor (Window : System.Address) return System.Address;
pragma Import (Convention => C, Entity => Get_Window_Monitor,
External_Name => "glfwGetWindowMonitor");
function Get_Window_Attrib (Window : System.Address;
Attrib : Enums.Window_Info) return C.int;
function Get_Window_Attrib (Window : System.Address;
Attrib : Enums.Window_Info) return Bool;
function Get_Window_Attrib (Window : System.Address;
Attrib : Enums.Window_Info)
return Windows.Context.API_Kind;
function Get_Window_Attrib (Window : System.Address;
Attrib : Enums.Window_Info)
return Windows.Context.OpenGL_Profile_Kind;
function Get_Window_Attrib (Window : System.Address;
Attrib : Enums.Window_Info)
return Windows.Context.Robustness_Kind;
pragma Import (Convention => C, Entity => Get_Window_Attrib,
External_Name => "glfwGetWindowAttrib");
procedure Set_Window_User_Pointer (Window : System.Address;
Pointer : System.Address);
pragma Import (Convention => C, Entity => Set_Window_User_Pointer,
External_Name => "glfwSetWindowUserPointer");
function Get_Window_User_Pointer (Window : System.Address)
return System.Address;
pragma Import (Convention => C, Entity => Get_Window_User_Pointer,
External_Name => "glfwGetWindowUserPointer");
-- The callback setters in the C header are defined as returning the
-- previous callback pointer. This is rather low-level and not applicable
-- in the object-oriented interface of this binding. So we define the setters
-- as procedures, the return value will just get thrown away.
procedure Set_Window_Pos_Callback (Window : System.Address;
CB_Fun : Window_Position_Callback);
--return Window_Position_Callback;
pragma Import (Convention => C, Entity => Set_Window_Pos_Callback,
External_Name => "glfwSetWindowPosCallback");
procedure Set_Window_Size_Callback (Window : System.Address;
CB_Fun : Window_Size_Callback);
--return Window_Size_Callback;
pragma Import (Convention => C, Entity => Set_Window_Size_Callback,
External_Name => "glfwSetWindowSizeCallback");
procedure Set_Window_Close_Callback (Window : System.Address;
CB_Fun : Window_Close_Callback);
--return Window_Close_Callback;
pragma Import (Convention => C, Entity => Set_Window_Close_Callback,
External_Name => "glfwSetWindowCloseCallback");
procedure Set_Window_Refresh_Callback (Window : System.Address;
CB_Fun : Window_Refresh_Callback);
--return Window_Refresh_Callback;
pragma Import (Convention => C, Entity => Set_Window_Refresh_Callback,
External_Name => "glfwSetWindowRefreshCallback");
procedure Set_Window_Focus_Callback (Window : System.Address;
CB_Fun : Window_Focus_Callback);
--return Window_Focus_Callback;
pragma Import (Convention => C, Entity => Set_Window_Focus_Callback,
External_Name => "glfwSetWindowFocusCallback");
procedure Set_Window_Iconify_Callback (Window : System.Address;
CB_Fun : Window_Iconify_Callback);
--return Window_Iconify_Callback;
pragma Import (Convention => C, Entity => Set_Window_Iconify_Callback,
External_Name => "glfwSetWindowIconifyCallback");
procedure Set_Framebuffer_Size_Callback (Window : System.Address;
CB_Fun : Framebuffer_Size_Callback);
--return Framebuffer_Size_Callback;
pragma Import (Convention => C, Entity => Set_Framebuffer_Size_Callback,
External_Name => "glfwSetFramebufferSizeCallback");
-----------------------------------------------------------------------------
-- Input
-----------------------------------------------------------------------------
function Get_Input_Mode (Window : System.Address;
Mode : Enums.Bool_Input_Toggle) return Bool;
function Get_Input_Mode (Window : System.Address;
Mode : Enums.Cursor_Input_Toggle)
return Input.Mouse.Cursor_Mode;
pragma Import (Convention => C, Entity => Get_Input_Mode,
External_Name => "glfwGetInputMode");
procedure Set_Input_Mode (Window : System.Address;
Mode : Input.Sticky_Toggle;
Value : Bool);
procedure Set_Input_Mode (Window : System.Address;
Mode : Enums.Cursor_Input_Toggle;
Value : Input.Mouse.Cursor_Mode);
procedure Set_Input_Mode (Window : System.Address;
Mode : Enums.Bool_Input_Toggle;
Value : Bool);
pragma Import (Convention => C, Entity => Set_Input_Mode,
External_Name => "glfwSetInputMode");
function Raw_Mouse_Motion_Supported return Bool;
pragma Import (Convention => C, Entity => Raw_Mouse_Motion_Supported,
External_Name => "glfwRawMouseMotionSupported");
function Get_Key (Window : System.Address; Key : Input.Keys.Key)
return Input.Button_State;
pragma Import (Convention => C, Entity => Get_Key,
External_Name => "glfwGetKey");
function Get_Mouse_Button (Window : System.Address;
Button : Input.Mouse.Button)
return Input.Button_State;
pragma Import (Convention => C, Entity => Get_Mouse_Button,
External_Name => "glfwGetMouseButton");
procedure Get_Cursor_Pos (Window : System.Address;
Xpos, Ypos : out Input.Mouse.Coordinate);
pragma Import (Convention => C, Entity => Get_Cursor_Pos,
External_Name => "glfwGetCursorPos");
procedure Set_Cursor_Pos (Window : System.Address;
Xpos, Ypos : Input.Mouse.Coordinate);
pragma Import (Convention => C, Entity => Set_Cursor_Pos,
External_Name => "glfwSetCursorPos");
procedure Set_Key_Callback (Window : System.Address;
CB_Fun : Key_Callback);
--return Key_Callback
pragma Import (Convention => C, Entity => Set_Key_Callback,
External_Name => "glfwSetKeyCallback");
procedure Set_Char_Callback (Window : System.Address;
CB_Fun : Character_Callback);
--return Character_Callback;
pragma Import (Convention => C, Entity => Set_Char_Callback,
External_Name => "glfwSetCharCallback");
procedure Set_Mouse_Button_Callback (Window : System.Address;
CB_Fun : Mouse_Button_Callback);
--return Mouse_Button_Callback;
pragma Import (Convention => C, Entity => Set_Mouse_Button_Callback,
External_Name => "glfwSetMouseButtonCallback");
procedure Set_Cursor_Pos_Callback (Window : System.Address;
CB_Fun : Cursor_Position_Callback);
--return Cursor_Position_Callback;
pragma Import (Convention => C, Entity => Set_Cursor_Pos_Callback,
External_Name => "glfwSetCursorPosCallback");
procedure Set_Cursor_Enter_Callback (Window : System.Address;
CB_Fun : Cursor_Enter_Callback);
--return Cursor_Enter_Callback;
pragma Import (Convention => C, Entity => Set_Cursor_Enter_Callback,
External_Name => "glfwSetCursorEnterCallback");
procedure Set_Scroll_Callback (Window : System.Address;
CB_Fun : Scroll_Callback);
--return Scroll_Callback;
pragma Import (Convention => C, Entity => Set_Scroll_Callback,
External_Name => "glfwSetScrollCallback");
function Joystick_Present (Joy : Enums.Joystick_ID) return Bool;
pragma Import (Convention => C, Entity => Joystick_Present,
External_Name => "glfwJoystickPresent");
function Get_Joystick_Axes (Joy : Enums.Joystick_ID;
Count : access Interfaces.C.int)
return Axis_Position_List_Pointers.Pointer;
pragma Import (Convention => C, Entity => Get_Joystick_Axes,
External_Name => "glfwGetJoystickAxes");
function Get_Joystick_Buttons (Joy : Enums.Joystick_ID;
Count : access Interfaces.C.int)
return Joystick_Button_State_List_Pointers.Pointer;
pragma Import (Convention => C, Entity => Get_Joystick_Buttons,
External_Name => "glfwGetJoystickButtons");
function Get_Joystick_Name (Joy : Enums.Joystick_ID)
return Interfaces.C.Strings.chars_ptr;
pragma Import (Convention => C, Entity => Get_Joystick_Name,
External_Name => "glfwGetJoystickName");
procedure Poll_Events;
pragma Import (Convention => C, Entity => Poll_Events,
External_Name => "glfwPollEvents");
procedure Wait_Events;
pragma Import (Convention => C, Entity => Wait_Events,
External_Name => "glfwWaitEvents");
-----------------------------------------------------------------------------
-- Context
-----------------------------------------------------------------------------
procedure Make_Context_Current (Window : System.Address);
pragma Import (Convention => C, Entity => Make_Context_Current,
External_Name => "glfwMakeContextCurrent");
function Get_Current_Context return System.Address;
pragma Import (Convention => C, Entity => Get_Current_Context,
External_Name => "glfwGetCurrentContext");
procedure Swap_Buffers (Window : System.Address);
pragma Import (Convention => C, Entity => Swap_Buffers,
External_Name => "glfwSwapBuffers");
procedure Swap_Interval (Value : Windows.Context.Swap_Interval);
pragma Import (Convention => C, Entity => Swap_Interval,
External_Name => "glfwSwapInterval");
-----------------------------------------------------------------------------
-- Clipboard
-----------------------------------------------------------------------------
function Get_Clipboard_String (Window : System.Address)
return Interfaces.C.Strings.chars_ptr;
pragma Import (Convention => C, Entity => Get_Clipboard_String,
External_Name => "glfwGetClipboardString");
procedure Set_Clipboard_String (Window : System.Address;
Value : Interfaces.C.char_array);
pragma Import (Convention => C, Entity => Set_Clipboard_String,
External_Name => "glfwSetClipboardString");
end Glfw.API;
|
MinimSecure/unum-sdk | Ada | 801 | ads | -- Copyright 2011-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with System;
package Pck is
procedure Do_Nothing (A : System.Address);
end Pck;
|
reznikmm/matreshka | Ada | 6,791 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Examples Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Wide_Wide_Text_IO;
with League.Stream_Element_Vectors;
with Web_Socket.Connections;
package body Servlets.Hello is
function "+"
(Text : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Max_Count : constant := 5;
type WS_Handler_Access is access all WS_Handler'Class;
------------
-- Do_Get --
------------
overriding procedure Do_Get
(Self : in out Hello_Servlet;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
H : WS_Handler_Access := new WS_Handler;
begin
H.WS.Set_Web_Socket_Listener (H.all'Access);
Request.Upgrade (H.WS'Access);
Response.Set_Status (Servlet.HTTP_Responses.Switching_Protocols);
end Do_Get;
----------------------
-- Get_Servlet_Info --
----------------------
overriding function Get_Servlet_Info
(Self : Hello_Servlet)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
Text : constant Wide_Wide_String :=
"Hello servlet provides WebSocket upgrade responses";
begin
return +Text;
end Get_Servlet_Info;
-----------------
-- Instantiate --
-----------------
overriding function Instantiate
(Parameters : not null access
Servlet.Generic_Servlets.Instantiation_Parameters'Class)
return Hello_Servlet
is
pragma Unreferenced (Parameters);
begin
return (Servlet.HTTP_Servlets.HTTP_Servlet with null record);
end Instantiate;
---------------
-- On_Binary --
---------------
overriding procedure On_Binary
(Self : in out WS_Handler;
Data : Ada.Streams.Stream_Element_Array)
is
Vector : League.Stream_Element_Vectors.Stream_Element_Vector;
begin
Ada.Wide_Wide_Text_IO.Put_Line
("On_Binary:" & Natural'Wide_Wide_Image (Data'Length));
if Self.Count < Max_Count then
Self.Count := Self.Count + 1;
Vector.Append (Data);
Web_Socket.Connections.Connection'Class (Self.WS).
Send_Binary (Vector);
-- Web_Socket.Handlers.AWS_Handlers.Send_Binary (Self.WS, Vector);
-- Self.WS.Send_Binary (Vector);
end if;
end On_Binary;
--------------
-- On_Close --
--------------
overriding procedure On_Close
(Self : in out WS_Handler;
Status : Web_Socket.Listeners.Status_Code;
Reason : League.Strings.Universal_String) is
begin
Ada.Wide_Wide_Text_IO.Put_Line
("On_Close: "
& Web_Socket.Listeners.Status_Code'Wide_Wide_Image (Status)
& Reason.To_Wide_Wide_String);
end On_Close;
----------------
-- On_Connect --
----------------
overriding procedure On_Connect (Self : in out WS_Handler) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Connect");
end On_Connect;
--------------
-- On_Error --
--------------
overriding procedure On_Error (Self : in out WS_Handler) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Error");
end On_Error;
-------------
-- On_Text --
-------------
overriding procedure On_Text
(Self : in out WS_Handler;
Text : League.Strings.Universal_String) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Text: " & Text.To_Wide_Wide_String);
if Self.Count < Max_Count then
Self.Count := Self.Count + 1;
Web_Socket.Connections.Connection'Class (Self.WS).
Send_Text (Text);
end if;
end On_Text;
end Servlets.Hello;
|
eliben/pss | Ada | 139 | adb | just a line
context-2
context-1
line with match - abc
context+1
context+2
bloop
groop
line matching 'abc' again
derm
germ
blah
1
2
3
|
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Style_Name_Attributes is
pragma Preelaborate;
type ODF_Draw_Style_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Style_Name_Attribute_Access is
access all ODF_Draw_Style_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Style_Name_Attributes;
|
reznikmm/matreshka | Ada | 4,696 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Decoder and encoder of ASCII.
------------------------------------------------------------------------------
private package Matreshka.Internals.Text_Codecs.ASCII is
pragma Preelaborate;
-------------------
-- ASCII_Decoder --
-------------------
type ASCII_Decoder is new Abstract_Decoder with private;
overriding function Is_Error (Self : ASCII_Decoder) return Boolean;
overriding function Is_Mailformed (Self : ASCII_Decoder) return Boolean;
overriding procedure Decode_Append
(Self : in out ASCII_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access);
function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class;
-------------------
-- ASCII_Encoder --
-------------------
type ASCII_Encoder is new Abstract_Encoder with private;
overriding procedure Encode
(Self : in out ASCII_Encoder;
String : not null Matreshka.Internals.Strings.Shared_String_Access;
Buffer : out MISEV.Shared_Stream_Element_Vector_Access);
function Encoder return Abstract_Encoder'Class;
private
type ASCII_Decoder is new Abstract_Decoder with record
Error : Boolean := False;
end record;
type ASCII_Encoder is new Abstract_Encoder with null record;
end Matreshka.Internals.Text_Codecs.ASCII;
|
persan/AdaYaml | Ada | 675 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package Yaml.Lexer.Buffering_Test is
type TC is new Test_Cases.Test_Case with record
Pool : Text.Pool.Reference;
end record;
overriding procedure Register_Tests (T : in out TC);
overriding procedure Set_Up (T : in out TC);
function Name (T : TC) return Message_String;
procedure Test_File_Without_Refill (T : in out Test_Cases.Test_Case'Class);
procedure Test_File_With_Single_Refill (T : in out Test_Cases.Test_Case'Class);
end Yaml.Lexer.Buffering_Test;
|
reznikmm/matreshka | Ada | 3,694 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Border_Attributes is
pragma Preelaborate;
type ODF_Draw_Border_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Border_Attribute_Access is
access all ODF_Draw_Border_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Border_Attributes;
|
zhmu/ananas | Ada | 183 | adb | -- { dg-do run }
with Array39_Pkg; use Array39_Pkg;
procedure Array39 is
T : Tsk;
R : Rec2;
begin
T.E (R, 1);
if R.A (1) /= Val then
raise Program_Error;
end if;
end;
|
kraileth/ravensource | Ada | 1,008 | adb | --- gnatstudio/src/gps-main.adb.orig 2022-05-11 12:25:42 UTC
+++ gnatstudio/src/gps-main.adb
@@ -773,30 +773,6 @@ procedure GPS.Main is
end if;
end;
- -- Python startup path
-
- declare
- Python_Path : constant String := Env.Value ("PYTHONPATH", "");
- New_Val : String_Access;
-
- begin
- if Python_Path = "" then
- New_Val := new String'
- (+Create_From_Dir
- (Prefix_Dir, "share/gnatstudio/python").Full_Name);
- else
- New_Val := new String'
- (+To_Path
- (From_Path (+Python_Path) &
- (1 => Create_From_Dir
- (Prefix_Dir, "share/gnatstudio/python"))));
- end if;
-
- Setenv ("PYTHONPATH", New_Val.all);
- Trace (Me, "PYTHONPATH=" & New_Val.all);
- Free (New_Val);
- end;
-
for J of Env.Keys loop
Each_Environment_Variable (J, Env.Value (J));
end loop;
|
leo-brewin/adm-bssn-numerical | Ada | 5,581 | adb | with Ada.Numerics.Generic_Elementary_Functions;
-- for reporting Ksner parameters
with Ada.Text_IO; use Ada.Text_IO;
-- for parsing of the command line arguments
with Support.RegEx; use Support.RegEx;
with Support.CmdLine; use Support.CmdLine;
with Support.Strings; use Support.Strings;
package body Metric.Kasner is
package Maths is new Ada.Numerics.Generic_Elementary_Functions (Real); use Maths;
-- allow the pi to be set on the command line: -p0.666:0.666:-0.333
re_real : String := "([-+]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?)"; -- note counts as 2 groups (1.234(e+56))
re_real_seq : String := re_real&":"&re_real&":"&re_real;
p1 : Real := grep (read_command_arg ('p',"0.666666666666666666:0.666666666666666666:-0.333333333333333333"),re_real_seq,1,fail=> 2.0/3.0);
p2 : Real := grep (read_command_arg ('p',"0.666666666666666666:0.666666666666666666:-0.333333333333333333"),re_real_seq,3,fail=> 2.0/3.0);
p3 : Real := grep (read_command_arg ('p',"0.666666666666666666:0.666666666666666666:-0.333333333333333333"),re_real_seq,5,fail=> -1.0/3.0);
-- hard wired pi
-- p1 : Real := 2.0/3.0;
-- p2 : Real := 2.0/3.0;
-- p3 : Real := - 1.0/3.0;
----------------------------------------------------------------------------
-- ADM data
function set_3d_lapse (t, x, y, z : Real) return Real is
begin
return 1.0;
end set_3d_lapse;
function set_3d_metric (t, x, y, z : Real) return MetricPointArray is
gab : MetricPointArray := (others => 0.0);
begin
gab (xx) := t ** (2.0*p1); -- gxx
gab (yy) := t ** (2.0*p2); -- gyy
gab (zz) := t ** (2.0*p3); -- gzz
return gab;
end set_3d_metric;
function set_3d_extcurv (t, x, y, z : Real) return ExtcurvPointArray is
N : Real;
Kab : ExtcurvPointArray := (others => 0.0);
begin
N := set_3d_lapse (t, x, y, z);
Kab (xx) := - p1 * (t ** (2.0*p1-1.0)) / N ; -- Kxx
Kab (yy) := - p2 * (t ** (2.0*p2-1.0)) / N ; -- Kyy
Kab (zz) := - p3 * (t ** (2.0*p3-1.0)) / N ; -- Kzz
return Kab;
end set_3d_extcurv;
----------------------------------------------------------------------------
-- BSSN data
function set_3d_phi (t, x, y, z : Real) return Real is
begin
return (1.0/6.0) * log (t);
end set_3d_phi;
function set_3d_trK (t, x, y, z : Real) return Real is
begin
return -1.0 / t;
end set_3d_trK;
function set_3d_gBar (t, x, y, z : Real) return MetricPointArray is
gBar : MetricPointArray := (others => 0.0);
begin
gBar (xx) := t ** (2.0*p1-(2.0/3.0)); -- gBar_xx
gBar (yy) := t ** (2.0*p2-(2.0/3.0)); -- gBar_yy
gBar (zz) := t ** (2.0*p3-(2.0/3.0)); -- gBar_zz
return gBar;
end set_3d_gBar;
function set_3d_Abar (t, x, y, z : Real) return ExtcurvPointArray is
N : Real;
ABar : ExtcurvPointArray := (others => 0.0);
begin
N := set_3d_lapse (t, x, y, z);
ABar (xx) := (-p1+(1.0/3.0)) * (t ** (2.0*p1-(5.0/3.0))) / N ; -- ABar_xx
ABar (yy) := (-p2+(1.0/3.0)) * (t ** (2.0*p2-(5.0/3.0))) / N ; -- ABar_yy
ABar (zz) := (-p3+(1.0/3.0)) * (t ** (2.0*p3-(5.0/3.0))) / N ; -- ABar_zz
return ABar;
end set_3d_Abar;
function set_3d_Gi (t, x, y, z : Real) return GammaPointArray is
Gi : GammaPointArray := (others => 0.0);
begin
return Gi;
end set_3d_Gi;
----------------------------------------------------------------------------
-- ADM data
function set_3d_lapse (t : Real; point : GridPoint) return Real is
begin
return 1.0;
end set_3d_lapse;
function set_3d_metric (t : Real; point : GridPoint) return MetricPointArray is
x, y, z : Real;
begin
x := point.x;
y := point.y;
z := point.z;
return set_3d_metric (t, x, y, z);
end set_3d_metric;
function set_3d_extcurv (t : Real; point : GridPoint) return ExtcurvPointArray is
x, y, z : Real;
begin
x := point.x;
y := point.y;
z := point.z;
return set_3d_extcurv (t, x, y, z);
end set_3d_extcurv;
----------------------------------------------------------------------------
-- BSSN data
function set_3d_phi (t : Real; point : GridPoint) return Real is
begin
return (1.0/6.0) * log (t);
end set_3d_phi;
function set_3d_trK (t : Real; point : GridPoint) return Real is
begin
return -1.0 / t;
end set_3d_trK;
function set_3d_gBar (t : Real; point : GridPoint) return MetricPointArray is
x, y, z : Real;
begin
x := point.x;
y := point.y;
z := point.z;
return set_3d_gBar (t, x, y, z);
end set_3d_gBar;
function set_3d_Abar (t : Real; point : GridPoint) return ExtcurvPointArray is
x, y, z : Real;
begin
x := point.x;
y := point.y;
z := point.z;
return set_3d_Abar (t, x, y, z);
end set_3d_Abar;
function set_3d_Gi (t : Real; point : GridPoint) return GammaPointArray is
Gi : GammaPointArray := (others => 0.0);
begin
return Gi;
end set_3d_Gi;
----------------------------------------------------------------------------
procedure get_pi (p1, p2, p3 : out Real) is
begin
p1 := Metric.Kasner.p1;
p2 := Metric.Kasner.p2;
p3 := Metric.Kasner.p3;
end get_pi;
procedure report_kasner_params is
begin
Put_Line ("> Kasner p1 = "&str(p1,16));
Put_Line ("> Kasner p2 = "&str(p2,16));
Put_Line ("> Kasner p3 = "&str(p3,16));
end report_kasner_params;
end Metric.Kasner;
|
reznikmm/matreshka | Ada | 4,648 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Decimal_Places_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Decimal_Places_Attribute_Node is
begin
return Self : Style_Decimal_Places_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Decimal_Places_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Decimal_Places_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Decimal_Places_Attribute,
Style_Decimal_Places_Attribute_Node'Tag);
end Matreshka.ODF_Style.Decimal_Places_Attributes;
|
Fabien-Chouteau/motherlode | Ada | 2,104 | ads | -- Motherlode
-- Copyright (c) 2020 Fabien Chouteau
with HAL; use HAL;
with PyGamer; use PyGamer;
with PyGamer.Screen;
with World;
package Render is
subtype Frame_Buffer
is HAL.UInt16_Array (0 .. (Screen.Width * Screen.Height) - 1);
procedure Draw_Cell (FB : in out Frame_Buffer;
X, Y : Integer;
Kind : World.Cell_Kind);
procedure Draw_Tile (FB : in out Frame_Buffer;
X, Y : Integer;
Id : Natural);
procedure Draw_World (FB : in out Frame_Buffer);
procedure Draw_Player (FB : in out Frame_Buffer;
X, Y : Integer);
procedure Draw_Char (FB : in out Frame_Buffer;
Char : Character;
X, Y : Natural);
procedure Draw_String (FB : in out Frame_Buffer;
Str : String;
X, Y : Natural);
-- Draw a string with X, Y being at the top left
procedure Draw_String_Left (FB : in out Frame_Buffer;
Str : String;
X, Y : Natural);
-- Draw a string with X, Y being at the top right
procedure Draw_String_Center (FB : in out Frame_Buffer;
Str : String;
X, Y : Natural);
-- Draw a string with X, Y being at the center of the text
procedure Draw_H_Line (FB : in out Frame_Buffer;
X, Y, Len : Natural;
Color : UInt16);
procedure Draw_V_Line (FB : in out Frame_Buffer;
X, Y, Len : Natural;
Color : UInt16);
function RGB565 (R, G, B : HAL.UInt8) return HAL.UInt16;
FB1 : aliased HAL.UInt16_Array := (0 .. (Screen.Width * Screen.Height) - 1 => 0);
FB2 : aliased HAL.UInt16_Array := (0 .. (Screen.Width * Screen.Height) - 1 => 0);
Flip : Boolean := True;
procedure Refresh_Screen (Acc : not null Screen.Framebuffer_Access);
end Render;
|
reznikmm/matreshka | Ada | 6,940 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Reference_Mark_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Reference_Mark_Element_Node is
begin
return Self : Text_Reference_Mark_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Reference_Mark_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Reference_Mark
(ODF.DOM.Text_Reference_Mark_Elements.ODF_Text_Reference_Mark_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Reference_Mark_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Reference_Mark_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Reference_Mark_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Reference_Mark
(ODF.DOM.Text_Reference_Mark_Elements.ODF_Text_Reference_Mark_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Reference_Mark_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Reference_Mark
(Visitor,
ODF.DOM.Text_Reference_Mark_Elements.ODF_Text_Reference_Mark_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Reference_Mark_Element,
Text_Reference_Mark_Element_Node'Tag);
end Matreshka.ODF_Text.Reference_Mark_Elements;
|
apple-oss-distributions/old_ncurses | Ada | 4,248 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Menu_Demo.Aux --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus;
package Sample.Menu_Demo.Aux is
procedure Geometry (M : in Menu;
L : out Line_Count;
C : out Column_Count;
Y : out Line_Position;
X : out Column_Position);
-- Calculate the geometry for a panel beeing able to be used to display
-- the menu.
function Create (M : Menu;
Title : String;
Lin : Line_Position;
Col : Column_Position) return Panel;
-- Create a panel decorated with a frame and the title at the specified
-- position. The dimension of the panel is derived from the menus layout.
procedure Destroy (M : in Menu;
P : in out Panel);
-- Destroy all the windowing structures associated with this menu and
-- panel.
function Get_Request (M : Menu; P : Panel) return Key_Code;
-- Centralized request driver for all menus in this sample. This
-- gives us a common key binding for all menus.
end Sample.Menu_Demo.Aux;
|
Fabien-Chouteau/tiled-code-gen | Ada | 8,712 | adb | ------------------------------------------------------------------------------
-- --
-- tiled-code-gen --
-- --
-- Copyright (C) 2018 Fabien Chouteau --
-- --
-- --
-- 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.Command_Line;
with Ada.Text_IO;
with Ada.Directories; use Ada.Directories;
with TCG.Palette;
with TCG.Maps;
with TCG.Maps.Render;
with TCG.Maps.List;
with TCG.Outputs.PDF;
with TCG.Outputs.GESTE;
with TCG.Outputs.LibGBA;
with TCG.Outputs.RSTE;
with TCG.Tilesets;
use TCG;
with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.Strings; use GNAT.Strings;
with GNATCOLL.Utils; use GNATCOLL.Utils;
procedure Tiled_Code_Gen is
List : Maps.List.List;
Config : Command_Line_Configuration;
PDF_Enabled : aliased Boolean;
GESTE_Enabled : aliased Boolean;
RSTE_Enabled : aliased Boolean;
GBA_Enabled : aliased Boolean;
BMP_Enabled : aliased Boolean;
Source_Out_Dir : aliased String_Access := new String'("src");
Doc_Out_Dir : aliased String_Access := new String'("doc");
Color_Format_Str : aliased String_Access := new String'("RGB565");
Color_Format : Palette.Output_Color_Format;
Root_Package : aliased String_Access := new String'("Game_Assets");
Tileset : Tilesets.Tileset_Id := Tilesets.Invalid_Tileset;
use type Tilesets.Tileset_Id;
begin
declare
begin
Define_Switch
(Config, PDF_Enabled'Access, "-p",
Long_Switch => "--pdf",
Help => "Generate PDF documentation");
Define_Switch
(Config, GESTE_Enabled'Access, "-g",
Long_Switch => "--geste",
Help => "Generate code for GEneric Sprite and Tile Engine");
Define_Switch
(Config, RSTE_Enabled'Access, "",
Long_Switch => "--rste",
Help => "Generate code for Rust Sprite and Tile Engine");
Define_Switch
(Config, GBA_Enabled'Access, "",
Long_Switch => "--libgba",
Help => "Generate code for Rust Sprite and Tile Engine");
Define_Switch
(Config, BMP_Enabled'Access, "-b",
Long_Switch => "--bmp",
Help => "Generate bitmap images of the maps");
Define_Switch
(Config, Root_Package'Access, "-r:",
Long_Switch => "--root-package-name=",
Help => "Name of the root package of generated sources (default: " &
Root_Package.all & ")");
Define_Switch
(Config, Source_Out_Dir'Access, "-o:",
Long_Switch => "--source-out-dir=",
Help => "Output directory for the generated sources (default: " &
Source_Out_Dir .all & ")");
Define_Switch
(Config, Doc_Out_Dir'Access, "-d:",
Long_Switch => "--doc-out-dir=",
Help => "Output directory for the generated documentation " &
"(default: " & Doc_Out_Dir.all & ")");
Define_Switch
(Config, Color_Format_Str'Access, "-f:",
Long_Switch => "--color-format=",
Help => "Color format used in generated sources (" &
Palette.Supported_Formats & ") (default: " &
Color_Format_Str.all & ")");
Set_Usage
(Config,
"[switches] maps (.tmx) or tilesets (.tsx)",
"Tiled-Code-Gen, a code generator for Tiled the map editor");
Getopt (Config);
exception
when GNAT.Command_Line.Invalid_Switch =>
Ada.Command_Line.Set_Exit_Status (1);
return;
when GNAT.Command_Line.Exit_From_Command_Line =>
return;
end;
-- Checking output color format
if Palette.Format_Supported (Color_Format_Str.all) then
Color_Format := Palette.Convert (Color_Format_Str.all);
else
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Unsuported color format: " & Color_Format_Str.all);
Ada.Command_Line.Set_Exit_Status (1);
return;
end if;
-- Processing each Tiled maps
loop
declare
Arg : constant String := Get_Argument (Do_Expansion => True);
begin
exit when Arg'Length = 0;
if Ends_With (Arg, ".tmx") then
List.Append (TCG.Maps.Load (Arg, Base_Name (Arg)));
elsif Ends_With (Arg, ".tsx") then
Tileset := Tilesets.Load (Arg);
Tilesets.Fill_Master_Tileset (Tileset);
else
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Unknown file format: '" & Arg & "'");
end if;
end;
end loop;
if List.Is_Empty and then Tileset = Tilesets.Invalid_Tileset then
Display_Help (Config);
return;
end if;
for Map of List loop
TCG.Maps.Fill_Master_Tileset (Map);
end loop;
if GESTE_Enabled then
Outputs.GESTE.Gen_GESTE_Source (Directory => Source_Out_Dir.all,
Root_Package_Name => Root_Package.all,
Format => Color_Format,
Map_List => List);
end if;
if GBA_Enabled then
Outputs.LibGBA.Gen_LibGBA_Source
(Directory => Source_Out_Dir.all,
Root_Package_Name => Root_Package.all,
Map_List => List);
end if;
if RSTE_Enabled then
Outputs.RSTE.Gen_RSTE_Source (Directory => Source_Out_Dir.all,
Root_Module_Name => Root_Package.all,
Format => Color_Format,
Map_List => List);
end if;
if PDF_Enabled then
Outputs.PDF.Gen_PDF_Doc (Doc_Out_Dir.all, "doc.pdf", List);
end if;
if BMP_Enabled then
for M of List loop
TCG.Maps.Render.To_BMP
(M,
Path => Compose (Doc_Out_Dir.all, Maps.Name (M) & ".bmp"),
Background => (255, 255, 255, 255));
end loop;
end if;
if not GESTE_Enabled
and then
not GBA_Enabled
and then
not PDF_Enabled
and then
not BMP_Enabled
then
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error, "Warning: no generator enabled.");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error, "Use --help to see the list of options.");
end if;
end Tiled_Code_Gen;
|
io7m/coreland-stack-ada | Ada | 2,907 | adb | with Test;
with Stack;
procedure t_ops1 is
package Int_Stack is new Stack (element_type => Natural);
Stack : Int_Stack.Stack_t;
procedure Push
(Expected_Value : Natural;
Expected_Size : Natural)
is
Got_value : Natural;
Got_Size : Natural;
begin
Int_Stack.Push (Stack, Expected_Value);
Int_Stack.Peek (Stack, Got_value);
Got_Size := Int_Stack.Size (Stack);
Test.Assert
(Check => Got_value = Expected_Value,
Pass_Message => "Push value " & Natural'Image (Got_value) & " = " & Natural'Image (Expected_Value),
Fail_Message => "Push value " & Natural'Image (Got_value) & " /= " & Natural'Image (Expected_Value));
Test.Assert
(Check => Got_Size = Expected_Size,
Pass_Message => "Push Size " & Natural'Image (Got_Size) & " = " & Natural'Image (Expected_Size),
Fail_Message => "Push Size " & Natural'Image (Got_Size) & " /= " & Natural'Image (Expected_Size));
end Push;
procedure Pop
(Expected_Value : Natural;
Expected_Size : Natural)
is
Got_value : Natural;
Got_Size : Natural;
begin
Int_Stack.Pop (Stack, Got_value);
Got_Size := Int_Stack.Size (Stack);
Test.Assert
(Check => Got_value = Expected_Value,
Pass_Message => "Pop value " & Natural'Image (Got_value) & " = " & Natural'Image (Expected_Value),
Fail_Message => "Pop value " & Natural'Image (Got_value) & " /= " & Natural'Image (Expected_Value));
Test.Assert
(Check => Got_Size = Expected_Size,
Pass_Message => "Pop Size " & Natural'Image (Got_Size) & " = " & Natural'Image (Expected_Size),
Fail_Message => "Pop Size " & Natural'Image (Got_Size) & " /= " & Natural'Image (Expected_Size));
end Pop;
begin
Test.Assert
(Check => Int_Stack.Size (Stack) = 0,
Pass_Message => "Stack is empty",
Fail_Message => "Stack not empty at initialization");
Push (Expected_Value => 100, Expected_Size => 1);
Push (Expected_Value => 200, Expected_Size => 2);
Push (Expected_Value => 300, Expected_Size => 3);
Push (Expected_Value => 400, Expected_Size => 4);
Push (Expected_Value => 500, Expected_Size => 5);
Pop (Expected_Value => 500, Expected_Size => 4);
Pop (Expected_Value => 400, Expected_Size => 3);
Pop (Expected_Value => 300, Expected_Size => 2);
Pop (Expected_Value => 200, Expected_Size => 1);
Pop (Expected_Value => 100, Expected_Size => 0);
Push (Expected_Value => 100, Expected_Size => 1);
Push (Expected_Value => 200, Expected_Size => 2);
Push (Expected_Value => 300, Expected_Size => 3);
Push (Expected_Value => 400, Expected_Size => 4);
Push (Expected_Value => 500, Expected_Size => 5);
Int_Stack.Clear (Stack);
Test.Assert
(Check => Int_Stack.Size (Stack) = 0,
Pass_Message => "Stack is empty",
Fail_Message => "Stack not empty at initialization");
end t_ops1;
|
dksmiffs/gnatmake-examples | Ada | 61 | ads | package I_Am_Ada is
procedure Ada_Procedure;
end I_Am_Ada;
|
annexi-strayline/AURA | Ada | 4,040 | ads | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2023, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Registrar.Queries;
with Registrar.Subsystems;
procedure Registrar.Registration.Unchecked_Deregister_Subsystem
(SS: in out Registrar.Subsystems.Subsystem)
with Pre => Registrar.Queries.Subsystem_Registered (SS.Name);
-- Unchecked_Deregister_Subsystem removes a subsystem from the All_Subsystems
-- set.
--
-- Currently this procedure is used only by:
--
-- * Depreciation_Handlers.AURA_Subdirectory, to de-register the AURA subsystem
-- if already registered via aura subsystem units in the root directory
--
-- Any other uses shall be documented here.
|
pok-kernel/pok | Ada | 4,673 | ads | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2022 POK team
-- This is a compilable Ada 95 specification for the APEX interface,
-- derived from section 3 of ARINC 653.
-- The declarations of the services given below are taken from the
-- standard, as are the enumerated types and the names of the others types.
-- However, the definitions given for these others types, and the
-- names and values given below for constants, are all implementation
-- specific.
-- All types have defining representation pragmas or clauses to ensure
-- representation compatibility with the C and Ada 83 bindings.
-- ---------------------------------------------------------------------------
-- --
-- Root package providing constant and type definitions --
-- --
-- ---------------------------------------------------------------------------
with System;
-- This is the Ada 95 predefined C interface package
with Interfaces.C;
package APEX is
pragma Pure;
-- ----------------------------
-- Domain limits --
-- ----------------------------
-- Domain dependent
-- These values define the domain limits and are implementation-dependent.
System_Limit_Number_Of_Partitions : constant := 32;
-- module scope
System_Limit_Number_Of_Messages : constant := 512;
-- module scope
System_Limit_Message_Size : constant := 16#10_0000#;
-- module scope
System_Limit_Number_Of_Processes : constant := 1024;
-- partition scope
System_Limit_Number_Of_Sampling_Ports : constant := 1024;
-- partition scope
System_Limit_Number_Of_Queuing_Ports : constant := 1024;
-- partition scope
System_Limit_Number_Of_Buffers : constant := 512;
-- partition scope
System_Limit_Number_Of_Blackboards : constant := 512;
-- partition scope
System_Limit_Number_Of_Semaphores : constant := 512;
-- partition scope
System_Limit_Number_Of_Events : constant := 512;
-- partition scope
-- ----------------------------
-- Base APEX types --
-- ----------------------------
-- The actual sizes of these base types are system-specific and must
-- match those of the underlying Operating System.
type APEX_Byte is new Interfaces.C.unsigned_char;
type APEX_Integer is new Interfaces.C.long;
type APEX_Unsigned is new Interfaces.C.unsigned_long;
type APEX_Long_Integer is new Interfaces.Integer_64;
-- If Integer_64 is not provided in package Interfaces, any implementation-
-- defined alternative 64-bit signed integer type may be used.
-- ----------------------------
-- General APEX types --
-- ----------------------------
type Return_Code_Type is (
No_Error, -- request valid and operation performed
No_Action, -- status of system unaffected by request
Not_Available, -- resource required by request unavailable
Invalid_Param, -- invalid parameter specified in request
Invalid_Config, -- parameter incompatible with configuration
Invalid_Mode, -- request incompatible with current mode
Timed_Out); -- time-out tied up with request has expired
pragma Convention (C, Return_Code_Type);
Max_Name_Length : constant := 30;
subtype Name_Type is String (1 .. Max_Name_Length);
subtype System_Address_Type is System.Address;
subtype Message_Addr_Type is System.Address;
subtype Message_Size_Type is APEX_Integer range
1 .. System_Limit_Message_Size;
subtype Message_Range_Type is APEX_Integer range
0 .. System_Limit_Number_Of_Messages;
type Port_Direction_Type is (Source, Destination);
pragma Convention (C, Port_Direction_Type);
type Queuing_Discipline_Type is (Fifo, Priority);
pragma Convention (C, Queuing_Discipline_Type);
subtype System_Time_Type is APEX_Long_Integer;
-- 64-bit signed integer with 1 nanosecond LSB
Infinite_Time_Value : constant System_Time_Type;
Aperiodic : constant System_Time_Type;
Zero_Time_Value : constant System_Time_Type;
private
Infinite_Time_Value : constant System_Time_Type := -1;
Aperiodic : constant System_Time_Type := 0;
Zero_Time_Value : constant System_Time_Type := 0;
end APEX;
|
sungyeon/drake | Ada | 36 | ads | ../machine-apple-darwin/a-hifina.ads |
zhmu/ananas | Ada | 7,097 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- C A S I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Csets; use Csets;
with Opt; use Opt;
with Widechar; use Widechar;
package body Casing is
----------------------
-- Determine_Casing --
----------------------
function Determine_Casing (Ident : Text_Buffer) return Casing_Type is
All_Lower : Boolean := True;
-- Set False if upper case letter found
All_Upper : Boolean := True;
-- Set False if lower case letter found
Mixed : Boolean := True;
-- Set False if exception to mixed case rule found (lower case letter
-- at start or after underline, or upper case letter elsewhere).
Decisive : Boolean := False;
-- Set True if at least one instance of letter not after underline
After_Und : Boolean := True;
-- True at start of string, and after an underline character
begin
-- A special exception, consider SPARK_Mode to be mixed case
if Ident = "SPARK_Mode" then
return Mixed_Case;
end if;
-- Proceed with normal determination
for S in Ident'Range loop
if Ident (S) = '_' or else Ident (S) = '.' then
After_Und := True;
elsif Is_Lower_Case_Letter (Ident (S)) then
All_Upper := False;
if not After_Und then
Decisive := True;
else
After_Und := False;
Mixed := False;
end if;
elsif Is_Upper_Case_Letter (Ident (S)) then
All_Lower := False;
if not After_Und then
Decisive := True;
Mixed := False;
else
After_Und := False;
end if;
end if;
end loop;
-- Now we can figure out the result from the flags we set in that loop
if All_Lower then
return All_Lower_Case;
elsif not Decisive then
return Unknown;
elsif All_Upper then
return All_Upper_Case;
elsif Mixed then
return Mixed_Case;
else
return Unknown;
end if;
end Determine_Casing;
------------------------
-- Set_All_Upper_Case --
------------------------
procedure Set_All_Upper_Case is
begin
Set_Casing (All_Upper_Case);
end Set_All_Upper_Case;
----------------
-- Set_Casing --
----------------
procedure Set_Casing
(Buf : in out Bounded_String;
C : Casing_Type;
D : Casing_Type := Mixed_Case)
is
Ptr : Natural;
Actual_Casing : Casing_Type;
-- Set from C or D as appropriate
After_Und : Boolean := True;
-- True at start of string, and after an underline character or after
-- any other special character that is not a normal identifier char).
begin
if C /= Unknown then
Actual_Casing := C;
else
Actual_Casing := D;
end if;
Ptr := 1;
while Ptr <= Buf.Length loop
-- Wide character. Note that we do nothing with casing in this case.
-- In Ada 2005 mode, required folding of lower case letters happened
-- as the identifier was scanned, and we do not attempt any further
-- messing with case (note that in any case we do not know how to
-- fold upper case to lower case in wide character mode). We also
-- do not bother with recognizing punctuation as equivalent to an
-- underscore. There is nothing functional at this stage in doing
-- the requested casing operation, beyond folding to upper case
-- when it is mandatory, which does not involve underscores.
if Buf.Chars (Ptr) = ASCII.ESC
or else Buf.Chars (Ptr) = '['
or else (Upper_Half_Encoding
and then Buf.Chars (Ptr) in Upper_Half_Character)
then
Skip_Wide (Buf.Chars, Ptr);
After_Und := False;
-- Underscore, or non-identifer character (error case)
elsif Buf.Chars (Ptr) = '_'
or else not Identifier_Char (Buf.Chars (Ptr))
then
After_Und := True;
Ptr := Ptr + 1;
-- Lower case letter
elsif Is_Lower_Case_Letter (Buf.Chars (Ptr)) then
if Actual_Casing = All_Upper_Case
or else (After_Und and then Actual_Casing = Mixed_Case)
then
Buf.Chars (Ptr) := Fold_Upper (Buf.Chars (Ptr));
end if;
After_Und := False;
Ptr := Ptr + 1;
-- Upper case letter
elsif Is_Upper_Case_Letter (Buf.Chars (Ptr)) then
if Actual_Casing = All_Lower_Case
or else (not After_Und and then Actual_Casing = Mixed_Case)
then
Buf.Chars (Ptr) := Fold_Lower (Buf.Chars (Ptr));
end if;
After_Und := False;
Ptr := Ptr + 1;
-- Other identifier character (must be digit)
else
After_Und := False;
Ptr := Ptr + 1;
end if;
end loop;
end Set_Casing;
procedure Set_Casing (C : Casing_Type; D : Casing_Type := Mixed_Case) is
begin
Set_Casing (Global_Name_Buffer, C, D);
end Set_Casing;
end Casing;
|
stcarrez/dynamo | Ada | 1,666 | ads | -----------------------------------------------------------------------
-- gen-commands-page -- Page creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Gen.Commands.Page is
-- ------------------------------
-- Page Creation Command
-- ------------------------------
-- This command adds a XHTML page to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Page;
|
reznikmm/matreshka | Ada | 3,451 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Nodes.Character_Datas.Texts;
package XML.DOM.Texts renames XML.DOM.Nodes.Character_Datas.Texts;
|
reznikmm/matreshka | Ada | 4,589 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes.Elements;
with XML.DOM.Visitors;
package Matreshka.ODF_Elements is
type ODF_Element_Node is
abstract new Matreshka.DOM_Nodes.Elements.Abstract_Element
with null record;
overriding procedure Enter_Element
(Self : not null access ODF_Element_Node;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is abstract;
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access ODF_Element_Node;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is abstract;
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access ODF_Element_Node;
Iterator : in out Standard.XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control) is abstract;
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements;
|
rtoal/enhanced-dining-philosophers | Ada | 2,031 | ads | ------------------------------------------------------------------------------
-- host.ads
--
-- This package defines the task for the host. The host allows the philoso-
-- phers to enter and leave the restaurant. It also keeps track of how many
-- philosophers have died. The host is called Norman_Bates.
--
-- Entries:
--
-- Enter Allows you to enter the restaurant provided there are
-- at least two empty seats.
-- Leave Allows you to leave the restaurant.
-- Death_Announcement Records the fact that a philosopher has died.
--
-- Behavior:
--
-- The host just sits around waiting for someone to ask him to escort her
-- in to or out of the restaurant, or to inform him of a (philosopher's)
-- death. He will take requests to be seated only if there are at least two
-- free seats at the table. He will take requests to leave at any time.
-- After all the philosophers have informed him of their deaths, he will
-- fire all the cooks.
--
-- Termination:
--
-- The host keeps track of how many philosophers are alive. When this count
-- reaches zero, he will fire all the cooks and then subsequently terminate
-- himself.
--
-- Note:
--
-- The use of a host in the Dining Philosophers Problem is controversial be-
-- cause the system relies on the "ethics" of our philosophers. The phil-
-- osophers must be honest and always use the host to enter and leave, and
-- always inform the host that they are dead (or terminally ill and unable
-- to eat again!) One advantage, though, of having the philosophers inform-
-- ing the host of their death is that the host does not need to poll to see
-- how many philosophers are alive.
------------------------------------------------------------------------------
package Host is
task Norman_Bates is
entry Enter;
entry Leave;
entry Death_Announcement;
end Norman_Bates;
end Host;
|
leo-brewin/adm-bssn-numerical | Ada | 12,119 | adb | with Support; use Support;
with Support.Clock; use Support.Clock;
with Support.CmdLine; use Support.CmdLine;
with Support.Strings; use Support.Strings;
with ADMBase.Data_IO; use ADMBase.Data_IO;
with ADMBase.Text_IO; use ADMBase.Text_IO;
with ADMBase.Runge; use ADMBase.Runge;
with ADMBase.Time_Derivs; use ADMBase.Time_Derivs;
with Ada.Exceptions;
with System.Multiprocessors;
package body ADMBase.Evolve is
procedure evolve_data is
looping : Boolean;
task type SlaveTask is
entry resume;
entry pause;
entry release;
entry set_params (slave_params : SlaveParams);
end SlaveTask;
task body SlaveTask is
params : SlaveParams;
begin
-- collect parameters for this task ------------------------
accept set_params (slave_params : SlaveParams) do
params := slave_params;
end;
loop
select
-- start the runge kutta --------------------------------
accept resume; beg_runge_kutta (params); accept pause;
-- 1st step of runge-kutta ------------------------------
accept resume; set_time_derivatives_intr (params); accept pause;
accept resume; set_time_derivatives_bndry_fb (params); accept pause;
accept resume; set_time_derivatives_bndry_ew (params); accept pause;
accept resume; set_time_derivatives_bndry_ns (params); accept pause;
accept resume; rk_step (1.0 / 2.0, 1.0 / 6.0, params); accept pause;
-- 2nd step of runge-kutta ------------------------------
accept resume; set_time_derivatives_intr (params); accept pause;
accept resume; set_time_derivatives_bndry_fb (params); accept pause;
accept resume; set_time_derivatives_bndry_ew (params); accept pause;
accept resume; set_time_derivatives_bndry_ns (params); accept pause;
accept resume; rk_step (1.0 / 2.0, 1.0 / 3.0, params); accept pause;
-- 3rd step of runge-kutta ------------------------------
accept resume; set_time_derivatives_intr (params); accept pause;
accept resume; set_time_derivatives_bndry_fb (params); accept pause;
accept resume; set_time_derivatives_bndry_ew (params); accept pause;
accept resume; set_time_derivatives_bndry_ns (params); accept pause;
accept resume; rk_step (1.0, 1.0 / 3.0, params); accept pause;
-- 4th step of runge-kutta ------------------------------
accept resume; set_time_derivatives_intr (params); accept pause;
accept resume; set_time_derivatives_bndry_fb (params); accept pause;
accept resume; set_time_derivatives_bndry_ew (params); accept pause;
accept resume; set_time_derivatives_bndry_ns (params); accept pause;
accept resume; rk_step (0.0, 1.0 / 6.0, params); accept pause;
-- finish the runge kutta -------------------------------
accept resume; end_runge_kutta (params); accept pause;
or
-- time to release the tasks? ---------------------------
accept release;
exit;
or
terminate; -- a safeguard, just to ensure tasks don't hang
end select;
end loop;
exception
when whoops : others =>
Put_Line ("> Exception raised in task body");
Put_Line (Ada.Exceptions.Exception_Information (whoops));
report_elapsed_cpu (grid_point_num, num_loop);
halt (1);
end SlaveTask;
num_cpus : Integer := Integer (System.Multiprocessors.Number_Of_CPUs);
num_slaves : Integer := read_command_arg ('N',num_cpus);
slave_tasks : array (1..num_slaves) of SlaveTask;
slave_params : array (1..num_slaves) of SlaveParams;
procedure prepare_slaves is
n_point : constant Integer := grid_point_num;
n_intr : constant Integer := interior_num;
n_bndry : constant Integer := boundary_num;
n_north : constant Integer := north_bndry_num;
n_south : constant Integer := south_bndry_num;
n_east : constant Integer := east_bndry_num;
n_west : constant Integer := west_bndry_num;
n_front : constant Integer := front_bndry_num;
n_back : constant Integer := back_bndry_num;
begin
case num_slaves is
when 1 | 2 | 4 | 8 | 16 => null;
when others => Put_Line ("> Error: range error in num_slaves, should be 1,2,4,8 or 16");
Put_Line ("> num_slaves = " & str(num_slaves,0));
halt (1);
end case;
-- here we sub-divide the list of cells across the tasks.
-- it is *essential* that the every cell appears in *exactly* one sub-list.
-- if a cell appears in more than one sub-list then it will be processed by more
-- than one task. doing so wastes time, but far more worrying is that such multiple
-- processing may cause data to be overwritten!
for i in slave_params'range loop
slave_params (i)(1) := i;
end loop;
slave_params (1)( 2) := 1;
slave_params (1)( 4) := 1;
slave_params (1)( 6) := 1;
slave_params (1)( 8) := 1;
slave_params (1)(10) := 1;
slave_params (1)(12) := 1;
slave_params (1)(14) := 1;
slave_params (1)(16) := 1;
slave_params (1)(18) := 1;
for i in 2 .. num_slaves loop
slave_params (i-1)( 3) := (i-1)*n_point/num_slaves;
slave_params (i)(2) := 1 + slave_params (i-1)(3);
slave_params (i-1)( 5) := (i-1)*n_intr/num_slaves;
slave_params (i)(4) := 1 + slave_params (i-1)(5);
slave_params (i-1)( 7) := (i-1)*n_bndry/num_slaves;
slave_params (i)(6) := 1 + slave_params (i-1)(7);
slave_params (i-1)( 9) := (i-1)*n_north/num_slaves;
slave_params (i)(8) := 1 + slave_params (i-1)(9);
slave_params (i-1)(11) := (i-1)*n_south/num_slaves;
slave_params (i)(10) := 1 + slave_params (i-1)(11);
slave_params (i-1)(13) := (i-1)*n_east/num_slaves;
slave_params (i)(12) := 1 + slave_params (i-1)(13);
slave_params (i-1)(15) := (i-1)*n_west/num_slaves;
slave_params (i)(14) := 1 + slave_params (i-1)(15);
slave_params (i-1)(17) := (i-1)*n_front/num_slaves;
slave_params (i)(16) := 1 + slave_params (i-1)(17);
slave_params (i-1)(19) := (i-1)*n_back/num_slaves;
slave_params (i)(18) := 1 + slave_params (i-1)(19);
end loop;
slave_params (num_slaves)( 3) := n_point;
slave_params (num_slaves)( 5) := n_intr;
slave_params (num_slaves)( 7) := n_bndry;
slave_params (num_slaves)( 9) := n_north;
slave_params (num_slaves)(11) := n_south;
slave_params (num_slaves)(13) := n_east;
slave_params (num_slaves)(15) := n_west;
slave_params (num_slaves)(17) := n_front;
slave_params (num_slaves)(19) := n_back;
for i in 1..num_slaves loop
slave_tasks(i).set_params (slave_params(i));
end loop;
-- use this to verify the slave params are set correctly
-- for i in slave_params'Range loop
-- put ("Slave "&str(i,2)&" params: ");
-- for j in slave_params(i)'Range loop
-- put (str(slave_params(i)(j),7)&' ');
-- end loop;
-- new_line;
-- end loop;
-- halt;
end prepare_slaves;
procedure release_slaves is
begin
for i in slave_tasks'Range loop
slave_tasks(i).release;
end loop;
end release_slaves;
procedure advance_slaves is
begin
for i in slave_tasks'Range loop
slave_tasks(i).resume;
end loop;
for i in slave_tasks'Range loop
slave_tasks(i).pause;
end loop;
end advance_slaves;
procedure runge_kutta_step is
begin
advance_slaves; -- set interior time derivatives
advance_slaves; -- set boundary time derivatives on front & back faces
advance_slaves; -- set boundary time derivatives on east & west faces
advance_slaves; -- set boundary time derivatives on north & south faces
-- use this to show that all d/dt are correct
-- for the Kasner initial data, all d/dt should be equal across all grid points
-- note the changes that arise if the order in which the boundaries are set is changed
-- note: use this test on a small grid, e.g., 5x5x5
-- declare
-- i,j,k : Integer;
-- begin
-- for a in 1..grid_point_num loop
-- i := grid_point_list (a).i;
-- j := grid_point_list (a).j;
-- k := grid_point_list (a).k;
-- put_line (str(i)&' '&str(j)&' '&str(k)&' '&
-- str(ADMBase.dot_gab(i,j,k)(1))&' '&
-- str(ADMBase.dot_gab(i,j,k)(4))&' '&
-- str(ADMBase.dot_gab(i,j,k)(6)));
-- end loop;
-- halt;
-- end;
advance_slaves; -- Runge-Kutta step
end runge_kutta_step;
procedure evolve_one_step is
begin
-- 4th order RK ---
advance_slaves; -- prepare for a new Runge-Kutta step
runge_kutta_step; -- the four Runge-Kutta steps
runge_kutta_step;
runge_kutta_step;
runge_kutta_step;
advance_slaves; -- complete the Runge-Kutta step
end evolve_one_step;
begin
prepare_slaves;
num_loop := 0;
looping := (num_loop < max_loop);
print_time := the_time + print_time_step;
set_time_step;
set_time_step_min;
set_finite_diff_factors;
set_time_derivatives;
create_text_io_lists;
write_summary_header;
write_results;
write_summary;
write_history;
reset_elapsed_cpu;
loop
evolve_one_step;
num_loop := num_loop + 1;
looping := (num_loop < max_loop) and (the_time < end_time - 0.5*time_step);
if (print_cycle > 0 and then (num_loop rem print_cycle) = 0)
or (abs (the_time-print_time) < 0.5*time_step)
or (the_time > print_time)
or (not looping)
then
write_results;
write_summary;
write_history;
print_time := print_time + print_time_step;
set_time_step;
if time_step < time_step_min then
raise Constraint_error with "time step too small";
end if;
if print_time_step < time_step then
raise Constraint_Error with "print time step < time step";
end if;
end if;
exit when not looping;
end loop;
release_slaves;
write_summary_trailer;
report_elapsed_cpu (grid_point_num, num_loop);
exception
when whoops : others =>
Put_Line ("> Exception raised in evolve_data");
Put_Line (Ada.Exceptions.Exception_Information (whoops));
report_elapsed_cpu (grid_point_num, num_loop);
halt (1);
end evolve_data;
end ADMBase.Evolve;
|
reznikmm/matreshka | Ada | 3,822 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Vertical is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_End_Line_Spacing_Vertical_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.End_Line_Spacing_Vertical_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Vertical;
|
zhmu/ananas | Ada | 124 | ads | package Limited_With7_Pkg is
type Rec;
type Rec is record
I : Integer;
end record;
end Limited_With7_Pkg;
|
pchapin/acrypto | Ada | 11,307 | adb | ---------------------------------------------------------------------------
-- FILE : test_block_ciphers-test_blowfish.adb
-- SUBJECT : Procedure to test the Blowfish implementation.
-- AUTHOR : (C) Copyright 2009 by Peter Chapin
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
with ACO.Crypto.Block_Cipher.BLowfish;
separate( Test_Block_Ciphers )
procedure Test_Blowfish is
type Test_Case is
record
Key : ACO.Octet_Array(0 .. 7);
Plain_Text : ACO.Octet_Array(0 .. 7);
Cipher_Text : ACO.Octet_Array(0 .. 7);
end record;
-- The following test vectors are from http://www.schneier.com/blowfish.html.
Test_Cases : array(1 .. 34) of Test_Case :=
( (Key => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Plain_Text => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Cipher_Text => (16#4E#, 16#F9#, 16#97#, 16#45#, 16#61#, 16#98#, 16#DD#, 16#78#)),
(Key => (16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#),
Plain_Text => (16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#),
Cipher_Text => (16#51#, 16#86#, 16#6F#, 16#D5#, 16#B8#, 16#5E#, 16#CB#, 16#8A#)),
(Key => (16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Plain_Text => (16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#),
Cipher_Text => (16#7D#, 16#85#, 16#6F#, 16#9A#, 16#61#, 16#30#, 16#63#, 16#F2#)),
(Key => (16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#),
Plain_Text => (16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#),
Cipher_Text => (16#24#, 16#66#, 16#DD#, 16#87#, 16#8B#, 16#96#, 16#3C#, 16#9D#)),
(Key => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Plain_Text => (16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#),
Cipher_Text => (16#61#, 16#F9#, 16#C3#, 16#80#, 16#22#, 16#81#, 16#B0#, 16#96#)),
(Key => (16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#, 16#11#),
Plain_Text => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Cipher_Text => (16#7D#, 16#0C#, 16#C6#, 16#30#, 16#AF#, 16#DA#, 16#1E#, 16#C7#)),
(Key => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Plain_Text => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Cipher_Text => (16#4E#, 16#F9#, 16#97#, 16#45#, 16#61#, 16#98#, 16#DD#, 16#78#)),
(Key => (16#FE#, 16#DC#, 16#BA#, 16#98#, 16#76#, 16#54#, 16#32#, 16#10#),
Plain_Text => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Cipher_Text => (16#0A#, 16#CE#, 16#AB#, 16#0F#, 16#C6#, 16#A0#, 16#A2#, 16#8D#)),
(Key => (16#7C#, 16#A1#, 16#10#, 16#45#, 16#4A#, 16#1A#, 16#6E#, 16#57#),
Plain_Text => (16#01#, 16#A1#, 16#D6#, 16#D0#, 16#39#, 16#77#, 16#67#, 16#42#),
Cipher_Text => (16#59#, 16#C6#, 16#82#, 16#45#, 16#EB#, 16#05#, 16#28#, 16#2B#)),
(Key => (16#01#, 16#31#, 16#D9#, 16#61#, 16#9D#, 16#C1#, 16#37#, 16#6E#),
Plain_Text => (16#5C#, 16#D5#, 16#4C#, 16#A8#, 16#3D#, 16#EF#, 16#57#, 16#DA#),
Cipher_Text => (16#B1#, 16#B8#, 16#CC#, 16#0B#, 16#25#, 16#0F#, 16#09#, 16#A0#)),
(Key => (16#07#, 16#A1#, 16#13#, 16#3E#, 16#4A#, 16#0B#, 16#26#, 16#86#),
Plain_Text => (16#02#, 16#48#, 16#D4#, 16#38#, 16#06#, 16#F6#, 16#71#, 16#72#),
Cipher_Text => (16#17#, 16#30#, 16#E5#, 16#77#, 16#8B#, 16#EA#, 16#1D#, 16#A4#)),
(Key => (16#38#, 16#49#, 16#67#, 16#4C#, 16#26#, 16#02#, 16#31#, 16#9E#),
Plain_Text => (16#51#, 16#45#, 16#4B#, 16#58#, 16#2D#, 16#DF#, 16#44#, 16#0A#),
Cipher_Text => (16#A2#, 16#5E#, 16#78#, 16#56#, 16#CF#, 16#26#, 16#51#, 16#EB#)),
(Key => (16#04#, 16#B9#, 16#15#, 16#BA#, 16#43#, 16#FE#, 16#B5#, 16#B6#),
Plain_Text => (16#42#, 16#FD#, 16#44#, 16#30#, 16#59#, 16#57#, 16#7F#, 16#A2#),
Cipher_Text => (16#35#, 16#38#, 16#82#, 16#B1#, 16#09#, 16#CE#, 16#8F#, 16#1A#)),
(Key => (16#01#, 16#13#, 16#B9#, 16#70#, 16#FD#, 16#34#, 16#F2#, 16#CE#),
Plain_Text => (16#05#, 16#9B#, 16#5E#, 16#08#, 16#51#, 16#CF#, 16#14#, 16#3A#),
Cipher_Text => (16#48#, 16#F4#, 16#D0#, 16#88#, 16#4C#, 16#37#, 16#99#, 16#18#)),
(Key => (16#01#, 16#70#, 16#F1#, 16#75#, 16#46#, 16#8F#, 16#B5#, 16#E6#),
Plain_Text => (16#07#, 16#56#, 16#D8#, 16#E0#, 16#77#, 16#47#, 16#61#, 16#D2#),
Cipher_Text => (16#43#, 16#21#, 16#93#, 16#B7#, 16#89#, 16#51#, 16#FC#, 16#98#)),
(Key => (16#43#, 16#29#, 16#7F#, 16#AD#, 16#38#, 16#E3#, 16#73#, 16#FE#),
Plain_Text => (16#76#, 16#25#, 16#14#, 16#B8#, 16#29#, 16#BF#, 16#48#, 16#6A#),
Cipher_Text => (16#13#, 16#F0#, 16#41#, 16#54#, 16#D6#, 16#9D#, 16#1A#, 16#E5#)),
(Key => (16#07#, 16#A7#, 16#13#, 16#70#, 16#45#, 16#DA#, 16#2A#, 16#16#),
Plain_Text => (16#3B#, 16#DD#, 16#11#, 16#90#, 16#49#, 16#37#, 16#28#, 16#02#),
Cipher_Text => (16#2E#, 16#ED#, 16#DA#, 16#93#, 16#FF#, 16#D3#, 16#9C#, 16#79#)),
(Key => (16#04#, 16#68#, 16#91#, 16#04#, 16#C2#, 16#FD#, 16#3B#, 16#2F#),
Plain_Text => (16#26#, 16#95#, 16#5F#, 16#68#, 16#35#, 16#AF#, 16#60#, 16#9A#),
Cipher_Text => (16#D8#, 16#87#, 16#E0#, 16#39#, 16#3C#, 16#2D#, 16#A6#, 16#E3#)),
(Key => (16#37#, 16#D0#, 16#6B#, 16#B5#, 16#16#, 16#CB#, 16#75#, 16#46#),
Plain_Text => (16#16#, 16#4D#, 16#5E#, 16#40#, 16#4F#, 16#27#, 16#52#, 16#32#),
Cipher_Text => (16#5F#, 16#99#, 16#D0#, 16#4F#, 16#5B#, 16#16#, 16#39#, 16#69#)),
(Key => (16#1F#, 16#08#, 16#26#, 16#0D#, 16#1A#, 16#C2#, 16#46#, 16#5E#),
Plain_Text => (16#6B#, 16#05#, 16#6E#, 16#18#, 16#75#, 16#9F#, 16#5C#, 16#CA#),
Cipher_Text => (16#4A#, 16#05#, 16#7A#, 16#3B#, 16#24#, 16#D3#, 16#97#, 16#7B#)),
(Key => (16#58#, 16#40#, 16#23#, 16#64#, 16#1A#, 16#BA#, 16#61#, 16#76#),
Plain_Text => (16#00#, 16#4B#, 16#D6#, 16#EF#, 16#09#, 16#17#, 16#60#, 16#62#),
Cipher_Text => (16#45#, 16#20#, 16#31#, 16#C1#, 16#E4#, 16#FA#, 16#DA#, 16#8E#)),
(Key => (16#02#, 16#58#, 16#16#, 16#16#, 16#46#, 16#29#, 16#B0#, 16#07#),
Plain_Text => (16#48#, 16#0D#, 16#39#, 16#00#, 16#6E#, 16#E7#, 16#62#, 16#F2#),
Cipher_Text => (16#75#, 16#55#, 16#AE#, 16#39#, 16#F5#, 16#9B#, 16#87#, 16#BD#)),
(Key => (16#49#, 16#79#, 16#3E#, 16#BC#, 16#79#, 16#B3#, 16#25#, 16#8F#),
Plain_Text => (16#43#, 16#75#, 16#40#, 16#C8#, 16#69#, 16#8F#, 16#3C#, 16#FA#),
Cipher_Text => (16#53#, 16#C5#, 16#5F#, 16#9C#, 16#B4#, 16#9F#, 16#C0#, 16#19#)),
(Key => (16#4F#, 16#B0#, 16#5E#, 16#15#, 16#15#, 16#AB#, 16#73#, 16#A7#),
Plain_Text => (16#07#, 16#2D#, 16#43#, 16#A0#, 16#77#, 16#07#, 16#52#, 16#92#),
Cipher_Text => (16#7A#, 16#8E#, 16#7B#, 16#FA#, 16#93#, 16#7E#, 16#89#, 16#A3#)),
(Key => (16#49#, 16#E9#, 16#5D#, 16#6D#, 16#4C#, 16#A2#, 16#29#, 16#BF#),
Plain_Text => (16#02#, 16#FE#, 16#55#, 16#77#, 16#81#, 16#17#, 16#F1#, 16#2A#),
Cipher_Text => (16#CF#, 16#9C#, 16#5D#, 16#7A#, 16#49#, 16#86#, 16#AD#, 16#B5#)),
(Key => (16#01#, 16#83#, 16#10#, 16#DC#, 16#40#, 16#9B#, 16#26#, 16#D6#),
Plain_Text => (16#1D#, 16#9D#, 16#5C#, 16#50#, 16#18#, 16#F7#, 16#28#, 16#C2#),
Cipher_Text => (16#D1#, 16#AB#, 16#B2#, 16#90#, 16#65#, 16#8B#, 16#C7#, 16#78#)),
(Key => (16#1C#, 16#58#, 16#7F#, 16#1C#, 16#13#, 16#92#, 16#4F#, 16#EF#),
Plain_Text => (16#30#, 16#55#, 16#32#, 16#28#, 16#6D#, 16#6F#, 16#29#, 16#5A#),
Cipher_Text => (16#55#, 16#CB#, 16#37#, 16#74#, 16#D1#, 16#3E#, 16#F2#, 16#01#)),
(Key => (16#01#, 16#01#, 16#01#, 16#01#, 16#01#, 16#01#, 16#01#, 16#01#),
Plain_Text => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Cipher_Text => (16#FA#, 16#34#, 16#EC#, 16#48#, 16#47#, 16#B2#, 16#68#, 16#B2#)),
(Key => (16#1F#, 16#1F#, 16#1F#, 16#1F#, 16#0E#, 16#0E#, 16#0E#, 16#0E#),
Plain_Text => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Cipher_Text => (16#A7#, 16#90#, 16#79#, 16#51#, 16#08#, 16#EA#, 16#3C#, 16#AE#)),
(Key => (16#E0#, 16#FE#, 16#E0#, 16#FE#, 16#F1#, 16#FE#, 16#F1#, 16#FE#),
Plain_Text => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Cipher_Text => (16#C3#, 16#9E#, 16#07#, 16#2D#, 16#9F#, 16#AC#, 16#63#, 16#1D#)),
(Key => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Plain_Text => (16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#),
Cipher_Text => (16#01#, 16#49#, 16#33#, 16#E0#, 16#CD#, 16#AF#, 16#F6#, 16#E4#)),
(Key => (16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#),
Plain_Text => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Cipher_Text => (16#F2#, 16#1E#, 16#9A#, 16#77#, 16#B7#, 16#1C#, 16#49#, 16#BC#)),
(Key => (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#AB#, 16#CD#, 16#EF#),
Plain_Text => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#),
Cipher_Text => (16#24#, 16#59#, 16#46#, 16#88#, 16#57#, 16#54#, 16#36#, 16#9A#)),
(Key => (16#FE#, 16#DC#, 16#BA#, 16#98#, 16#76#, 16#54#, 16#32#, 16#10#),
Plain_Text => (16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#FF#),
Cipher_Text => (16#6B#, 16#5C#, 16#5A#, 16#9C#, 16#5D#, 16#9E#, 16#0A#, 16#5A#)) );
Workspace : ACO.Octet_Array(0 .. 7);
begin -- Test_Blowfish
for I in Test_Cases'Range loop
-- Using two separate objects.
declare
E : ACO.Crypto.Block_Cipher.Blowfish.Blowfish_Cipher;
D : ACO.Crypto.Block_Cipher.Blowfish.Blowfish_Cipher;
begin
ACO.Crypto.Block_Cipher.Blowfish.Make(E, Test_Cases(I).Key);
ACO.Crypto.Block_Cipher.Blowfish.Make(D, Test_Cases(I).Key);
Workspace := Test_Cases(I).Plain_Text;
E.Encrypt(Workspace);
Assert(Workspace = Test_Cases(I).Cipher_Text, "Encryption failed");
D.Decrypt(Workspace);
Assert(Workspace = Test_Cases(I).Plain_Text, "Decryption failed");
Round_Trip(E, D);
end;
-- Using the same object for both encryption and decryption.
declare
Cipher : ACO.Crypto.Block_Cipher.Blowfish.Blowfish_Cipher;
begin
ACO.Crypto.Block_Cipher.Blowfish.Make(Cipher, Test_Cases(I).Key);
Workspace := Test_Cases(I).Plain_Text;
Cipher.Encrypt(Workspace);
Assert(Workspace = Test_Cases(I).Cipher_Text, "Encryption failed");
Cipher.Decrypt(Workspace);
Assert(Workspace = Test_Cases(I).Plain_Text, "Decryption failed");
Round_Trip(Cipher, Cipher);
end;
end loop;
end Test_Blowfish;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Line_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Line_Element_Node is
begin
return Self : Draw_Line_Element_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Draw_Line_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Draw_Line
(ODF.DOM.Draw_Line_Elements.ODF_Draw_Line_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Line_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Line_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Draw_Line_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Draw_Line
(ODF.DOM.Draw_Line_Elements.ODF_Draw_Line_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Draw_Line_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Draw_Line
(Visitor,
ODF.DOM.Draw_Line_Elements.ODF_Draw_Line_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Line_Element,
Draw_Line_Element_Node'Tag);
end Matreshka.ODF_Draw.Line_Elements;
|
reznikmm/gela | Ada | 1,299 | ads | -- This package provides Parser and Parser_Input interfaces and methods.
with Gela.Lexical_Types;
with Gela.Element_Factories;
with Gela.Elements.Compilations;
package Gela.Parsers is
pragma Preelaborate;
type Parser_Input is limited interface;
-- Source of syntax analysis
type Parser_Input_Access is access all Parser_Input'Class;
for Parser_Input_Access'Storage_Size use 0;
not overriding procedure Next_Token
(Self : in out Parser_Input;
Token : out Gela.Lexical_Types.Token_Kind;
Index : out Gela.Lexical_Types.Token_Index) is abstract;
-- Provide next token tosyntax analysis
type Parser is limited interface;
-- Type to run syntax analysis
type Parser_Access is access all Parser'Class;
for Parser_Access'Storage_Size use 0;
not overriding procedure Parse
(Self : in out Parser; -- TODO: Drop 'in out'
Input : not null access Parser_Input'Class;
Factory : not null Gela.Element_Factories.Element_Factory_Access;
Root : out Gela.Elements.Compilations.Compilation_Access;
Last_Token : out Gela.Lexical_Types.Token_Index) is abstract;
-- Run syntax analysis of given Input. Use Factory to create AST elements.
-- Return Root of AST ans last token index
end Gela.Parsers;
|
redparavoz/ada-wiki | Ada | 5,532 | adb | -----------------------------------------------------------------------
-- wiki-helpers -- Helper operations for wiki parsers and renderer
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Wide_Wide_Characters.Handling;
package body Wiki.Helpers is
-- ------------------------------
-- Returns True if the character is a space or tab.
-- ------------------------------
function Is_Space (C : in Wiki.Strings.WChar) return Boolean is
begin
return Ada.Wide_Wide_Characters.Handling.Is_Space (C) or C = HT;
end Is_Space;
-- ------------------------------
-- Returns True if the character is a space, tab or a newline.
-- ------------------------------
function Is_Space_Or_Newline (C : in Wiki.Strings.WChar) return Boolean is
begin
return Is_Space (C) or Ada.Wide_Wide_Characters.Handling.Is_Line_Terminator (C);
end Is_Space_Or_Newline;
-- ------------------------------
-- Returns True if the character is a line terminator.
-- ------------------------------
function Is_Newline (C : in Wiki.Strings.WChar) return Boolean is
begin
return Ada.Wide_Wide_Characters.Handling.Is_Line_Terminator (C);
end Is_Newline;
-- ------------------------------
-- Returns True if the text is a valid URL
-- ------------------------------
function Is_Url (Text : in Wiki.Strings.WString) return Boolean is
begin
if Text'Length <= 9 then
return False;
else
return Text (Text'First .. Text'First + 6) = "http://"
or Text (Text'First .. Text'First + 7) = "https://";
end if;
end Is_Url;
-- ------------------------------
-- Returns True if the extension part correspond to an image.
-- Recognized extension are: .png, .gif, .jpg, .jpeg.
-- The extension case is ignored.
-- ------------------------------
function Is_Image_Extension (Ext : in Wiki.Strings.WString) return Boolean is
S : constant Wiki.Strings.WString := Ada.Wide_Wide_Characters.Handling.To_Lower (Ext);
begin
return S = ".png" or S = ".jpg" or S = ".gif" or S = ".jpeg";
end Is_Image_Extension;
-- ------------------------------
-- Given the current tag on the top of the stack and the new tag that will be pushed,
-- decide whether the current tag must be closed or not.
-- Returns True if the current tag must be closed.
-- ------------------------------
function Need_Close (Tag : in Html_Tag;
Current_Tag : in Html_Tag) return Boolean is
begin
if No_End_Tag (Current_Tag) then
return True;
elsif Current_Tag = Tag and Tag_Omission (Current_Tag) then
return True;
else
case Current_Tag is
when DT_TAG | DD_TAG =>
return Tag = DD_TAG or Tag = DL_TAG or Tag = DT_TAG;
when TD_TAG =>
return Tag = TD_TAG or Tag = TR_TAG or Tag = TH_TAG;
when TR_TAG =>
return False;
when others =>
return False;
end case;
end if;
end Need_Close;
-- ------------------------------
-- Get the dimension represented by the string. The string has one of the following
-- formats:
-- original -> Width, Height := Natural'Last
-- default -> Width := 800, Height := 0
-- upright -> Width := 800, Height := 0
-- <width>px -> Width := <width>, Height := 0
-- x<height>px -> Width := 0, Height := <height>
-- <width>x<height>px -> Width := <width>, Height := <height>
-- ------------------------------
procedure Get_Sizes (Dimension : in Wiki.Strings.WString;
Width : out Natural;
Height : out Natural) is
Pos : Natural;
Last : Natural;
begin
if Dimension = "original" then
Width := Natural'Last;
Height := Natural'Last;
elsif Dimension = "default" or Dimension = "upright" then
Width := 800;
Height := 0;
else
Pos := Wiki.Strings.Index (Dimension, "x");
Last := Wiki.Strings.Index (Dimension, "px");
if Pos > Dimension'First and Last + 1 /= Pos then
Width := Natural'Wide_Wide_Value (Dimension (Dimension'First .. Pos - 1));
elsif Last > 0 then
Width := Natural'Wide_Wide_Value (Dimension (Dimension'First .. Last - 1));
else
Width := 0;
end if;
if Pos < Dimension'Last then
Height := Natural'Wide_Wide_Value (Dimension (Pos + 1 .. Last - 1));
else
Height := 0;
end if;
end if;
exception
when Constraint_Error =>
Width := 0;
Height := 0;
end Get_Sizes;
end Wiki.Helpers;
|
pdaxrom/Kino2 | Ada | 3,542 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Modular_IO --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
-- $Revision: 1.10 $
-- Binding Version 01.00
------------------------------------------------------------------------------
generic
type Num is mod <>;
package Terminal_Interface.Curses.Text_IO.Modular_IO is
Default_Width : Field := Num'Width;
Default_Base : Number_Base := 10;
procedure Put
(Win : in Window;
Item : in Num;
Width : in Field := Default_Width;
Base : in Number_Base := Default_Base);
procedure Put
(Item : in Num;
Width : in Field := Default_Width;
Base : in Number_Base := Default_Base);
private
pragma Inline (Put);
end Terminal_Interface.Curses.Text_IO.Modular_IO;
|
Fabien-Chouteau/samd51-hal | Ada | 10,458 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of 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. --
-- --
------------------------------------------------------------------------------
package body SAM.SERCOM.I2C is
---------------
-- Configure --
---------------
procedure Configure (This : in out I2C_Device;
Baud : UInt8)
is
CTRLB : SERCOM_CTRLB_SERCOM_I2CM_Register;
begin
This.Reset;
This.Periph.SERCOM_I2CM.CTRLA.MODE := 5;
This.Wait_Sync;
This.Periph.SERCOM_I2CM.BAUD := (BAUD => Baud,
BAUDLOW => 0,
HSBAUD => Baud,
HSBAUDLOW => 0);
CTRLB := This.Periph.SERCOM_I2CM.CTRLB;
CTRLB.SMEN := False; -- Smart mode
This.Periph.SERCOM_I2CM.CTRLB := CTRLB;
This.Wait_Sync;
This.Periph.SERCOM_I2CM.STATUS.BUSSTATE := 1; -- Set to IDLE
This.Wait_Sync;
This.Config_Done := True;
end Configure;
------------------
-- Data_Address --
------------------
function Data_Address (This : I2C_Device) return System.Address
is (This.Periph.SERCOM_I2CM.Data'Address);
---------------------
-- Master_Transmit --
---------------------
overriding
procedure Master_Transmit
(This : in out I2C_Device;
Addr : I2C_Address;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
-- Address is shifted to the left to use bit 0 as read/write mode
Status := This.Send_Addr (UInt11 (Addr) * 2);
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
for Elt of Data loop
This.Periph.SERCOM_I2CM.DATA := UInt32 (Elt);
This.Wait_Bus;
Status := This.Bus_Status;
exit when Status /= Ok;
end loop;
if This.Do_Stop_Sequence then
This.Cmd_Stop;
end if;
end Master_Transmit;
--------------------
-- Master_Receive --
--------------------
overriding
procedure Master_Receive
(This : in out I2C_Device;
Addr : I2C_Address;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
if Data'Length = 0 then
Status := Ok;
return;
end if;
-- Address is shifted to the left to use bit 0 as read/write mode
Status := This.Send_Addr ((UInt11 (Addr) * 2) or 1);
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
-- Get the first byte
Data (Data'First) := UInt8 (This.Periph.SERCOM_I2CM.DATA);
for Index in Data'First + 1 .. Data'Last loop
This.Cmd_Read;
This.Wait_Bus;
Status := This.Bus_Status;
exit when Status /= Ok;
Data (Index) := UInt8 (This.Periph.SERCOM_I2CM.DATA);
end loop;
This.Cmd_Nack;
This.Cmd_Stop;
end Master_Receive;
---------------
-- Mem_Write --
---------------
overriding
procedure Mem_Write
(This : in out I2C_Device;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
This.Do_Stop_Sequence := False;
case Mem_Addr_Size is
when Memory_Size_8b =>
This.Master_Transmit (Addr => Addr,
Data => (0 => UInt8 (Mem_Addr)),
Status => Status,
Timeout => Timeout);
when Memory_Size_16b =>
This.Master_Transmit (Addr => Addr,
Data => (UInt8 (Shift_Right (Mem_Addr, 8)),
UInt8 (Mem_Addr and 16#FF#)),
Status => Status,
Timeout => Timeout);
end case;
This.Do_Stop_Sequence := True;
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
This.Master_Transmit (Addr => Addr,
Data => Data,
Status => Status,
Timeout => Timeout);
end Mem_Write;
--------------
-- Mem_Read --
--------------
overriding
procedure Mem_Read
(This : in out I2C_Device;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
This.Do_Stop_Sequence := False;
case Mem_Addr_Size is
when Memory_Size_8b =>
This.Master_Transmit (Addr => Addr,
Data => (0 => UInt8 (Mem_Addr)),
Status => Status,
Timeout => Timeout);
when Memory_Size_16b =>
This.Master_Transmit (Addr => Addr,
Data => (UInt8 (Shift_Right (Mem_Addr, 8)),
UInt8 (Mem_Addr and 16#FF#)),
Status => Status,
Timeout => Timeout);
end case;
This.Do_Stop_Sequence := True;
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
This.Master_Receive (Addr => Addr,
Data => Data,
Status => Status,
Timeout => Timeout);
end Mem_Read;
---------------
-- Wait_Sync --
---------------
procedure Wait_Sync (This : in out I2C_Device) is
begin
while This.Periph.SERCOM_I2CM.SYNCBUSY.SYSOP loop
null;
end loop;
end Wait_Sync;
--------------
-- Wait_Bus --
--------------
procedure Wait_Bus (This : in out I2C_Device) is
INTFLAG : SERCOM_INTFLAG_SERCOM_I2CM_Register;
begin
loop
INTFLAG := This.Periph.SERCOM_I2CM.INTFLAG;
exit when INTFLAG.MB or else INTFLAG.SB or else INTFLAG.ERROR;
end loop;
end Wait_Bus;
---------------
-- Send_Addr --
---------------
function Send_Addr (This : in out I2C_Device;
Addr : UInt11)
return I2C_Status
is
Reg : SERCOM_ADDR_SERCOM_I2CM_Register;
begin
Reg := This.Periph.SERCOM_I2CM.ADDR;
Reg.ADDR := Addr;
Reg.TENBITEN := False;
Reg.HS := False; -- High-speed transfer
Reg.LENEN := False; -- Automatic transfer length
This.Periph.SERCOM_I2CM.ADDR := Reg;
This.Wait_Sync;
This.Wait_Bus;
return This.Bus_Status;
end Send_Addr;
--------------
-- Cmd_Stop --
--------------
procedure Cmd_Stop (This : in out I2C_Device) is
begin
This.Periph.SERCOM_I2CM.CTRLB.CMD := 3;
This.Wait_Sync;
end Cmd_Stop;
--------------
-- Cmd_Nack --
--------------
procedure Cmd_Nack (This : in out I2C_Device) is
begin
This.Periph.SERCOM_I2CM.CTRLB.ACKACT := True;
This.Wait_Sync;
end Cmd_Nack;
--------------
-- Cmd_Read --
--------------
procedure Cmd_Read (This : in out I2C_Device) is
CTRLB : SERCOM_CTRLB_SERCOM_I2CM_Register;
begin
CTRLB := This.Periph.SERCOM_I2CM.CTRLB;
CTRLB.CMD := 2; -- Read command
CTRLB.ACKACT := False; -- False means send ack
This.Periph.SERCOM_I2CM.CTRLB := CTRLB;
This.Wait_Sync;
end Cmd_Read;
----------------
-- Bus_Status --
----------------
function Bus_Status (This : I2C_Device) return I2C_Status is
begin
if This.Periph.SERCOM_I2CM.STATUS.RXNACK
or else
This.Periph.SERCOM_I2CM.STATUS.BUSERR
then
return HAL.I2C.Err_Error; -- We should have an addr nack status value
elsif This.Periph.SERCOM_I2CM.STATUS.ARBLOST then
return HAL.I2C.Busy;
else
return HAL.I2C.Ok;
end if;
end Bus_Status;
end SAM.SERCOM.I2C;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 2,845 | ads | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
package HAL.Time is
type Delays is limited interface;
type Any_Delays is access all Delays'Class;
procedure Delay_Microseconds (This : in out Delays;
Us : Integer) is abstract;
procedure Delay_Milliseconds (This : in out Delays;
Ms : Integer) is abstract;
procedure Delay_Seconds (This : in out Delays;
S : Integer) is abstract;
end HAL.Time;
|
reznikmm/matreshka | Ada | 3,734 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Sort_Algorithm_Attributes is
pragma Preelaborate;
type ODF_Text_Sort_Algorithm_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Sort_Algorithm_Attribute_Access is
access all ODF_Text_Sort_Algorithm_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Sort_Algorithm_Attributes;
|
michael-hardeman/contacts_app | Ada | 6,491 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
package body AdaBase.Logger.Facility is
------------------
-- error_mode --
------------------
function error_mode (facility : LogFacility) return Error_Modes
is
begin
return facility.prop_error_mode;
end error_mode;
----------------------
-- set_error_mode --
----------------------
procedure set_error_mode (facility : out LogFacility; mode : Error_Modes)
is
begin
facility.prop_error_mode := mode;
end set_error_mode;
--------------------
-- set_log_file --
--------------------
procedure set_log_file (facility : LogFacility; filename : String) is
begin
facility.listener_file.all.set_filepath (filename);
end set_log_file;
---------------------
-- standard_logger --
---------------------
procedure standard_logger (facility : out LogFacility;
logger : TLogger;
action : TAction)
is
use type ALF.File_Logger_access;
use type ALS.Screen_Logger_access;
begin
case logger is
when screen =>
case action is
when detach =>
if facility.listener_screen = null then
raise ALREADY_DETACHED;
else
facility.listener_screen := null;
end if;
when attach =>
if facility.listener_screen = null then
facility.listener_screen := logger_screen'Access;
else
raise ALREADY_ATTACHED;
end if;
end case;
when file =>
case action is
when detach =>
if facility.listener_file = null then
raise ALREADY_DETACHED;
else
facility.listener_file := null;
end if;
when attach =>
if facility.listener_file = null then
facility.listener_file := logger_file'Access;
else
raise ALREADY_ATTACHED;
end if;
end case;
end case;
end standard_logger;
----------------------------
-- detach_custom_logger --
----------------------------
procedure detach_custom_logger (facility : out LogFacility)
is
use type AL.BaseClass_Logger_access;
begin
if facility.listener_custom = null then
raise ALREADY_DETACHED;
else
facility.listener_custom := null;
end if;
end detach_custom_logger;
----------------------------
-- attach_custom_logger --
----------------------------
procedure attach_custom_logger (facility : out LogFacility;
logger_access : AL.BaseClass_Logger_access)
is
use type AL.BaseClass_Logger_access;
begin
if facility.listener_custom = null then
facility.listener_custom := logger_access;
else
raise ALREADY_ATTACHED;
end if;
end attach_custom_logger;
-------------------
-- log_nominal --
-------------------
procedure log_nominal (facility : LogFacility;
driver : Driver_Type;
category : Log_Category;
message : CT.Text)
is
use type AL.Screen.Screen_Logger_access;
use type AL.File.File_Logger_access;
use type AL.BaseClass_Logger_access;
begin
if facility.listener_screen /= null then
facility.listener_screen.all.set_information
(driver => driver,
category => category,
message => message);
facility.listener_screen.all.reaction;
end if;
if facility.listener_file /= null then
facility.listener_file.all.set_information
(driver => driver,
category => category,
message => message);
facility.listener_file.all.reaction;
end if;
if facility.listener_custom /= null then
facility.listener_custom.all.set_information
(driver => driver,
category => category,
message => message);
facility.listener_custom.all.reaction;
end if;
end log_nominal;
-------------------
-- log_problem --
-------------------
procedure log_problem
(facility : LogFacility;
driver : Driver_Type;
category : Log_Category;
message : CT.Text;
error_msg : CT.Text := CT.blank;
error_code : Driver_Codes := 0;
sqlstate : SQL_State := stateless;
break : Boolean := False)
is
use type Error_Modes;
use type AL.Screen.Screen_Logger_access;
use type AL.File.File_Logger_access;
use type AL.BaseClass_Logger_access;
QND : constant String := CT.USS (message);
begin
if not break and then facility.prop_error_mode = silent
then
return;
end if;
if facility.listener_screen /= null then
facility.listener_screen.all.set_information
(driver => driver,
category => category,
message => message,
error_msg => error_msg,
error_code => error_code,
sqlstate => sqlstate);
facility.listener_screen.all.reaction;
end if;
if facility.listener_file /= null then
facility.listener_file.all.set_information
(driver => driver,
category => category,
message => message,
error_msg => error_msg,
error_code => error_code,
sqlstate => sqlstate);
facility.listener_file.all.reaction;
end if;
if facility.listener_custom /= null then
facility.listener_custom.all.set_information
(driver => driver,
category => category,
message => message,
error_msg => error_msg,
error_code => error_code,
sqlstate => sqlstate);
facility.listener_custom.all.reaction;
end if;
if break or else facility.prop_error_mode = raise_exception
then
raise ERRMODE_EXCEPTION with QND;
end if;
end log_problem;
end AdaBase.Logger.Facility;
|
pok-kernel/pok | Ada | 379 | ads | #ifndef __OCARINA_GENERATED_MARSHALLERS_H_
#define __OCARINA_GENERATED_MARSHALLERS_H_
/*****************************************************/
/* This file was automatically generated by Ocarina */
/* Do NOT hand-modify this file, as your */
/* changes will be lost when you re-run Ocarina */
/*****************************************************/
#endif
|
zhmu/ananas | Ada | 7,667 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (LynxOS-178 X86 Version) --
-- --
-- Copyright (C) 2009-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package System is
pragma Pure;
-- Note that we take advantage of the implementation permission to make
-- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-- 2005, this is Pure in any case (AI-362).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := Standard'Max_Integer_Size - 1;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 0.01;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := 32;
Memory_Size : constant := 2 ** 32;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := Low_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
-- 17 is the system determined default priority for user applications
-- running on LynxOS.
-- The standard (Rm 13.7) requires that Default_Priority has the value:
-- (Priority'First + Priority'Last) / 2
-- However, the default priority given by the OS is not the same thing as
-- the Ada value Default_Priority (previous examples include VxWorks).
-- Therefore, we follow a model based on the full range of LynxOS-178
-- priorities.
Max_Priority : constant Positive := 252;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 252;
subtype Interrupt_Priority is Any_Priority range 253 .. 255;
Default_Priority : constant Priority := 126;
-- Note that the priority of the environment task is set externally by the
-- OS
private
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
Signed_Zeros : constant Boolean := True;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := True;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := False;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := False;
end System;
|
annexi-strayline/AURA | Ada | 3,827 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
separate (Registrar.Executive.Unit_Entry.Execute)
package body Source_Pack is
--------------------
-- Discard_Source --
--------------------
procedure Discard_Source is
begin
Registrar.Source_Files.Allocation.Discard
(File => Source,
Checkout => Stream);
end Discard_Source;
end Source_Pack;
|
PThierry/ewok-kernel | Ada | 26 | ads | ../stm32f439/soc-usart.ads |
MinimSecure/unum-sdk | Ada | 821 | adb | -- Copyright 2014-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo_NA07_019 is
begin
Increment (Something); -- START
end Foo_NA07_019;
|
docandrew/troodon | Ada | 3,909 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package bits_floatn_common_h is
-- Macros to control TS 18661-3 glibc features where the same
-- definitions are appropriate for all platforms.
-- Copyright (C) 2017-2021 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C Library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- The GNU C Library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with the GNU C Library; if not, see
-- <https://www.gnu.org/licenses/>.
-- This header should be included at the bottom of each bits/floatn.h.
-- It defines the following macros for each _FloatN and _FloatNx type,
-- where the same definitions, or definitions based only on the macros
-- in bits/floatn.h, are appropriate for all glibc configurations.
-- Defined to 1 if the current compiler invocation provides a
-- floating-point type with the right format for this type, and this
-- glibc includes corresponding *fN or *fNx interfaces for it.
-- Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the
-- type is the first with its format in the sequence of (the default
-- choices for) float, double, long double, _Float16, _Float32,
-- _Float64, _Float128, _Float32x, _Float64x, _Float128x for this
-- glibc; that is, if functions present once per floating-point format
-- rather than once per type are present for this type.
-- All configurations supported by glibc have _Float32 the same format
-- as float, _Float64 and _Float32x the same format as double, the
-- _Float64x the same format as either long double or _Float128. No
-- configurations support _Float128x or, as of GCC 7, have compiler
-- support for a type meeting the requirements for _Float128x.
-- Defined to 1 if the corresponding _FloatN type is not binary compatible
-- with the corresponding ISO C type in the current compilation unit as
-- opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
-- in glibc.
-- Defined to 1 if any _FloatN or _FloatNx types that are not
-- ABI-distinct are however distinct types at the C language level (so
-- for the purposes of __builtin_types_compatible_p and _Generic).
-- Defined to concatenate the literal suffix to be used with _FloatN
-- or _FloatNx types, if __HAVE_<type> is 1. The corresponding
-- literal suffixes exist since GCC 7, for C only.
-- No corresponding suffix available for this type.
-- Defined to a complex type if __HAVE_<type> is 1.
-- The remaining of this file provides support for older compilers.
subtype u_Float32 is float; -- /usr/include/bits/floatn-common.h:214
-- If double, long double and _Float64 all have the same set of
-- values, TS 18661-3 requires the usual arithmetic conversions on
-- long double and _Float64 to produce _Float64. For this to be the
-- case when building with a compiler without a distinct _Float64
-- type, _Float64 must be a typedef for long double, not for
-- double.
subtype u_Float64 is double; -- /usr/include/bits/floatn-common.h:251
subtype u_Float32x is double; -- /usr/include/bits/floatn-common.h:268
subtype u_Float64x is long_double; -- /usr/include/bits/floatn-common.h:285
end bits_floatn_common_h;
|
PThierry/ewok-kernel | Ada | 25 | adb | ../stm32f439/soc-exti.adb |
caqg/linux-home | Ada | 32,533 | adb | ------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2000-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Maps.Constants;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode;
with Ada.Characters.Wide_Wide_Latin_1;
with GNAT.Expect; use GNAT.Expect;
with GNAT.Regpat; use GNAT.Regpat;
with GNATCOLL.Symbols; use GNATCOLL.Symbols;
with GNATCOLL.Utils; use GNATCOLL.Utils;
with String_Utils; use String_Utils;
with UTF8_Utils; use UTF8_Utils;
package body Language is
Default_Word_Character_Set : constant Character_Set :=
Constants.Letter_Set or Constants.Decimal_Digit_Set or To_Set ("_");
-- Default character set for keywords and indentifiers
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive;
Line : out Natural;
Column : out Natural);
-- Internal version of Looking_At, which also returns the Line and Column,
-- considering that Buffer (First) is at line 1 column 1.
-- Column is a byte index, not a character index.
---------------------------
-- Can_Tooltip_On_Entity --
---------------------------
function Can_Tooltip_On_Entity
(Lang : access Language_Root;
Entity : String) return Boolean
is
pragma Unreferenced (Lang, Entity);
begin
return True;
end Can_Tooltip_On_Entity;
---------------------
-- Scope_Separator --
---------------------
function Scope_Separator
(Lang : access Language_Root) return String
is
pragma Unreferenced (Lang);
begin
return ".";
end Scope_Separator;
----------------------
-- Explorer_Regexps --
----------------------
function Explorer_Regexps
(Lang : access Language_Root) return Explorer_Categories
is
pragma Unreferenced (Lang);
E : Explorer_Categories (1 .. 0);
begin
return E;
end Explorer_Regexps;
----------
-- Free --
----------
procedure Free (Context : in out Language_Context_Access) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Language_Context, Language_Context_Access);
Var : GNAT.Expect.Pattern_Matcher_Access :=
GNAT.Expect.Pattern_Matcher_Access
(Context.Syntax.New_Line_Comment_Start_Regexp);
begin
if Context /= null then
GNAT.Strings.Free (Context.Syntax.Comment_Start);
GNAT.Strings.Free (Context.Syntax.Comment_End);
Basic_Types.Unchecked_Free (Var);
GNAT.Strings.Free (Context.Syntax.New_Line_Comment_Start);
Unchecked_Free (Context);
end if;
end Free;
----------
-- Free --
----------
procedure Free (Lang : in out Language_Access) is
procedure Internal is new Ada.Unchecked_Deallocation
(Language_Root'Class, Language_Access);
begin
if Lang /= null then
Free (Lang.all);
Internal (Lang);
end if;
end Free;
procedure Free (List : in out Construct_List) is
Info, Tmp : Construct_Access;
procedure Free is new
Ada.Unchecked_Deallocation (Construct_Information, Construct_Access);
begin
Info := List.First;
loop
exit when Info = null;
GNAT.Strings.Free (Info.Profile);
Tmp := Info;
Info := Info.Next;
Free (Tmp);
end loop;
List.First := null;
List.Current := null;
List.Last := null;
end Free;
----------
-- Free --
----------
procedure Free (Category : in out Explorer_Category) is
begin
Basic_Types.Unchecked_Free (Category.Regexp);
end Free;
----------
-- Free --
----------
procedure Free (Categories : in out Explorer_Categories) is
begin
for C in Categories'Range loop
Free (Categories (C));
end loop;
end Free;
--------------------
-- Is_System_File --
--------------------
function Is_System_File
(Lang : access Language_Root;
File_Name : String) return Boolean
is
pragma Unreferenced (Lang, File_Name);
begin
return False;
end Is_System_File;
----------------
-- Looking_At --
----------------
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive)
is
Line, Column : Natural;
begin
Looking_At (Lang, Buffer, First, Entity, Next_Char, Line, Column);
end Looking_At;
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive;
Line : out Natural;
Column : out Natural)
is
Context : constant Language_Context_Access :=
Get_Language_Context (Language_Access (Lang));
Keys : constant GNAT.Expect.Pattern_Matcher_Access :=
Keywords (Language_Access (Lang));
Buffer_Length : constant Natural := Buffer'Last - First + 1;
Matched : Match_Array (0 .. 1);
C : Wide_Wide_Character;
Tmp : Natural;
Found : Boolean;
use GNAT.Strings;
begin
Line := 1;
Column := 1;
if Buffer (First) = ASCII.LF then
Next_Char := First + 1;
Line := Line + 1;
Column := 1;
Entity := Normal_Text;
return;
end if;
-- Do we have a comment ?
if Context.Syntax.Comment_Start /= null
and then Starts_With
(Buffer (First .. Buffer'Last), Context.Syntax.Comment_Start.all)
then
Entity := Comment_Text;
Next_Char := First + Context.Syntax.Comment_Start'Length;
Column := Column + Context.Syntax.Comment_Start'Length;
while Starts_With
(Buffer (Next_Char .. Buffer'Last), Context.Syntax.Comment_End.all)
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
if Next_Char <= Buffer'Last
and then Buffer (Next_Char) = ASCII.LF
then
Column := 1;
Line := Line + 1;
end if;
end loop;
Next_Char := Next_Char + Context.Syntax.Comment_End'Length;
Column := Column + Context.Syntax.Comment_End'Length;
return;
end if;
-- Do we have a comment that ends on newline ?
if Context.Syntax.New_Line_Comment_Start /= null then
Found := Starts_With
(Buffer (First .. Buffer'Last),
Context.Syntax.New_Line_Comment_Start.all);
elsif Context.Syntax.New_Line_Comment_Start_Regexp /= null then
Found := Match (Context.Syntax.New_Line_Comment_Start_Regexp.all,
Buffer (First .. Buffer'Last));
else
Found := False;
end if;
if Found then
Entity := Comment_Text;
Next_Char := UTF8_Next_Char (Buffer, First);
while Next_Char <= Buffer'Last
and then Buffer (Next_Char) /= ASCII.LF
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
return;
end if;
-- Do we have a string ?
-- Note that we consider that strings never span over multiple lines...
if Buffer (First) = Context.String_Delimiter then
Entity := String_Text;
Next_Char := First;
if Next_Char < Buffer'Last
and then Buffer (Next_Char + 1) /= ASCII.LF
then
loop
Next_Char := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + 1;
exit when Next_Char >= Buffer'Last
or else Buffer (Next_Char + 1) = ASCII.LF
or else
(Buffer (Next_Char) = Context.String_Delimiter
and then
(Context.Quote_Character = ASCII.NUL
or else
Buffer (Next_Char - 1) /= Context.Quote_Character));
end loop;
end if;
if Next_Char <= Buffer'Last then
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end if;
return;
end if;
-- A protected constant character
-- ??? The following test still does not handle cases such as
-- '\012' for instance, or multi-byte character constants.
if Buffer_Length > 4
and then Buffer (First) = Context.Constant_Character
and then Buffer (First + 1) = Context.Quote_Character
and then Buffer (First + 3) = Context.Constant_Character
then
Entity := Character_Text;
Next_Char := First + 4;
Column := Column + 4;
return;
end if;
-- A constant character
if Buffer_Length > 3
and then Buffer (First) = Context.Constant_Character
and then Buffer (First + 2) = Context.Constant_Character
then
Entity := Character_Text;
Next_Char := First + 3;
Column := Column + 3;
return;
end if;
-- Do we have a keyword ?
-- ??? It is assumed the regexp should check at the current char
-- only, not beyond for efficiency...
if Keys /= null then
Match (Keys.all, Buffer (First .. Buffer'Last), Matched);
if Matched (0) /= No_Match then
Next_Char := UTF8_Next_Char (Buffer, Matched (0).Last);
Column := Column + Matched (0).Last - Matched (0).First + 1;
Entity := Keyword_Text;
return;
end if;
end if;
-- Another special character, not part of a word: just skip it, before
-- doing some regexp matching
-- It is better to return a pointer to the newline, so that the icons
-- on the side might be displayed properly.
if not Is_Word_Char
(Language_Access (Lang),
UTF8_Get_Char (Buffer (First .. Buffer'Last)))
then
Entity := Normal_Text;
Next_Char := UTF8_Next_Char (Buffer, First);
Column := Column + (Next_Char - First);
while Next_Char <= Buffer'Last loop
C := UTF8_Get_Char (Buffer (Next_Char .. Buffer'Last));
exit when C = Ada.Characters.Wide_Wide_Latin_1.LF
or else not Is_Space (C);
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
return;
end if;
-- Skip to the next meaningful character. we know we are
-- starting with a letter
Next_Char := UTF8_Next_Char (Buffer, First);
Column := Column + (Next_Char - First);
Entity := Normal_Text;
if Buffer (Next_Char) = ASCII.LF then
return;
end if;
-- Skip the current word. We only take into account Is_Entity_Letter,
-- not the full set of chars supported by the language for its keywords
-- because of cases like "<foo>bar</foo>" in XML, which would otherwise
-- consider this as a single word when they are in fact several.
while Next_Char <= Buffer'Last
and then Is_Entity_Letter
(UTF8_Get_Char (Buffer (Next_Char .. Buffer'Last)))
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
end Looking_At;
-------------------------------------
-- To_Simple_Construct_Information --
-------------------------------------
procedure To_Simple_Construct_Information
(Construct : Construct_Information;
Simple : out Simple_Construct_Information;
Full_Copy : Boolean)
is
pragma Unreferenced (Full_Copy);
begin
Simple :=
(Category => Construct.Category,
Is_Declaration => Construct.Is_Declaration,
Is_Generic_Spec => Construct.Is_Generic_Spec,
Visibility => Construct.Visibility,
Name => Construct.Name,
Sloc_Start => Construct.Sloc_Start,
Sloc_Entity => Construct.Sloc_Entity,
Sloc_End => Construct.Sloc_End,
Attributes => Construct.Attributes,
Profile_Cache => null);
end To_Simple_Construct_Information;
------------------
-- Comment_Line --
------------------
function Comment_Line
(Lang : access Language_Root;
Line : String;
Comment : Boolean := True;
Clean : Boolean := False) return String
is
pragma Unreferenced (Lang, Comment, Clean);
begin
return Line;
end Comment_Line;
------------------
-- Comment_Block --
------------------
function Comment_Block
(Lang : access Language_Root;
Block : String;
Comment : Boolean := True;
Clean : Boolean := False) return String
is
Start_Of_Line : Natural := Block'First;
End_Of_Line : Natural;
New_Block : Unbounded_String := Null_Unbounded_String;
begin
loop
End_Of_Line := Next_Line (Block, Start_Of_Line);
if End_Of_Line /= Block'Last and then End_Of_Line /= Block'First then
End_Of_Line := End_Of_Line - 1;
end if;
Append
(New_Block,
Comment_Line
(Language_Access (Lang),
Block (Start_Of_Line .. End_Of_Line),
Comment,
Clean));
Start_Of_Line := Next_Line (Block, Start_Of_Line);
exit when Start_Of_Line = Block'Last;
end loop;
return To_String (New_Block);
end Comment_Block;
----------------------
-- Parse_Constructs --
----------------------
procedure Parse_Constructs
(Lang : access Language_Root;
File : GNATCOLL.VFS.Virtual_File;
Buffer : UTF8_String;
Result : out Construct_List)
is
pragma Unreferenced (File);
Matches : Match_Array (0 .. 10);
Categories : constant Explorer_Categories :=
Explorer_Regexps (Language_Access (Lang));
First : Natural;
Line : Natural;
Line_Pos : Natural;
Sloc_Entity : Source_Location;
Sloc_Start : Source_Location;
Sloc_End : Source_Location;
Info : Construct_Access;
Match_Index : Natural;
End_Index : Natural;
procedure Forward
(Index : Natural;
Sloc : in out Source_Location);
-- Compute Line and Column fields in Sloc and update Line and Line_Pos
-------------
-- Forward --
-------------
procedure Forward
(Index : Natural;
Sloc : in out Source_Location) is
begin
for J in Index .. Sloc.Index loop
if Buffer (J) = ASCII.LF then
Line := Line + 1;
Line_Pos := J;
end if;
end loop;
Sloc.Line := Line;
Sloc.Column := Sloc.Index - Line_Pos;
end Forward;
begin
Result := (null, null, null, 0);
-- For each category, parse the buffer
for C in Categories'Range loop
First := Buffer'First;
Line := 1;
Line_Pos := 0;
loop
Match (Categories (C).Regexp.all,
Buffer (First .. Buffer'Last),
Matches);
exit when Matches (0) = No_Match;
Match_Index := Categories (C).Position_Index;
End_Index := Categories (C).End_Index;
if Matches (Match_Index) /= No_Match then
Sloc_Start.Index := Matches (0).First;
Sloc_Entity.Index := Matches (Match_Index).First;
Sloc_End.Index := Matches (End_Index).Last;
Forward (First, Sloc_Start);
Forward (Sloc_Start.Index + 1, Sloc_Entity);
Forward (Sloc_Entity.Index + 1, Sloc_End);
Info := Result.Current;
Result.Current := new Construct_Information;
if Result.First = null then
Result.First := Result.Current;
else
Result.Current.Prev := Info;
Result.Current.Next := Info.Next;
Info.Next := Result.Current;
end if;
Result.Last := Result.Current;
Result.Current.Category := Categories (C).Category;
Result.Current.Category_Name := Categories (C).Category_Name;
Result.Size := Result.Size + 1;
if Categories (C).Make_Entry /= null then
Result.Current.Name := Lang.Symbols.Find
(Categories (C).Make_Entry (Buffer, Matches));
else
Result.Current.Name := Lang.Symbols.Find
(Buffer (Matches (Match_Index).First ..
Matches (Match_Index).Last));
end if;
-- Result.Current.Profile := ???
Result.Current.Sloc_Entity := Sloc_Entity;
Result.Current.Sloc_Start := Sloc_Start;
Result.Current.Sloc_End := Sloc_End;
Result.Current.Is_Declaration := False;
end if;
First := Matches (End_Index).Last + 1;
end loop;
end loop;
end Parse_Constructs;
--------------------
-- Parse_Entities --
--------------------
procedure Parse_Entities
(Lang : access Language_Root;
Buffer : String;
Callback : Entity_Callback)
is
use type GNAT.Strings.String_Access;
Index : Natural := Buffer'First;
Next_Char : Natural;
End_Char : Natural;
Entity : Language_Entity;
Line : Natural;
Line_Inc : Natural;
Col : Natural;
Column : Natural;
Column_Inc : Natural;
begin
Line := 1;
Column := 1;
while Index < Buffer'Last loop
Looking_At
(Lang, Buffer, Index, Entity, Next_Char, Line_Inc, Column_Inc);
if Next_Char = Buffer'Last then
End_Char := Buffer'Last;
else
End_Char := Next_Char - 1;
end if;
-- If we are still on the same line, Column_Inc is an increment
-- compared to what we have initially, otherwise it is an absolute
-- column.
if Line_Inc = 1 then
Column_Inc := Column + Column_Inc - 1;
end if;
-- Looking_At goes always one character beyond characters and
-- strings, otherwise next call to Looking_At would start on
-- a string or character delimiter. Keywords are also set one
-- character beyond.
if Column_Inc > 1
and then (Entity = String_Text
or else Entity = Character_Text
or else Entity = Keyword_Text)
then
Col := Column_Inc - 1;
else
Col := Column_Inc;
end if;
exit when Callback
(Entity,
(Line, Column, Index),
(Line + Line_Inc - 1, Col, End_Char),
Get_Language_Context
(Language_Access (Lang)).Syntax.Comment_Start /= null
and then Entity = Comment_Text and then Next_Char > Buffer'Last);
Line := Line + Line_Inc - 1;
Column := Column_Inc;
Index := Next_Char;
end loop;
end Parse_Entities;
---------------------------
-- Get_Referenced_Entity --
---------------------------
procedure Get_Referenced_Entity
(Lang : access Language_Root;
Buffer : String;
Construct : Simple_Construct_Information;
Sloc_Start : out Source_Location;
Sloc_End : out Source_Location;
Success : out Boolean;
From_Index : Natural := 0)
is
pragma Unreferenced
(Lang, Buffer, Construct, Sloc_Start, Sloc_End, From_Index);
begin
Success := False;
end Get_Referenced_Entity;
-------------------
-- Format_Buffer --
-------------------
procedure Format_Buffer
(Lang : access Language_Root;
Buffer : String;
Replace : Replace_Text_Callback;
From, To : Natural := 0;
Indent_Params : Indent_Parameters := Default_Indent_Parameters;
Indent_Offset : Natural := 0;
Case_Exceptions : Case_Handling.Casing_Exceptions :=
Case_Handling.No_Casing_Exception;
Is_Optional_Keyword : access function (S : String)
return Boolean := null)
is
pragma Unreferenced
(Lang, Indent_Offset, Case_Exceptions, Is_Optional_Keyword);
Use_Tabs : Boolean renames Indent_Params.Use_Tabs;
Index : Natural;
Indent : Natural := 0;
Start_Of_Line : Natural;
Start_Prev_Line : Natural;
function Find_Line_Start
(Buffer : String; Index : Natural) return Natural;
-- Find the starting ASCII.LF character of the line positioned at
-- Buffer (Index).
---------------------
-- Find_Line_Start --
---------------------
function Find_Line_Start
(Buffer : String; Index : Natural) return Natural
is
Result : Natural := Index;
begin
while Result > Buffer'First
and then Buffer (Result) /= ASCII.LF
loop
Result := Result - 1;
end loop;
return Result;
end Find_Line_Start;
begin
if Buffer'Length <= 1 or else To > From + 1 then
return;
end if;
Start_Of_Line := Find_Line_Start (Buffer, Buffer'Last - 1);
Start_Prev_Line := Find_Line_Start (Buffer, Start_Of_Line - 1);
-- Compute the indentation level
for J in Start_Prev_Line + 1 .. Start_Of_Line - 1 loop
if Buffer (J) = ' ' then
Indent := Indent + 1;
elsif Buffer (J) = ASCII.HT then
Indent := Indent + Tab_Width - (Indent mod Tab_Width);
else
exit;
end if;
end loop;
-- Find the blank slice to replace
Index := Start_Of_Line + 1;
while Index < Buffer'Last
and then (Buffer (Index) = ' ' or else Buffer (Index) = ASCII.HT)
loop
Index := Index + 1;
end loop;
Replace
(To, 1, Index - Start_Of_Line,
Blank_Slice (Indent, Use_Tabs, Tab_Width));
end Format_Buffer;
-------------------
-- Category_Name --
-------------------
function Category_Name
(Category : Language.Language_Category;
Name : GNATCOLL.Symbols.Symbol := GNATCOLL.Symbols.No_Symbol)
return String
is
use type Strings.String_Access;
begin
if Name /= No_Symbol then
return Get (Name).all;
end if;
case Category is
when Cat_Unknown => return "";
when Cat_Custom => return "custom";
when Cat_Package => return "package";
when Cat_Namespace => return "namespace";
when Cat_Task => return "task";
when Cat_Procedure => return "subprogram";
when Cat_Function => return "subprogram";
when Cat_Method => return "method";
when Cat_Constructor => return "constructor";
when Cat_Destructor => return "destructor";
when Cat_Protected => return "protected";
when Cat_Entry => return "entry";
when Cat_Class => return "class";
when Cat_Structure => return "structure";
when Cat_Case_Inside_Record => return "structure variant part";
when Cat_Union => return "union";
when Cat_Type => return "type";
when Cat_Subtype => return "subtype";
when Cat_Variable => return "variable";
when Cat_Local_Variable => return "variable";
when Cat_Parameter => return "parameter";
when Cat_Discriminant => return "discriminant";
when Cat_Field => return "field";
when Cat_Literal => return "literal";
when Cat_Representation_Clause => return "representation clause";
when Cat_With => return "with";
when Cat_Use => return "use";
when Cat_Include => return "include";
when Construct_Category => return "";
when Cat_Exception_Handler => return "";
when Cat_Pragma => return "pragma";
when Cat_Aspect => return "aspect";
end case;
end Category_Name;
--------------------------------
-- Get_Indentation_Parameters --
--------------------------------
procedure Get_Indentation_Parameters
(Lang : access Language_Root;
Params : out Indent_Parameters;
Indent_Style : out Indentation_Kind) is
begin
Params := Lang.Indent_Params;
Indent_Style := Lang.Indent_Style;
end Get_Indentation_Parameters;
--------------------------------
-- Set_Indentation_Parameters --
--------------------------------
procedure Set_Indentation_Parameters
(Lang : access Language_Root;
Params : Indent_Parameters;
Indent_Style : Indentation_Kind) is
begin
Lang.Indent_Params := Params;
Lang.Indent_Style := Indent_Style;
end Set_Indentation_Parameters;
----------
-- Free --
----------
procedure Free (Fields : in out Project_Field_Array) is
begin
for F in Fields'Range loop
Strings.Free (Fields (F).Attribute_Name);
Strings.Free (Fields (F).Attribute_Index);
Strings.Free (Fields (F).Description);
end loop;
end Free;
------------------------
-- Word_Character_Set --
------------------------
function Word_Character_Set
(Lang : access Language_Root)
return Character_Set
is
pragma Unreferenced (Lang);
begin
return Default_Word_Character_Set;
end Word_Character_Set;
------------------
-- Is_Word_Char --
------------------
function Is_Word_Char
(Lang : access Language_Root; Char : Wide_Wide_Character) return Boolean
is
pragma Unreferenced (Lang);
begin
return Is_Entity_Letter (Char);
end Is_Word_Char;
---------
-- "=" --
---------
overriding function "=" (S1, S2 : Source_Location) return Boolean is
begin
if S1.Index > 0 and then S2.Index > 0 then
return S1.Index = S2.Index;
else
return S1.Line = S2.Line
and then S1.Column = S2.Column;
end if;
end "=";
---------
-- "<" --
---------
function "<" (S1, S2 : Source_Location) return Boolean is
begin
if S1.Index > 0 and then S2.Index > 0 then
return S1.Index < S2.Index;
elsif S1.Line = S2.Line then
return S1.Column < S2.Column;
else
return S1.Line < S2.Line;
end if;
end "<";
----------
-- "<=" --
----------
function "<=" (S1, S2 : Source_Location) return Boolean is
begin
return S1 = S2 or else S1 < S2;
end "<=";
---------
-- ">" --
---------
function ">" (S1, S2 : Source_Location) return Boolean is
begin
return S2 < S1;
end ">";
----------
-- ">=" --
----------
function ">=" (S1, S2 : Source_Location) return Boolean is
begin
return not (S1 < S2);
end ">=";
---------------------------
-- Parse_Tokens_Backward --
---------------------------
procedure Parse_Tokens_Backwards
(Lang : access Language_Root;
Buffer : UTF8_String;
Start_Offset : String_Index_Type;
End_Offset : String_Index_Type := 0;
-- ??? This analysis should be done when looking for comments !!!
Callback :
access procedure (Token : Token_Record;
Stop : in out Boolean))
is
pragma Unreferenced (Lang);
Lowest : constant String_Index_Type :=
String_Index_Type'Max (End_Offset, String_Index_Type (Buffer'First));
Index : String_Index_Type := Start_Offset;
Stop : Boolean := False;
begin
if Index not in Lowest .. String_Index_Type (Buffer'Last) then
return;
else
Skip_Word
(Buffer (Natural (Lowest) .. Natural (Index)),
Natural (Index),
Step => -1);
Callback
((Tok_Type => No_Token,
Token_First => Index + 1,
Token_Last => Start_Offset),
Stop);
end if;
end Parse_Tokens_Backwards;
------------------------------
-- Parse_Reference_Backward --
------------------------------
function Parse_Reference_Backwards
(Lang : access Language_Root;
Buffer : UTF8_String;
Start_Offset : String_Index_Type;
End_Offset : String_Index_Type := 0) return String
is
Buf_Start : Integer := 1;
Buf_End : Integer := 0;
procedure Callback
(Token : Token_Record;
Stop : in out Boolean);
procedure Callback
(Token : Token_Record;
Stop : in out Boolean)
is
begin
Buf_End := Integer (Token.Token_Last);
Buf_Start := Integer (Token.Token_First);
Stop := True;
end Callback;
begin
Lang.Parse_Tokens_Backwards
(Buffer => Buffer,
Start_Offset => Start_Offset,
End_Offset => End_Offset,
Callback => Callback'Access);
return Buffer (Buf_Start .. Buf_End);
end Parse_Reference_Backwards;
-----------------
-- Set_Symbols --
-----------------
procedure Set_Symbols
(Self : access Language_Root'Class;
Symbols : not null access GNATCOLL.Symbols.Symbol_Table_Record'Class) is
begin
Self.Symbols := Symbol_Table_Access (Symbols);
end Set_Symbols;
-------------
-- Symbols --
-------------
function Symbols
(Self : access Language_Root'Class)
return GNATCOLL.Symbols.Symbol_Table_Access is
begin
return Self.Symbols;
end Symbols;
----------------------
-- Entities_Indexed --
----------------------
function Entities_Indexed (Self : Language_Root) return Boolean is
pragma Unreferenced (Self);
begin
return False;
end Entities_Indexed;
end Language;
|
AdaCore/gpr | Ada | 20 | ads | package J is
end J;
|
Rodeo-McCabe/orka | Ada | 4,651 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Characters.Latin_1;
with Ada.Exceptions;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Orka.Containers.Ring_Buffers;
with Orka.Loggers.Formatting;
with Orka.Loggers.Terminal;
with Orka.OS;
package body Orka.Loggers.Location is
package L renames Ada.Characters.Latin_1;
package SU renames Ada.Strings.Unbounded;
type Log_Request is record
Path : SU.Unbounded_String;
Message : SU.Unbounded_String;
end record;
package Buffers is new Orka.Containers.Ring_Buffers (Log_Request);
protected Queue is
procedure Enqueue
(Path : SU.Unbounded_String;
From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String);
entry Dequeue (Request : out Log_Request; Stop : out Boolean);
procedure Shutdown;
private
Messages : Buffers.Buffer (Capacity_Queue);
Should_Stop : Boolean := False;
Has_Stopped : Boolean := False;
end Queue;
protected body Queue is
procedure Enqueue
(Path : SU.Unbounded_String;
From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String) is
begin
if not Messages.Is_Full and not Has_Stopped then
Messages.Add_Last
((Path => Path,
Message => SU.To_Unbounded_String
(Formatting.Format_Message_No_Color (From, Kind, Level, ID, Message) & L.LF)));
else
Orka.Loggers.Terminal.Logger.Log (From, Kind, Level, ID, Message);
end if;
end Enqueue;
entry Dequeue
(Request : out Log_Request;
Stop : out Boolean) when not Messages.Is_Empty or else Should_Stop is
begin
Stop := Should_Stop and Messages.Is_Empty;
if Stop then
Has_Stopped := True;
return;
end if;
Request := Messages.Remove_First;
end Dequeue;
procedure Shutdown is
begin
Should_Stop := True;
end Shutdown;
end Queue;
procedure Shutdown is
begin
Queue.Shutdown;
end Shutdown;
task Logger_Task;
task body Logger_Task is
Name : String renames Task_Name;
Request : Log_Request;
Stop : Boolean;
begin
Orka.OS.Set_Task_Name (Name);
loop
Queue.Dequeue (Request, Stop);
exit when Stop;
Location.Append_Data
(Path => SU.To_String (Request.Path),
Data => Orka.Resources.Convert (SU.To_String (Request.Message)));
end loop;
exception
when Error : others =>
Ada.Text_IO.Put_Line (Name & ": " & Ada.Exceptions.Exception_Information (Error));
end Logger_Task;
protected type Location_Logger (Min_Level : Severity) is new Logger with
overriding
procedure Log
(From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String);
procedure Set_Path (Path : String);
private
File_Path : SU.Unbounded_String;
end Location_Logger;
protected body Location_Logger is
procedure Log
(From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String) is
begin
if Level <= Min_Level then
Queue.Enqueue (File_Path, From, Kind, Level, ID, Message);
end if;
end Log;
procedure Set_Path (Path : String) is
begin
File_Path := SU.To_Unbounded_String (Path);
end Set_Path;
end Location_Logger;
function Create_Logger (Path : String; Level : Severity := Debug) return Logger_Ptr is
begin
return Result : constant Logger_Ptr := new Location_Logger (Min_Level => Level) do
Location_Logger (Result.all).Set_Path (Path);
end return;
end Create_Logger;
end Orka.Loggers.Location;
|
AaronC98/PlaneSystem | Ada | 4,929 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2007-2015, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
private with Ada.Containers.Indefinite_Hashed_Maps;
private with Ada.Strings.Hash;
private with GNAT.SHA1;
package AWS.Services.Web_Block.Context is
type Object is tagged private;
-- A context object, can be used to record key/name values
Empty : constant Object;
type Id is private;
-- An object Id, the Id depends only on the context content. Two context
-- with the very same content will have the same Id.
function Image (CID : Id) return String;
-- Returns CID string representation
function Value (CID : String) return Id;
-- Returns Id given it's string representation
function Register (Context : Object) return Id
with Post => Exist (Register'Result);
-- Register the context into the database, returns its Id
function Exist (CID : Id) return Boolean;
-- Returns True if CID context exists into the database
function Get (CID : Id) return Object;
-- Returns the context object corresponding to CID
procedure Set_Value (Context : in out Object; Name, Value : String)
with Post => Context.Exist (Name);
-- Add a new name/value pair (replace name/value if already present)
function Get_Value (Context : Object; Name : String) return String
with Post => (if not Context.Exist (Name) then Get_Value'Result = "");
-- Returns the value for the key Name or an empty string if does not exist
function Exist (Context : Object; Name : String) return Boolean;
-- Returns true if the key Name exist in this context
procedure Remove (Context : in out Object; Name : String)
with Post => not Context.Exist (Name);
-- Remove the context for key Name
generic
type Data is private;
Null_Data : Data;
package Generic_Data is
procedure Set_Value
(Context : in out Object;
Name : String;
Value : Data)
with Post => Context.Exist (Name);
-- Set key/pair value for the SID
function Get_Value (Context : Object; Name : String) return Data
with
Inline,
Post => (if not Context.Exist (Name)
then Get_Value'Result = Null_Data);
-- Returns the Value for Key in the session SID or Null_Data if
-- key does not exist.
end Generic_Data;
private
use Ada;
use GNAT;
pragma Suppress (Tampering_Check);
-- ?? Suppress Tampering_Check until O608-005 is fixed
package KV is new Containers.Indefinite_Hashed_Maps
(String, String, Strings.Hash, "=");
type Object is new KV.Map with null record;
type Id is new SHA1.Message_Digest;
Empty : constant Object := Object'(KV.Map with null record);
end AWS.Services.Web_Block.Context;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Form_Linked_Cell_Attributes is
pragma Preelaborate;
type ODF_Form_Linked_Cell_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Linked_Cell_Attribute_Access is
access all ODF_Form_Linked_Cell_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Linked_Cell_Attributes;
|
AdaCore/training_material | Ada | 1,891 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with stddef_h;
package malloc_h is
-- arg-macro: procedure alloca (x)
-- __builtin_alloca((x))
--*
-- * This file has no copyright assigned and is placed in the Public Domain.
-- * This file is part of the mingw-w64 runtime package.
-- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
--
-- Return codes for _heapwalk()
-- Values for _heapinfo.useflag
-- The structure used to walk through the heap with _heapwalk.
type u_heapinfo is record
u_pentry : access int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\malloc.h:47
u_size : aliased stddef_h.size_t; -- d:\install\gpl2018\x86_64-pc-mingw32\include\malloc.h:48
u_useflag : aliased int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\malloc.h:49
end record;
pragma Convention (C_Pass_By_Copy, u_heapinfo); -- d:\install\gpl2018\x86_64-pc-mingw32\include\malloc.h:46
-- Make sure that X86intrin.h doesn't produce here collisions.
-- Users should really use MS provided versions
-- skipped func __mingw_aligned_malloc
-- skipped func __mingw_aligned_free
-- skipped func __mingw_aligned_offset_realloc
-- skipped func __mingw_aligned_realloc
-- skipped func _resetstkoflw
-- skipped func _set_malloc_crt_max_wait
-- skipped func _expand
-- skipped func _msize
-- skipped func _get_sbh_threshold
-- skipped func _set_sbh_threshold
-- skipped func _set_amblksiz
-- skipped func _get_amblksiz
-- skipped func _heapadd
-- skipped func _heapchk
-- skipped func _heapmin
-- skipped func _heapset
-- skipped func _heapwalk
-- skipped func _heapused
-- skipped func _get_heap_handle
-- skipped func _MarkAllocaS
-- skipped func _freea
end malloc_h;
|
Fabien-Chouteau/lvgl-ada | Ada | 3,321 | ads | with System;
with Interfaces.C.Extensions;
package Lv.Anim is
type Path_T is access function (Arg1 : System.Address) return Int32_T;
pragma Convention (C, Path_T);
type Fp_T is access procedure (Arg1 : System.Address; Arg2 : Int32_T);
pragma Convention (C, Fp_T);
type Cb_T is access procedure (Arg1 : System.Address);
pragma Convention (C, Cb_T);
type U_Lv_Anim_T is record
Var : System.Address;
Fp : Fp_T;
End_Cb : Cb_T;
Path : Path_T;
Start : aliased Int32_T;
C_End : aliased Int32_T;
Time : aliased Uint16_T;
Act_Time : aliased Int16_T;
Playback_Pause : aliased Uint16_T;
Repeat_Pause : aliased Uint16_T;
Playback : Extensions.Unsigned_1;
Repeat : Extensions.Unsigned_1;
Playback_Now : Extensions.Unsigned_1;
Has_Run : Extensions.Unsigned_1;
end record;
pragma Convention (C_Pass_By_Copy, U_Lv_Anim_T);
pragma Pack (U_Lv_Anim_T);
subtype Anim_T is U_Lv_Anim_T;
-- Init. the animation module
procedure Init;
-- Create an animation
-- @param p an initialized 'anim_t' variable. Not required after call.
procedure Create (A : access Anim_T);
-- Delete an animation for a variable with a given animatior function
-- @param var pointer to variable
-- @param fp a function pointer which is animating 'var',
-- or NULL to ignore it and delete all animation with 'var
-- @return true: at least 1 animation is deleted, false: no animation is deleted
function Del (Var : System.Address; Fp : Fp_T) return U_Bool;
-- Calculate the time of an animation with a given speed and the start and end values
-- @param speed speed of animation in unit/sec
-- @param start start value of the animation
-- @param end end value of the animation
-- @return the required time [ms] for the animation with the given parameters
function Speed_To_Time
(Speed : Uint16_T;
Start : Int32_T;
End_P : Int32_T) return Uint16_T;
-- Calculate the current value of an animation applying linear characteristic
-- @param a pointer to an animation
-- @return the current value to set
function Path_Linear (A : access constant Anim_T) return Int32_T;
-- Calculate the current value of an animation applying an "S" characteristic (cosine)
-- @param a pointer to an animation
-- @return the current value to set
function Path_Ease_In_Out
(A : access constant Anim_T) return Int32_T;
-- Calculate the current value of an animation applying step characteristic.
-- (Set end value on the end of the animation)
-- @param a pointer to an animation
-- @return the current value to set
function Path_Step (A : access constant Anim_T) return Int32_T;
-------------
-- Imports --
-------------
pragma Import (C, Init, "lv_anim_init");
pragma Import (C, Create, "lv_anim_create");
pragma Import (C, Del, "lv_anim_del");
pragma Import (C, Speed_To_Time, "lv_anim_speed_to_time");
pragma Import (C, Path_Linear, "lv_anim_path_linear");
pragma Import (C, Path_Ease_In_Out, "lv_anim_path_ease_in_out");
pragma Import (C, Path_Step, "lv_anim_path_step");
end Lv.Anim;
|
reznikmm/matreshka | Ada | 3,558 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Visitors.Containment;
with AMF.Visitors.Generic_CMOF_Containment;
package AMF.Visitors.CMOF_Containment is
new AMF.Visitors.Generic_CMOF_Containment
(AMF.Visitors.Containment.Containment_Iterator);
|
reznikmm/matreshka | Ada | 6,747 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Matreshka.Internals.Unicode.Ucd;
with Matreshka.Internals.Utf16;
package body League.Strings.Debug is
use Ada.Strings.Unbounded;
use Matreshka.Internals.Strings;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Unicode.Ucd;
use Matreshka.Internals.Utf16;
function Code_Point_Image (Item : Code_Point) return String;
function Collation_Weight_Image (Item : Collation_Weight) return String;
----------------------
-- Code_Point_Image --
----------------------
function Code_Point_Image (Item : Code_Point) return String is
To_Hex_Digit : constant
array (Code_Point range 0 .. 15) of Character
:= "0123456789ABCDEF";
begin
if Item <= 16#FFFF# then
return Result : String (1 .. 4) do
Result (4) := To_Hex_Digit (Item mod 16);
Result (3) := To_Hex_Digit ((Item / 16) mod 16);
Result (2) := To_Hex_Digit ((Item / 256) mod 16);
Result (1) := To_Hex_Digit ((Item / 4096) mod 16);
end return;
else
return Result : String (1 .. 6) do
Result (6) := To_Hex_Digit (Item mod 16);
Result (5) := To_Hex_Digit ((Item / 16) mod 16);
Result (4) := To_Hex_Digit ((Item / 256) mod 16);
Result (3) := To_Hex_Digit ((Item / 4096) mod 16);
Result (2) := To_Hex_Digit ((Item / 65536) mod 16);
Result (1) := To_Hex_Digit ((Item / 1048576) mod 16);
end return;
end if;
end Code_Point_Image;
----------------------------
-- Collation_Weight_Image --
----------------------------
function Collation_Weight_Image (Item : Collation_Weight) return String is
To_Hex_Digit : constant
array (Collation_Weight range 0 .. 15) of Character
:= "0123456789ABCDEF";
Result : String (1 .. 4);
begin
Result (4) := To_Hex_Digit (Item mod 16);
Result (3) := To_Hex_Digit ((Item / 16) mod 16);
Result (2) := To_Hex_Digit ((Item / 256) mod 16);
Result (1) := To_Hex_Digit ((Item / 4096) mod 16);
return Result;
end Collation_Weight_Image;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (Item : Sort_Key) return String is
D : constant Shared_Sort_Key_Access := Item.Data;
Result : Unbounded_String;
begin
Append (Result, '[');
for J in 1 .. D.Last loop
if J /= 1 then
Append (Result, ' ');
end if;
if D.Data (J) = 0 then
Append (Result, "|");
else
Append (Result, Collation_Weight_Image (D.Data (J)));
end if;
end loop;
Append (Result, ']');
return To_String (Result);
end Debug_Image;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (Item : Universal_String) return String is
D : constant Shared_String_Access := Item.Data;
Result : Unbounded_String;
Index : Utf16_String_Index := 0;
Code : Code_Point;
begin
while Index < D.Unused loop
if Index /= 0 then
Append (Result, ' ');
end if;
Unchecked_Next (D.Value, Index, Code);
Append (Result, Code_Point_Image (Code));
end loop;
return To_String (Result);
end Debug_Image;
end League.Strings.Debug;
|
pdaxrom/Kino2 | Ada | 4,168 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Enumeration_IO --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
-- $Revision: 1.9 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Terminal_Interface.Curses.Text_IO.Aux;
package body Terminal_Interface.Curses.Text_IO.Enumeration_IO is
package Aux renames Terminal_Interface.Curses.Text_IO.Aux;
package EIO is new Ada.Text_IO.Enumeration_IO (Enum);
procedure Put
(Win : in Window;
Item : in Enum;
Width : in Field := Default_Width;
Set : in Type_Set := Default_Setting)
is
Buf : String (1 .. Field'Last);
Tset : Ada.Text_IO.Type_Set;
begin
if Set /= Mixed_Case then
Tset := Ada.Text_IO.Type_Set'Val (Type_Set'Pos (Set));
else
Tset := Ada.Text_IO.Lower_Case;
end if;
EIO.Put (Buf, Item, Tset);
if Set = Mixed_Case then
Buf (Buf'First) := To_Upper (Buf (Buf'First));
end if;
Aux.Put_Buf (Win, Buf, Width, True, True);
end Put;
procedure Put
(Item : in Enum;
Width : in Field := Default_Width;
Set : in Type_Set := Default_Setting)
is
begin
Put (Get_Window, Item, Width, Set);
end Put;
end Terminal_Interface.Curses.Text_IO.Enumeration_IO;
|
reznikmm/matreshka | Ada | 3,792 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Office.Styles;
package ODF.DOM.Elements.Office.Styles.Internals is
function Create
(Node : Matreshka.ODF_Elements.Office.Styles.Office_Styles_Access)
return ODF.DOM.Elements.Office.Styles.ODF_Office_Styles;
function Wrap
(Node : Matreshka.ODF_Elements.Office.Styles.Office_Styles_Access)
return ODF.DOM.Elements.Office.Styles.ODF_Office_Styles;
end ODF.DOM.Elements.Office.Styles.Internals;
|
reznikmm/matreshka | Ada | 3,991 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Svg_Cap_Height_Attributes;
package Matreshka.ODF_Svg.Cap_Height_Attributes is
type Svg_Cap_Height_Attribute_Node is
new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node
and ODF.DOM.Svg_Cap_Height_Attributes.ODF_Svg_Cap_Height_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Cap_Height_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Svg_Cap_Height_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Svg.Cap_Height_Attributes;
|
reznikmm/matreshka | Ada | 4,559 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Key1_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Key1_Attribute_Node is
begin
return Self : Text_Key1_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Key1_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Key1_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Key1_Attribute,
Text_Key1_Attribute_Node'Tag);
end Matreshka.ODF_Text.Key1_Attributes;
|
Skjelsbek/ada_projects | Ada | 2,560 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with MicroBit.Display;
with Ada.Integer_Text_IO;
procedure Main is
begin
loop
MicroBit.Display.Display ("Make with Ada! ");
Ada.Integer_Text_IO(1);
end loop;
end Main;
|
sungyeon/drake | Ada | 925 | ads | pragma License (Unrestricted);
-- separated and auto-loaded by compiler
private generic
type Num is range <>;
package Ada.Wide_Text_IO.Integer_IO is
Default_Width : Field := Num'Width;
Default_Base : Number_Base := 10;
-- procedure Get (
-- File : File_Type; -- Input_File_Type
-- Item : out Num;
-- Width : Field := 0);
-- procedure Get (
-- Item : out Num;
-- Width : Field := 0);
-- procedure Put (
-- File : File_Type; -- Output_File_Type
-- Item : Num;
-- Width : Field := Default_Width;
-- Base : Number_Base := Default_Base);
-- procedure Put (
-- Item : Num;
-- Width : Field := Default_Width;
-- Base : Number_Base := Default_Base);
-- procedure Get (
-- From : String;
-- Item : out Num;
-- Last : out Positive);
-- procedure Put (
-- To : out String;
-- Item : Num;
-- Base : Number_Base := Default_Base);
end Ada.Wide_Text_IO.Integer_IO;
|
Jellix/virtual_clocks | Ada | 3,497 | ads | ------------------------------------------------------------------------
-- Copyright (C) 2010-2020 by <[email protected]> --
-- --
-- This work is free. You can redistribute it and/or modify it under --
-- the terms of the Do What The Fuck You Want To Public License, --
-- Version 2, as published by Sam Hocevar. See the LICENSE file for --
-- more details. --
------------------------------------------------------------------------
pragma License (Unrestricted);
package Clocks.Virtual_Clocks is
---------------------------------------------------------------------
-- Virtual_Clock
---------------------------------------------------------------------
-- Protected type implementing the Clock_Interface.
---------------------------------------------------------------------
protected type Virtual_Clock is new Clock_Interface with
------------------------------------------------------------------
-- Forward_Time
------------------------------------------------------------------
overriding
procedure Forward_Time (Amount : in Duration);
------------------------------------------------------------------
-- Get_Time
------------------------------------------------------------------
overriding
function Get_Time return Time;
------------------------------------------------------------------
-- Pulse
------------------------------------------------------------------
overriding
procedure Pulse (Amount : in Duration);
------------------------------------------------------------------
-- Set_Speed
------------------------------------------------------------------
overriding
procedure Set_Speed (New_Speed : in Speedup);
------------------------------------------------------------------
-- Set_Time
------------------------------------------------------------------
overriding
procedure Set_Time (New_Time : in Time);
------------------------------------------------------------------
-- Resume
------------------------------------------------------------------
overriding
entry Resume;
------------------------------------------------------------------
-- Suspend
------------------------------------------------------------------
overriding
entry Suspend;
private
------------------------------------------------------------------
-- Activated
------------------------------------------------------------------
-- Returns the current activation state of the clock.
------------------------------------------------------------------
not overriding
function Activated return Boolean;
Current_Time : Time := START_DATE;
Speed : Speedup := UNCHANGED_TIME;
Is_Active : Boolean := True;
end Virtual_Clock;
---------------------------------------------------------------------
-- Virtual_Clock.Create
---------------------------------------------------------------------
overriding
procedure Create (Clock : out Virtual_Clock;
Start_Time : in Time := START_DATE;
Speed : in Speedup := UNCHANGED_TIME);
end Clocks.Virtual_Clocks;
|
charlie5/cBound | Ada | 1,283 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with xcb.xcb_focus_in_event_t;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_focus_out_event_t is
-- Item
--
subtype Item is xcb.xcb_focus_in_event_t.Item;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_focus_out_event_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_focus_out_event_t.Item,
Element_Array => xcb.xcb_focus_out_event_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_focus_out_event_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_focus_out_event_t.Pointer,
Element_Array => xcb.xcb_focus_out_event_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_focus_out_event_t;
|
sungyeon/drake | Ada | 16,828 | adb | with Ada.Exception_Identification.From_Here;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Address_To_Named_Access_Conversions;
with System.Growth;
with System.Standard_Allocators;
with System.System_Allocators.Allocated_Size;
package body Ada.Streams.Unbounded_Storage_IO is
use Exception_Identification.From_Here;
use type System.Storage_Elements.Storage_Offset;
procedure Free is
new Unchecked_Deallocation (Stream_Type, Stream_Access);
package DA_Conv is
new System.Address_To_Named_Access_Conversions (Data, Data_Access);
subtype Nonnull_Data_Access is not null Data_Access;
function Upcast is
new Unchecked_Conversion (
Nonnull_Data_Access,
System.Reference_Counting.Container);
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Data_Access);
type Data_Access_Access is access all Nonnull_Data_Access;
type Container_Access is access all System.Reference_Counting.Container;
function Upcast is
new Unchecked_Conversion (Data_Access_Access, Container_Access);
function Allocation_Size (Capacity : System.Reference_Counting.Length_Type)
return System.Storage_Elements.Storage_Count;
function Allocation_Size (Capacity : System.Reference_Counting.Length_Type)
return System.Storage_Elements.Storage_Count
is
Dividable : constant Boolean :=
Stream_Element_Array'Component_Size rem Standard'Storage_Unit = 0;
Header_Size : constant System.Storage_Elements.Storage_Count :=
Data'Size / Standard'Storage_Unit;
Use_Size : System.Storage_Elements.Storage_Count;
begin
if Dividable then -- optimized for packed
Use_Size :=
Capacity
* (Stream_Element_Array'Component_Size / Standard'Storage_Unit);
else -- unpacked
Use_Size :=
(Capacity * Stream_Element_Array'Component_Size
+ (Standard'Storage_Unit - 1))
/ Standard'Storage_Unit;
end if;
return Header_Size + Use_Size;
end Allocation_Size;
procedure Adjust_Allocated (Data : not null Data_Access);
procedure Adjust_Allocated (Data : not null Data_Access) is
Dividable : constant Boolean :=
Stream_Element_Array'Component_Size rem Standard'Storage_Unit = 0;
Header_Size : constant System.Storage_Elements.Storage_Count :=
Unbounded_Storage_IO.Data'Size / Standard'Storage_Unit;
M : constant System.Address := DA_Conv.To_Address (Data);
Usable_Size : constant System.Storage_Elements.Storage_Count :=
System.System_Allocators.Allocated_Size (M) - Header_Size;
Allocated_Capacity : Stream_Element_Count;
begin
if Dividable then -- optimized for packed
Allocated_Capacity := Stream_Element_Offset (
Usable_Size
/ (
Stream_Element_Array'Component_Size
/ Standard'Storage_Unit));
else -- unpacked
Allocated_Capacity := Stream_Element_Offset (
Usable_Size
* Standard'Storage_Unit
/ Stream_Element_Array'Component_Size);
end if;
Data.Capacity := Allocated_Capacity;
Data.Storage := M + Header_Size;
end Adjust_Allocated;
function Allocate_Data (
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type)
return not null Data_Access;
function Allocate_Data (
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type)
return not null Data_Access
is
M : constant System.Address :=
System.Standard_Allocators.Allocate (Allocation_Size (Capacity));
Result : constant not null Data_Access := DA_Conv.To_Pointer (M);
begin
Result.Reference_Count := 1;
Result.Max_Length := Max_Length;
Adjust_Allocated (Result);
return Result;
end Allocate_Data;
procedure Free_Data (Data : in out System.Reference_Counting.Data_Access);
procedure Free_Data (Data : in out System.Reference_Counting.Data_Access) is
begin
System.Standard_Allocators.Free (DA_Conv.To_Address (Downcast (Data)));
Data := null;
end Free_Data;
procedure Reallocate_Data (
Data : aliased in out not null System.Reference_Counting.Data_Access;
Length : System.Reference_Counting.Length_Type;
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type);
procedure Reallocate_Data (
Data : aliased in out not null System.Reference_Counting.Data_Access;
Length : System.Reference_Counting.Length_Type;
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type)
is
pragma Unreferenced (Length);
M : constant System.Address :=
System.Standard_Allocators.Reallocate (
DA_Conv.To_Address (Downcast (Data)),
Allocation_Size (Capacity));
begin
Data := Upcast (DA_Conv.To_Pointer (M));
Downcast (Data).Max_Length := Max_Length;
Adjust_Allocated (Downcast (Data));
end Reallocate_Data;
procedure Copy_Data (
Target : out not null System.Reference_Counting.Data_Access;
Source : not null System.Reference_Counting.Data_Access;
Length : System.Reference_Counting.Length_Type;
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type);
procedure Copy_Data (
Target : out not null System.Reference_Counting.Data_Access;
Source : not null System.Reference_Counting.Data_Access;
Length : System.Reference_Counting.Length_Type;
Max_Length : System.Reference_Counting.Length_Type;
Capacity : System.Reference_Counting.Length_Type)
is
Data : constant not null Data_Access :=
Allocate_Data (Max_Length, Capacity);
Source_Storage_All : Stream_Element_Array (
1 .. Stream_Element_Offset (Length));
for Source_Storage_All'Address use Downcast (Source).Storage;
Target_Storage_All : Stream_Element_Array (
1 .. Stream_Element_Offset (Length));
for Target_Storage_All'Address use Data.Storage;
begin
Target_Storage_All := Source_Storage_All;
Target := Upcast (Data);
end Copy_Data;
procedure Reallocate (
Buffer : in out Non_Controlled_Buffer_Type;
Length : Stream_Element_Count;
Size : Stream_Element_Count);
procedure Reallocate (
Buffer : in out Non_Controlled_Buffer_Type;
Length : Stream_Element_Count;
Size : Stream_Element_Count) is
begin
System.Reference_Counting.Unique (
Target => Upcast (Buffer.Data'Unchecked_Access),
Target_Length => System.Reference_Counting.Length_Type (Buffer.Last),
Target_Capacity =>
System.Reference_Counting.Length_Type (Buffer.Data.Capacity),
New_Length => System.Reference_Counting.Length_Type (Length),
New_Capacity => System.Reference_Counting.Length_Type (Size),
Sentinel => Upcast (Empty_Data'Unrestricted_Access),
Reallocate => Reallocate_Data'Access,
Copy => Copy_Data'Access,
Free => Free_Data'Access);
end Reallocate;
procedure Unique (Buffer : in out Non_Controlled_Buffer_Type);
procedure Unique (Buffer : in out Non_Controlled_Buffer_Type) is
begin
if System.Reference_Counting.Shared (Upcast (Buffer.Data)) then
Reallocate (
Buffer,
Buffer.Last,
Buffer.Data.Capacity); -- not shrinking
end if;
end Unique;
procedure Set_Size (
Buffer : in out Non_Controlled_Buffer_Type;
Size : Stream_Element_Count);
procedure Set_Size (
Buffer : in out Non_Controlled_Buffer_Type;
Size : Stream_Element_Count)
is
Old_Capacity : constant Stream_Element_Count := Buffer.Data.Capacity;
Failure : Boolean;
begin
System.Reference_Counting.In_Place_Set_Length (
Target_Data => Upcast (Buffer.Data),
Target_Length => System.Reference_Counting.Length_Type (Buffer.Last),
Target_Max_Length => Buffer.Data.Max_Length,
Target_Capacity =>
System.Reference_Counting.Length_Type (Old_Capacity),
New_Length => System.Reference_Counting.Length_Type (Size),
Failure => Failure);
if Failure then
declare
function Grow is
new System.Growth.Good_Grow (
Stream_Element_Count,
Component_Size => Stream_Element_Array'Component_Size);
New_Capacity : Stream_Element_Count;
begin
if Old_Capacity >= Size then
New_Capacity := Old_Capacity; -- not shrinking
else
New_Capacity :=
Stream_Element_Offset'Max (Grow (Old_Capacity), Size);
end if;
Reallocate (Buffer, Size, New_Capacity);
end;
end if;
Buffer.Last := Size;
end Set_Size;
-- implementation
procedure Reset (Object : in out Buffer_Type) is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
NC_Object.Index := 1;
end Reset;
function Size (Object : Buffer_Type) return Stream_Element_Count is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
return NC_Object.Last;
end Size;
procedure Set_Size (
Object : in out Buffer_Type;
Size : Stream_Element_Count)
is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
Set_Size (NC_Object, Size);
if NC_Object.Index > Size + 1 then
NC_Object.Index := Size + 1;
end if;
end Set_Size;
function Capacity (Object : Buffer_Type) return Stream_Element_Count is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
return NC_Object.Data.Capacity;
end Capacity;
procedure Reserve_Capacity (
Object : in out Buffer_Type;
Capacity : Stream_Element_Count)
is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
New_Capacity : constant Stream_Element_Count :=
Stream_Element_Offset'Max (Capacity, NC_Object.Last);
begin
Reallocate (NC_Object, NC_Object.Last, New_Capacity);
end Reserve_Capacity;
function Storage_Address (Object : aliased in out Buffer_Type)
return System.Address
is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
Unique (NC_Object);
return NC_Object.Data.Storage;
end Storage_Address;
function Storage_Size (Object : Buffer_Type)
return System.Storage_Elements.Storage_Count
is
NC_Object : Non_Controlled_Buffer_Type
renames Controlled.Reference (Object).all;
begin
return System.Storage_Elements.Storage_Offset (NC_Object.Last);
end Storage_Size;
function Stream (Object : Buffer_Type)
return not null access Root_Stream_Type'Class
is
NC_Object_Ref : constant not null access Non_Controlled_Buffer_Type :=
Controlled.Reference (Object);
begin
if NC_Object_Ref.Stream = null then
NC_Object_Ref.Stream := new Stream_Type'(Buffer => NC_Object_Ref);
end if;
return NC_Object_Ref.Stream;
end Stream;
procedure Write_To_Stream (
Stream : not null access Root_Stream_Type'Class;
Item : Buffer_Type)
is
NC_Item : Non_Controlled_Buffer_Type
renames Controlled.Reference (Item).all;
Stream_Storage_All : Stream_Element_Array (1 .. NC_Item.Last);
for Stream_Storage_All'Address use NC_Item.Data.Storage;
begin
Write (Stream.all, Stream_Storage_All);
end Write_To_Stream;
overriding procedure Read (
Stream : in out Stream_Type;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
Length : Stream_Element_Count := Item'Length;
Rest : constant Stream_Element_Count :=
Stream.Buffer.Last - Stream.Buffer.Index + 1;
begin
if Length > Rest then
Length := Rest;
if Length = 0 and then Item'First = Stream_Element_Offset'First then
raise Constraint_Error; -- AARM 13.13.1(11/2)
end if;
end if;
Last := Item'First + (Length - 1);
declare
Stream_Storage_All : Stream_Element_Array (1 .. Stream.Buffer.Last);
for Stream_Storage_All'Address use Stream.Buffer.Data.Storage;
begin
Item (Item'First .. Last) :=
Stream_Storage_All (
Stream.Buffer.Index ..
Stream.Buffer.Index + Length - 1);
end;
Stream.Buffer.Index := Stream.Buffer.Index + Length;
end Read;
overriding procedure Write (
Stream : in out Stream_Type;
Item : Stream_Element_Array)
is
New_Index : constant Stream_Element_Count :=
Stream.Buffer.Index + Item'Length;
Copy_Last : constant Stream_Element_Offset := New_Index - 1;
New_Last : constant Stream_Element_Offset :=
Stream_Element_Offset'Max (Stream.Buffer.Last, Copy_Last);
begin
Set_Size (Stream.Buffer.all, New_Last);
if Stream.Buffer.Index <= Stream.Buffer.Last then -- overwriting
Unique (Stream.Buffer.all);
end if;
declare
Stream_Storage_All : Stream_Element_Array (1 .. New_Last);
for Stream_Storage_All'Address use Stream.Buffer.Data.Storage;
begin
Stream_Storage_All (Stream.Buffer.Index .. Copy_Last) := Item;
end;
Stream.Buffer.Index := New_Index;
Stream.Buffer.Last := New_Last;
end Write;
overriding procedure Set_Index (
Stream : in out Stream_Type;
To : Stream_Element_Positive_Count) is
begin
if To > Stream.Buffer.Last + 1 then
raise Constraint_Error;
end if;
Stream.Buffer.Index := To;
end Set_Index;
overriding function Index (Stream : Stream_Type)
return Stream_Element_Positive_Count is
begin
return Stream.Buffer.Index;
end Index;
overriding function Size (Stream : Stream_Type)
return Stream_Element_Count is
begin
return Stream.Buffer.Last;
end Size;
package body Controlled is
procedure Clear (Data : aliased in out Non_Controlled_Buffer_Type);
procedure Clear (Data : aliased in out Non_Controlled_Buffer_Type) is
begin
System.Reference_Counting.Clear (
Upcast (Data.Data'Unchecked_Access),
Free => Free_Data'Access);
end Clear;
-- implementation
function Reference (Object : Unbounded_Storage_IO.Buffer_Type)
return not null access Non_Controlled_Buffer_Type is
begin
return Buffer_Type (Object).Data'Unrestricted_Access;
end Reference;
overriding procedure Adjust (Object : in out Buffer_Type) is
begin
Object.Data.Stream := null;
System.Reference_Counting.Adjust (
Upcast (Object.Data.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Buffer_Type) is
begin
Clear (Object.Data);
Free (Object.Data.Stream);
end Finalize;
package body Streaming is
procedure Read (
Stream : not null access Root_Stream_Type'Class;
Item : out Buffer_Type)
is
Size : Stream_Element_Offset;
begin
Stream_Element_Offset'Read (Stream, Size);
Item.Data.Last := 0;
Item.Data.Index := 1;
Set_Size (Item.Data, Size);
if Size > 0 then
declare
Stream_Storage_All : Stream_Element_Array (
1 .. Item.Data.Last);
for Stream_Storage_All'Address use Item.Data.Data.Storage;
Last : Stream_Element_Offset;
begin
Read (Stream.all, Stream_Storage_All, Last);
if Last < Stream_Storage_All'Last then
Raise_Exception (End_Error'Identity);
end if;
end;
end if;
end Read;
procedure Write (
Stream : not null access Root_Stream_Type'Class;
Item : Buffer_Type) is
begin
Stream_Element_Offset'Write (Stream, Item.Data.Last);
Write_To_Stream (Stream, Unbounded_Storage_IO.Buffer_Type (Item));
end Write;
end Streaming;
end Controlled;
end Ada.Streams.Unbounded_Storage_IO;
|
adamnemecek/GA_Ada | Ada | 1,042 | ads |
with GA_Maths;
with Multivector;
package Multivector_Type is
type MV_Type is (Unspecified_MV_Type, Multivector_Type, Versor_MV, Blade_MV);
type Parity_Type is (Odd_Parity, Even_Parity, No_Parity);
type MV_Type_Record is private;
function Init (MV : Multivector.Multivector) return MV_Type_Record;
function MV_Kind (MV : MV_Type_Record) return MV_Type;
function Top_Grade (MV : MV_Type_Record) return GA_Maths.Unsigned_Integer;
function Grade_Use (MV : MV_Type_Record) return GA_Maths.Grade_Usage;
function Parity (MV : MV_Type_Record) return Parity_Type;
procedure Print_Multivector_Info (Name : String; Info : MV_Type_Record);
function Zero (MV : MV_Type_Record) return Boolean;
private
type MV_Type_Record is record
MV_Kind : MV_Type := Unspecified_MV_Type;
Zero : Boolean;
Top_Grade : GA_Maths.Unsigned_Integer := 0;
Grade_Use : GA_Maths.Grade_Usage;
Parity : Parity_Type := No_Parity;
end record;
end Multivector_Type;
|
reznikmm/matreshka | Ada | 3,659 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Meta_Keyword_Elements is
pragma Preelaborate;
type ODF_Meta_Keyword is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Meta_Keyword_Access is
access all ODF_Meta_Keyword'Class
with Storage_Size => 0;
end ODF.DOM.Meta_Keyword_Elements;
|
stcarrez/ada-util | Ada | 3,139 | ads | -----------------------------------------------------------------------
-- util-log-locations -- General purpose source file location
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Util.Log.Locations is
-- ------------------------------
-- Source line information
-- ------------------------------
type File_Info (<>) is limited private;
type File_Info_Access is access all File_Info;
-- Create a <b>File_Info</b> record to identify the file whose path is <b>Path</b>
-- and whose relative path portion starts at <b>Relative_Position</b>.
function Create_File_Info (Path : in String;
Relative_Position : in Natural) return File_Info_Access;
-- Get the relative path name
function Relative_Path (File : in File_Info) return String;
type Line_Info is private;
-- Get the line number
function Line (Info : in Line_Info) return Natural;
-- Get the column number
function Column (Info : in Line_Info) return Natural;
-- Get the source file
function File (Info : in Line_Info) return String;
-- Compare the two source location. The comparison is made on:
-- o the source file,
-- o the line number,
-- o the column.
function "<" (Left, Right : in Line_Info) return Boolean;
-- Create a source line information.
function Create_Line_Info (File : in File_Info_Access;
Line : in Natural;
Column : in Natural := 0) return Line_Info;
-- Get a printable representation of the line information using
-- the format:
-- <path>:<line>[:<column>]
-- The path can be reported as relative or absolute path.
-- The column is optional and reported by default.
function To_String (Info : in Line_Info;
Relative : in Boolean := True;
Column : in Boolean := True) return String;
private
pragma Inline (Line);
pragma Inline (File);
type File_Info (Length : Natural) is limited record
Relative_Pos : Natural;
Path : String (1 .. Length);
end record;
NO_FILE : aliased File_Info := File_Info '(Length => 0, Path => "", Relative_Pos => 1);
type Line_Info is record
Line : Natural := 0;
Column : Natural := 0;
File : File_Info_Access := NO_FILE'Access;
end record;
end Util.Log.Locations;
|
reznikmm/matreshka | Ada | 5,932 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2016, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Defines a generic, protocol-independent servlet. To write an HTTP servlet
-- for use on the Web, extend HttpServlet instead.
--
-- GenericServlet implements the Servlet and ServletConfig interfaces.
-- GenericServlet may be directly extended by a servlet, although it's more
-- common to extend a protocol-specific subclass such as HttpServlet.
--
-- GenericServlet makes writing servlets easier. It provides simple versions
-- of the lifecycle methods init and destroy and of the methods in the
-- ServletConfig interface. GenericServlet also implements the log method,
-- declared in the ServletContext interface.
--
-- To write a generic servlet, you need only override the abstract service
-- method.
------------------------------------------------------------------------------
with League.Strings;
with Servlet.Configs;
with Servlet.Contexts;
with Servlet.Servlets;
package Servlet.Generic_Servlets is
pragma Preelaborate;
type Generic_Servlet is
abstract limited new Servlet.Servlets.Servlet
and Servlet.Configs.Servlet_Config with private;
overriding procedure Initialize
(Self : in out Generic_Servlet;
Config : not null access Standard.Servlet.Configs.Servlet_Config'Class);
-- Called by the servlet container to indicate to a servlet that the
-- servlet is being placed into service.
overriding function Get_Servlet_Config
(Self : Generic_Servlet)
return access Standard.Servlet.Configs.Servlet_Config'Class;
-- Returns a ServletConfig object, which contains initialization and
-- startup parameters for this servlet. The ServletConfig object returned
-- is the one passed to the init method.
overriding function Get_Servlet_Name
(Self : Generic_Servlet) return League.Strings.Universal_String;
-- Returns the name of this servlet instance. See
-- ServletConfig.getServletName().
overriding function Get_Servlet_Context
(Self : Generic_Servlet)
return not null access Servlet.Contexts.Servlet_Context'Class;
-- Returns a reference to the ServletContext in which the caller is
-- executing.
type Instantiation_Parameters is tagged limited null record;
not overriding function Instantiate
(Parameters : not null access Instantiation_Parameters'Class)
return Generic_Servlet is abstract;
private
type Generic_Servlet is
abstract limited new Servlet.Servlets.Servlet
and Servlet.Configs.Servlet_Config with
record
Config : access Servlet.Configs.Servlet_Config'Class;
end record;
end Servlet.Generic_Servlets;
|
AdaCore/training_material | Ada | 66 | ads | package PragmARC.Randomness with Pure is
end PragmARC.Randomness;
|
reznikmm/matreshka | Ada | 6,927 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.UML.Packages;
with AMF.Visitors.Standard_Profile_L2_Iterators;
with AMF.Visitors.Standard_Profile_L2_Visitors;
package body AMF.Internals.Standard_Profile_L2_Model_Libraries is
----------------------
-- Get_Base_Package --
----------------------
overriding function Get_Base_Package
(Self : not null access constant Standard_Profile_L2_Model_Library_Proxy)
return AMF.UML.Packages.UML_Package_Access is
begin
return
AMF.UML.Packages.UML_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Package
(Self.Element)));
end Get_Base_Package;
----------------------
-- Set_Base_Package --
----------------------
overriding procedure Set_Base_Package
(Self : not null access Standard_Profile_L2_Model_Library_Proxy;
To : AMF.UML.Packages.UML_Package_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Package
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Package;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Model_Library_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Enter_Model_Library
(AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Model_Library_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Leave_Model_Library
(AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Model_Library_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then
AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class
(Iterator).Visit_Model_Library
(Visitor,
AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.Standard_Profile_L2_Model_Libraries;
|
charlie5/dynamic_distributed_computing | Ada | 377 | adb | with
DDC.Boss,
Ada.Text_IO,
Ada.Exceptions;
procedure launch_DDC_Boss
is
use Ada.Text_IO,
Ada.Exceptions;
begin
DDC.Boss.calculate;
exception
when the_Error : others =>
put_Line ("Boss has *fatal* exception:");
put_Line (exception_Information (the_Error));
put_Line (exception_Message (the_Error));
end launch_DDC_Boss;
|
tum-ei-rcs/StratoX | Ada | 2,378 | ads | ------------------------------------------------------------------------------
-- --
-- SPARK LIBRARY COMPONENTS --
-- --
-- S P A R K . L O N G _ F L O A T _ A R I T H M E T I C _ L E M M A S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- SPARK 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. SPARK is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
pragma SPARK_Mode;
with SPARK.Floating_Point_Arithmetic_Lemmas;
pragma Elaborate_All (SPARK.Floating_Point_Arithmetic_Lemmas);
package SPARK.Long_Float_Arithmetic_Lemmas is new
SPARK.Floating_Point_Arithmetic_Lemmas (Long_Float, 2.0 ** 511);
|
reznikmm/matreshka | Ada | 3,729 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Form_Current_State_Attributes is
pragma Preelaborate;
type ODF_Form_Current_State_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Current_State_Attribute_Access is
access all ODF_Form_Current_State_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Current_State_Attributes;
|
onox/orka | Ada | 826 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with AUnit.Test_Suites;
package Test_SIMD_AVX_Shift_Emulation is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
end Test_SIMD_AVX_Shift_Emulation;
|
reznikmm/matreshka | Ada | 3,963 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Name_Attributes;
package Matreshka.ODF_Style.Name_Attributes is
type Style_Name_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Name_Attributes.ODF_Style_Name_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Name_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Name_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Name_Attributes;
|
zhmu/ananas | Ada | 6,087 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- SYSTEM.TASK_PRIMITIVES.OPERATIONS.SPECIFIC --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- 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 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a VxWorks version of this package where foreign threads are
-- recognized. The implementation is based on VxWorks taskVarLib.
separate (System.Task_Primitives.Operations)
package body Specific is
ERROR : constant STATUS := System.VxWorks.Ext.ERROR;
ATCB_Key : aliased System.Address := System.Null_Address;
-- Key used to find the Ada Task_Id associated with a thread
ATCB_Key_Addr : System.Address := ATCB_Key'Address;
pragma Export (Ada, ATCB_Key_Addr, "__gnat_ATCB_key_addr");
-- Exported to support the temporary AE653 task registration
-- implementation. This mechanism is used to minimize impact on other
-- targets.
Stack_Limit : aliased System.Address;
pragma Import (C, Stack_Limit, "__gnat_stack_limit");
type Set_Stack_Limit_Proc_Acc is access procedure;
pragma Convention (C, Set_Stack_Limit_Proc_Acc);
Set_Stack_Limit_Hook : Set_Stack_Limit_Proc_Acc;
pragma Import (C, Set_Stack_Limit_Hook, "__gnat_set_stack_limit_hook");
-- Procedure to be called when a task is created to set stack limit if
-- limit checking is used.
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean is
IERR : constant := -1;
begin
return taskVarGet (taskIdSelf, ATCB_Key'Access) /= IERR;
end Is_Valid_Task;
---------
-- Set --
---------
procedure Set (Self_Id : Task_Id) is
Result : STATUS;
begin
-- If argument is null, destroy task specific data, to make API
-- consistent with other platforms, and thus compatible with the
-- shared version of s-tpoaal.adb.
if Self_Id = null then
Result := taskVarDelete (taskIdSelf, ATCB_Key'Access);
pragma Assert (Result /= ERROR);
return;
end if;
if not Is_Valid_Task then
Result := taskVarAdd (Self_Id.Common.LL.Thread, ATCB_Key'Access);
pragma Assert (Result = OK);
if Stack_Check_Limits
and then Result /= ERROR
and then Set_Stack_Limit_Hook /= null
then
-- This will be initialized from taskInfoGet() once the task is
-- is running.
Result :=
taskVarAdd (Self_Id.Common.LL.Thread, Stack_Limit'Access);
pragma Assert (Result /= ERROR);
end if;
end if;
Result :=
taskVarSet
(Self_Id.Common.LL.Thread,
ATCB_Key'Access,
To_Address (Self_Id));
pragma Assert (Result /= ERROR);
end Set;
----------
-- Self --
----------
-- To make Ada tasks and C threads interoperate better, we have added some
-- functionality to Self. Suppose a C main program (with threads) calls an
-- Ada procedure and the Ada procedure calls the tasking runtime system.
-- Eventually, a call will be made to self. Since the call is not coming
-- from an Ada task, there will be no corresponding ATCB.
-- What we do in Self is to catch references that do not come from
-- recognized Ada tasks, and create an ATCB for the calling thread.
-- The new ATCB will be "detached" from the normal Ada task master
-- hierarchy, much like the existing implicitly created signal-server
-- tasks.
function Self return Task_Id is
Result : constant Task_Id := To_Task_Id (ATCB_Key);
begin
if Result /= null then
return Result;
else
-- If the value is Null then it is a non-Ada task
return Register_Foreign_Thread;
end if;
end Self;
end Specific;
|
reznikmm/matreshka | Ada | 4,704 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Last_Row_Start_Column_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Last_Row_Start_Column_Attribute_Node is
begin
return Self : Table_Last_Row_Start_Column_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Last_Row_Start_Column_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Last_Row_Start_Column_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Last_Row_Start_Column_Attribute,
Table_Last_Row_Start_Column_Attribute_Node'Tag);
end Matreshka.ODF_Table.Last_Row_Start_Column_Attributes;
|
Subsets and Splits