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 <vgodunko@gmail.com> -- -- 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 <vgodunko@gmail.com> -- -- 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 ayacc-info@ics.uci.edu -- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu -- -- 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 <reznikmm@gmail.com> -- -- 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 <vgodunko@gmail.com> -- -- 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 <aldomel@ix.netcom.com> 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;
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
4
Edit dataset card