repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
MinimSecure/unum-sdk
Ada
794
ads
-- Copyright 2010-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pack is procedure Print (I1 : Positive; I2 : Positive); end Pack;
Fabien-Chouteau/GESTE
Ada
1,299
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_SDL_stdinc_h; package SDL_SDL_endian_h is SDL_LIL_ENDIAN : constant := 1234; -- ../include/SDL/SDL_endian.h:37 SDL_BIG_ENDIAN : constant := 4321; -- ../include/SDL/SDL_endian.h:38 -- unsupported macro: SDL_BYTEORDER SDL_LIL_ENDIAN -- arg-macro: function SDL_SwapLE16 (X) -- return X; -- arg-macro: function SDL_SwapLE32 (X) -- return X; -- arg-macro: function SDL_SwapLE64 (X) -- return X; -- arg-macro: procedure SDL_SwapBE16 (X) -- SDL_Swap16(X) -- arg-macro: procedure SDL_SwapBE32 (X) -- SDL_Swap32(X) -- arg-macro: procedure SDL_SwapBE64 (X) -- SDL_Swap64(X) function SDL_Swap16 (x : SDL_SDL_stdinc_h.Uint16) return SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_endian.h:75 pragma Import (C, SDL_Swap16, "SDL_Swap16"); function SDL_Swap32 (x : SDL_SDL_stdinc_h.Uint32) return SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_endian.h:108 pragma Import (C, SDL_Swap32, "SDL_Swap32"); function SDL_Swap64 (x : SDL_SDL_stdinc_h.Uint64) return SDL_SDL_stdinc_h.Uint64; -- ../include/SDL/SDL_endian.h:144 pragma Import (C, SDL_Swap64, "SDL_Swap64"); end SDL_SDL_endian_h;
stcarrez/ada-util
Ada
1,670
adb
----------------------------------------------------------------------- -- util-listeners-observers -- Observers design pattern -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Listeners.Observers is -- ------------------------------ -- Notify the item passed in `Item` to the list of observers that have been registered -- in the `List`. -- ------------------------------ procedure Notify (List : in Util.Listeners.List; Item : in Element_Type) is procedure Update (Subscriber : in Util.Listeners.Listener_Access); procedure Update (Subscriber : in Util.Listeners.Listener_Access) is begin if Subscriber.all in Observer'Class then Observer'Class (Subscriber.all).Update (Item); end if; end Update; R : constant Util.Listeners.Listener_Arrays.Ref := List.Get; begin R.Iterate (Process => Update'Access); end Notify; end Util.Listeners.Observers;
mirror/ncurses
Ada
3,081
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses2.trace_set -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.2 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ procedure ncurses2.trace_set;
LiberatorUSA/GUCEF
Ada
7,141
adb
with interfaces.c.strings; package body agar.gui.surface is package cs renames interfaces.c.strings; package cbinds is function allocate (width : c.int; height : c.int; format : agar.gui.pixelformat.pixel_format_access_t; flags : flags_t) return surface_access_t; pragma import (c, allocate, "AG_SurfaceNew"); function std_rgb (width : c.unsigned; height : c.unsigned) return surface_access_t; pragma import (c, std_rgb, "agar_surface_std_rgb"); function std_rgba (width : c.unsigned; height : c.unsigned) return surface_access_t; pragma import (c, std_rgba, "agar_surface_std_rgba"); function indexed (width : c.unsigned; height : c.unsigned; bits_per_pixel : c.int; flags : flags_t) return surface_access_t; pragma import (c, indexed, "AG_SurfaceIndexed"); function rgb (width : c.unsigned; height : c.unsigned; bits_per_pixel : c.int; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t) return surface_access_t; pragma import (c, rgb, "AG_SurfaceRGB"); function rgba (width : c.unsigned; height : c.unsigned; bits_per_pixel : c.int; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t; amask : agar.core.types.uint32_t) return surface_access_t; pragma import (c, rgba, "AG_SurfaceRGBA"); function from_pixels_rgb (pixels : agar.core.types.void_ptr_t; width : c.unsigned; height : c.unsigned; bits_per_pixel : c.int; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t) return surface_access_t; pragma import (c, from_pixels_rgb, "AG_SurfaceFromPixelsRGB"); function from_pixels_rgba (pixels : agar.core.types.void_ptr_t; width : c.unsigned; height : c.unsigned; bits_per_pixel : c.int; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t; amask : agar.core.types.uint32_t) return surface_access_t; pragma import (c, from_pixels_rgba, "AG_SurfaceFromPixelsRGBA"); function from_bmp (file : cs.chars_ptr) return surface_access_t; pragma import (c, from_bmp, "AG_SurfaceFromBMP"); end cbinds; function allocate (width : positive; height : positive; format : agar.gui.pixelformat.pixel_format_access_t; flags : flags_t) return surface_access_t is begin return cbinds.allocate (width => c.int (width), height => c.int (height), format => format, flags => flags); end allocate; function std_rgb (width : positive; height : positive) return surface_access_t is begin return cbinds.std_rgb (width => c.unsigned (width), height => c.unsigned (height)); end std_rgb; function std_rgba (width : positive; height : positive) return surface_access_t is begin return cbinds.std_rgba (width => c.unsigned (width), height => c.unsigned (height)); end std_rgba; function indexed (width : positive; height : positive; bits_per_pixel : positive; flags : flags_t) return surface_access_t is begin return cbinds.indexed (width => c.unsigned (width), height => c.unsigned (height), bits_per_pixel => c.int (bits_per_pixel), flags => flags); end indexed; function rgb (width : positive; height : positive; bits_per_pixel : positive; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t) return surface_access_t is begin return cbinds.rgb (width => c.unsigned (width), height => c.unsigned (height), bits_per_pixel => c.int (bits_per_pixel), flags => flags, rmask => rmask, gmask => gmask, bmask => bmask); end rgb; function rgba (width : positive; height : positive; bits_per_pixel : positive; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t; amask : agar.core.types.uint32_t) return surface_access_t is begin return cbinds.rgba (width => c.unsigned (width), height => c.unsigned (height), bits_per_pixel => c.int (bits_per_pixel), flags => flags, rmask => rmask, gmask => gmask, bmask => bmask, amask => amask); end rgba; function from_pixels_rgb (pixels : agar.core.types.void_ptr_t; width : positive; height : positive; bits_per_pixel : positive; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t) return surface_access_t is begin return cbinds.from_pixels_rgb (pixels => pixels, width => c.unsigned (width), height => c.unsigned (height), bits_per_pixel => c.int (bits_per_pixel), flags => flags, rmask => rmask, gmask => gmask, bmask => bmask); end from_pixels_rgb; function from_pixels_rgba (pixels : agar.core.types.void_ptr_t; width : positive; height : positive; bits_per_pixel : positive; flags : flags_t; rmask : agar.core.types.uint32_t; gmask : agar.core.types.uint32_t; bmask : agar.core.types.uint32_t; amask : agar.core.types.uint32_t) return surface_access_t is begin return cbinds.from_pixels_rgba (pixels => pixels, width => c.unsigned (width), height => c.unsigned (height), bits_per_pixel => c.int (bits_per_pixel), flags => flags, rmask => rmask, gmask => gmask, bmask => bmask, amask => amask); end from_pixels_rgba; function from_bmp (file : string) return surface_access_t is ca_file : aliased c.char_array := c.to_c (file); begin return cbinds.from_bmp (cs.to_chars_ptr (ca_file'unchecked_access)); end from_bmp; end agar.gui.surface;
tum-ei-rcs/StratoX
Ada
2,887
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- A D A . E X C E P T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package body Ada.Exceptions is --------------------- -- Raise_Exception -- --------------------- procedure Raise_Exception (E : Exception_Id; Message : String := "") is pragma Unreferenced (E); procedure Last_Chance_Handler (Msg : System.Address; Line : Integer); pragma Import (C, Last_Chance_Handler, "__gnat_last_chance_handler"); pragma No_Return (Last_Chance_Handler); begin Last_Chance_Handler (Message'Address, 0); end Raise_Exception; end Ada.Exceptions;
sparre/aShell
Ada
3,098
ads
with Ada.Iterator_Interfaces, Ada.Directories, Ada.Containers.Vectors; private with Ada.Finalization; package Shell.Directory_Iteration is type Directory is tagged private with Default_Iterator => Iterate, Iterator_Element => Constant_Reference_Type, Constant_Indexing => Element_Value; function To_Directory (Path : in String) return Directory; function Path (Container : in Directory) return String; type Cursor is private; function Has_Element (Pos : Cursor) return Boolean; subtype Directory_Entry_Type is Ada.Directories.Directory_Entry_Type; type Constant_Reference_Type (Element : not null access constant Directory_Entry_Type) is private with Implicit_Dereference => Element; package Directory_Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element); function Iterate (Container : Directory) return Directory_Iterators.Forward_Iterator'Class; function Element_Value (Container : Directory; Pos : Cursor) return Constant_Reference_Type; private type Directory is tagged record Path : Unbounded_String; end record; type Constant_Reference_Type (Element : not null access constant Directory_Entry_Type) is null record; subtype Search_Type is Ada.Directories.Search_Type; type Search_Access is access all Search_Type; type Directory_Access is access all Directory; type Directory_Entry_Access is access all Directory_Entry_Type; package Entry_Vectors is new ada.Containers.Vectors (Index_Type => Positive, Element_Type => Directory_Entry_Access); type Entries is new Entry_Vectors.Vector with null record; -- Cursor -- type Cursor is record Container : Directory_Access; Search : Search_Access; Directory_Entry : Directory_Entry_Access; end record; No_Element : constant Cursor := Cursor' (Container => null, Search => null, Directory_Entry => null); -- Iterator -- type Iterator_State is record Entries : Directory_Iteration.Entries; -- Used to free the entries in Finalize. end record; type Iterator_State_Access is access all Iterator_State; type Iterator is new Ada.Finalization.Controlled and Directory_Iterators.Forward_Iterator with record Container : Directory_Access; Search : Search_Access; State : Iterator_State_Access; -- Allows modifying the Iterator state in functions. end record; overriding function First (Object : in Iterator) return Cursor; overriding function Next (Object : in Iterator; Position : in Cursor) return Cursor; overriding procedure Finalize (Object : in out Iterator); end Shell.Directory_Iteration;
reznikmm/matreshka
Ada
3,734
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Template_Name_Attributes is pragma Preelaborate; type ODF_Table_Template_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Template_Name_Attribute_Access is access all ODF_Table_Template_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Template_Name_Attributes;
reznikmm/matreshka
Ada
3,644
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Dr3d_Cube_Elements is pragma Preelaborate; type ODF_Dr3d_Cube is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Dr3d_Cube_Access is access all ODF_Dr3d_Cube'Class with Storage_Size => 0; end ODF.DOM.Dr3d_Cube_Elements;
Tim-Tom/scratch
Ada
976
adb
with Ada.Command_Line; with Trie; procedure SevenWords is words : constant Trie.Trie := Trie.Make_Trie("../american-english-filtered"); argument_length : Natural := 0; fragment_ends : Trie.Fragment_Endpoint_Array(1 .. Ada.Command_Line.Argument_Count); begin if Ada.Command_Line.Argument_Count = 0 then raise Constraint_Error; end if; for index in 1 .. Ada.Command_Line.Argument_Count loop fragment_ends(index).first := argument_length + 1; argument_length := argument_length + Ada.Command_Line.Argument(index)'Length; fragment_ends(index).last := argument_length; end loop; declare argument_string : String(1 .. argument_length); begin for index in 1 .. Ada.Command_Line.Argument_Count loop argument_string(fragment_ends(index).first .. fragment_ends(index).last) := Ada.Command_Line.Argument(index); end loop; Trie.find_words(words, argument_string, fragment_ends); end; end SevenWords;
melwyncarlo/ProjectEuler
Ada
303
adb
with Ada.Text_IO; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A080 is use Ada.Text_IO; use Ada.Integer_Text_IO; Str : constant String (1 .. 12) := "Hello World "; Num : constant Integer := 2021; begin Put (Str); Put (Num, Width => 0); end A080;
apple-oss-distributions/old_ncurses
Ada
3,712
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Helpers -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Sample.Explanation; use Sample.Explanation; -- This package contains some conveniant helper routines used throughout -- this example. -- package body Sample.Helpers is procedure Window_Title (Win : in Window; Title : in String) is Height : Line_Count; Width : Column_Count; Pos : Column_Position := 0; begin Get_Size (Win, Height, Width); if Title'Length < Width then Pos := (Width - Title'Length) / 2; end if; Add (Win, 0, Pos, Title); end Window_Title; procedure Not_Implemented is begin Explain ("NOTIMPL"); end Not_Implemented; end Sample.Helpers;
caqg/linux-home
Ada
4,375
ads
-- Abstract : -- -- Common utilities for Gen_Emacs_Wisi_*_Parse -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with Ada.Strings.Unbounded; with System; with Wisi; with WisiToken.Parse.LR.Parser; package Emacs_Wisi_Common_Parse is Protocol_Version : constant String := "3"; -- Protocol_Version defines the data sent between elisp and the -- background process, except for the language-specific parameters, -- which are defined by the Language_Protocol_Version parameter to -- Parse_Stream, below. -- -- This value must match wisi-process-parse.el -- wisi-process-parse-protocol-version. -- -- See wisi-process-parse.el functions, and this package body, for -- the implementation of the protocol. -- -- Only changes once per wisi release. Increment as soon as required, -- record new version in NEWS-wisi.text. Prompt : constant String := ";;> "; Protocol_Error : exception; Finish : exception; procedure Usage (Name : in String); procedure Read_Input (A : System.Address; N : Integer); function Get_Command_Length return Integer; function Get_String (Source : in String; Last : in out Integer) return String; function Get_Integer (Source : in String; Last : in out Integer) return Integer; type Process_Start_Params is record Recover_Log_File_Name : Ada.Strings.Unbounded.Unbounded_String; -- log enabled if non-empty. end record; function Get_Process_Start_Params return Process_Start_Params; -- Get from Ada.Command_Line. Handles --help by outputing help, -- raising Finish. type Parse_Params is record Post_Parse_Action : Wisi.Post_Parse_Action_Type; Source_File_Name : Ada.Strings.Unbounded.Unbounded_String; Begin_Byte_Pos : Integer; -- Source file byte position of first char sent; start parse here. End_Byte_Pos : Integer; -- Byte position of last char sent. Goal_Byte_Pos : Integer; -- Byte position of end of desired parse region; terminate parse at -- or after here. Begin_Char_Pos : WisiToken.Buffer_Pos; -- Char position of first char sent. Begin_Line : WisiToken.Line_Number_Type; End_Line : WisiToken.Line_Number_Type; -- Line number of line containing Begin_Byte_Pos, End_Byte_Pos Begin_Indent : Integer; -- Indentation of Line_Begin Partial_Parse_Active : Boolean; Debug_Mode : Boolean; Parse_Verbosity : Integer; McKenzie_Verbosity : Integer; Action_Verbosity : Integer; McKenzie_Disable : Integer; Task_Count : Integer; Check_Limit : Integer; Enqueue_Limit : Integer; Max_Parallel : Integer; Byte_Count : Integer; -- Count of bytes of source file sent. end record; function Get_Parse_Params (Command_Line : in String; Last : in out Integer) return Parse_Params; procedure Parse_Stream (Name : in String; Language_Protocol_Version : in String; Partial_Parse_Active : in out Boolean; Params : in Process_Start_Params; Parser : in out WisiToken.Parse.LR.Parser.Parser; Parse_Data : in out Wisi.Parse_Data_Type'Class; Descriptor : in WisiToken.Descriptor); end Emacs_Wisi_Common_Parse;
aherd2985/Amass
Ada
1,842
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "BinaryEdge" type = "api" function start() setratelimit(1) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end local hdrs={ ['X-KEY']=c["key"], ['Content-Type']="application/json", } for i=1,500 do local resp local vurl = apiurl(domain, i) -- Check if the response data is in the graph database if (cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(vurl, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request(ctx, { url=vurl, headers=hdrs, }) if (err ~= nil and err ~= "") then return end if (cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(vurl, resp) end end local d = json.decode(resp) if (d == nil or #(d.events) == 0) then return end for i, v in pairs(d.events) do newname(ctx, v) end if (d.page > 500 or d.page > (d.total / d.pagesize)) then return end checkratelimit() end end function apiurl(domain, pagenum) return "https://api.binaryedge.io/v2/query/domains/subdomain/" .. domain .. "?page=" .. pagenum end
charlie5/cBound
Ada
1,338
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C.Strings; with Interfaces.C.Pointers; package TensorFlow_C.TF_StringView is -- Item -- type Item is record data : aliased Interfaces.C.Strings.chars_ptr; len : aliased Interfaces.C.size_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased TensorFlow_C.TF_StringView.Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => TensorFlow_C.TF_StringView.Item, Element_Array => TensorFlow_C.TF_StringView.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased TensorFlow_C.TF_StringView.Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => TensorFlow_C.TF_StringView.Pointer, Element_Array => TensorFlow_C.TF_StringView.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end TensorFlow_C.TF_StringView;
AdaCore/Ada_Drivers_Library
Ada
6,778
ads
-- This spec has been automatically generated from STM32F7x9.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.NVIC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ICTR_INTLINESNUM_Field is HAL.UInt4; -- Interrupt Controller Type Register type ICTR_Register is record -- Read-only. Total number of interrupt lines in groups INTLINESNUM : ICTR_INTLINESNUM_Field; -- unspecified Reserved_4_31 : HAL.UInt28; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ICTR_Register use record INTLINESNUM at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- IPR_IPR_N array element subtype IPR_IPR_N_Element is HAL.UInt8; -- IPR_IPR_N array type IPR_IPR_N_Field_Array is array (0 .. 3) of IPR_IPR_N_Element with Component_Size => 8, Size => 32; -- Interrupt Priority Register type IPR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- IPR_N as a value Val : HAL.UInt32; when True => -- IPR_N as an array Arr : IPR_IPR_N_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IPR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype STIR_INTID_Field is HAL.UInt9; -- Software Triggered Interrupt Register type STIR_Register is record -- Write-only. interrupt to be triggered INTID : STIR_INTID_Field := 16#0#; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for STIR_Register use record INTID at 0 range 0 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Nested Vectored Interrupt Controller type NVIC_Peripheral is record -- Interrupt Controller Type Register ICTR : aliased ICTR_Register; -- Interrupt Set-Enable Register ISER0 : aliased HAL.UInt32; -- Interrupt Set-Enable Register ISER1 : aliased HAL.UInt32; -- Interrupt Set-Enable Register ISER2 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER0 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER1 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER2 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR0 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR1 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR2 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR0 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR1 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR2 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR0 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR1 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR2 : aliased HAL.UInt32; -- Interrupt Priority Register IPR0 : aliased IPR_Register; -- Interrupt Priority Register IPR1 : aliased IPR_Register; -- Interrupt Priority Register IPR2 : aliased IPR_Register; -- Interrupt Priority Register IPR3 : aliased IPR_Register; -- Interrupt Priority Register IPR4 : aliased IPR_Register; -- Interrupt Priority Register IPR5 : aliased IPR_Register; -- Interrupt Priority Register IPR6 : aliased IPR_Register; -- Interrupt Priority Register IPR7 : aliased IPR_Register; -- Interrupt Priority Register IPR8 : aliased IPR_Register; -- Interrupt Priority Register IPR9 : aliased IPR_Register; -- Interrupt Priority Register IPR10 : aliased IPR_Register; -- Interrupt Priority Register IPR11 : aliased IPR_Register; -- Interrupt Priority Register IPR12 : aliased IPR_Register; -- Interrupt Priority Register IPR13 : aliased IPR_Register; -- Interrupt Priority Register IPR14 : aliased IPR_Register; -- Interrupt Priority Register IPR15 : aliased IPR_Register; -- Interrupt Priority Register IPR16 : aliased IPR_Register; -- Interrupt Priority Register IPR17 : aliased IPR_Register; -- Interrupt Priority Register IPR18 : aliased IPR_Register; -- Interrupt Priority Register IPR19 : aliased IPR_Register; -- Interrupt Priority Register IPR20 : aliased IPR_Register; -- Software Triggered Interrupt Register STIR : aliased STIR_Register; end record with Volatile; for NVIC_Peripheral use record ICTR at 16#4# range 0 .. 31; ISER0 at 16#100# range 0 .. 31; ISER1 at 16#104# range 0 .. 31; ISER2 at 16#108# range 0 .. 31; ICER0 at 16#180# range 0 .. 31; ICER1 at 16#184# range 0 .. 31; ICER2 at 16#188# range 0 .. 31; ISPR0 at 16#200# range 0 .. 31; ISPR1 at 16#204# range 0 .. 31; ISPR2 at 16#208# range 0 .. 31; ICPR0 at 16#280# range 0 .. 31; ICPR1 at 16#284# range 0 .. 31; ICPR2 at 16#288# range 0 .. 31; IABR0 at 16#300# range 0 .. 31; IABR1 at 16#304# range 0 .. 31; IABR2 at 16#308# range 0 .. 31; IPR0 at 16#400# range 0 .. 31; IPR1 at 16#404# range 0 .. 31; IPR2 at 16#408# range 0 .. 31; IPR3 at 16#40C# range 0 .. 31; IPR4 at 16#410# range 0 .. 31; IPR5 at 16#414# range 0 .. 31; IPR6 at 16#418# range 0 .. 31; IPR7 at 16#41C# range 0 .. 31; IPR8 at 16#420# range 0 .. 31; IPR9 at 16#424# range 0 .. 31; IPR10 at 16#428# range 0 .. 31; IPR11 at 16#42C# range 0 .. 31; IPR12 at 16#430# range 0 .. 31; IPR13 at 16#434# range 0 .. 31; IPR14 at 16#438# range 0 .. 31; IPR15 at 16#43C# range 0 .. 31; IPR16 at 16#440# range 0 .. 31; IPR17 at 16#444# range 0 .. 31; IPR18 at 16#448# range 0 .. 31; IPR19 at 16#44C# range 0 .. 31; IPR20 at 16#450# range 0 .. 31; STIR at 16#F00# range 0 .. 31; end record; -- Nested Vectored Interrupt Controller NVIC_Periph : aliased NVIC_Peripheral with Import, Address => System'To_Address (16#E000E000#); end STM32_SVD.NVIC;
AdaCore/libadalang
Ada
114
ads
limited with Foo; package Bar is type Bar_Type is record F : access Foo_Type; end record; end Bar;
caqg/linux-home
Ada
14,049
ads
------------------------------------------------------------------------------ -- G P S -- -- -- -- Copyright (C) 2001-2016, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with this software; see file -- -- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- -- of the license. -- ------------------------------------------------------------------------------ -- This package provides a set of subprograms for manipulating and parsing -- strings. with GNAT.Strings; with Interfaces.C.Strings; with Basic_Types; use Basic_Types; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package String_Utils is function "+" (S : String) return Unbounded_String renames To_Unbounded_String; function "+" (S : Unbounded_String) return String renames To_String; -- Utility conversion operators from String to Unbounded_String function Hex_Value (Hex : String) return Natural; -- Return the value for the hexadecimal number Hex. Raises -- Constraint_Error is Hex is not an hexadecimal number. procedure Skip_To_Blank (Type_Str : String; Index : in out Natural); -- Skip to the next blank character procedure Skip_To_Index (Buffer : String; Columns : out Visible_Column_Type; Index_In_Line : String_Index_Type; Index : in out String_Index_Type; Tab_Width : Positive := 8); procedure Skip_To_Index (Buffer : Unbounded_String; Columns : out Visible_Column_Type; Index_In_Line : String_Index_Type; Index : in out String_Index_Type; Tab_Width : Positive := 8); -- Assuming Index points to the begining of a line, move the index by -- "Index_In_Line" characters, and give the new column value. procedure Skip_Hexa_Digit (Type_Str : String; Index : in out Natural); -- Move Index to the first character that can not be part of an hexadecimal -- digit. Note that an hexadecimal digit can optionally start with '0x', -- which is the only case where x is recognized as part of the digit. procedure Skip_To_Char (Type_Str : String; Index : in out Natural; Char : Character; Step : Integer := 1); procedure Skip_To_Char (Type_Str : Unbounded_String; Index : in out Natural; Char : Character; Step : Integer := 1); -- Skip every character up to the first occurence of Char in the string. -- If no occurrence found, then Index is set over Type_Str'Last. procedure Skip_Word (Type_Str : String; Index : in out Natural; Step : Integer := 1); -- Skip the word starting at Index (at least one character, even if there -- is no word). -- Currently, a word is defined as any string made of alphanumeric -- character or underscore. procedure Skip_CPP_Token (Type_Str : String; Index : in out Natural; Step : Integer := 1); -- Skip the cpp token starting at Index (at least one character, even if -- there is no cpp token). -- Currently, a cpp token is defined as any string made of alphanumeric -- character, underscore or period. function Tab_Width return Positive; pragma Inline (Tab_Width); -- Default value of tab width in the text editor (current value is 8) function Lines_Count (Text : String) return Natural; -- Return the number of lines in Text function Blank_Slice (Count : Integer; Use_Tabs : Boolean := False; Tab_Width : Positive := 8) return String; -- Return a string representing count blanks. -- If Use_Tabs is True, use ASCII.HT characters as much as possible, -- otherwise use only spaces. -- Return a null string if Count is negative. function Is_Blank (C : Character) return Boolean; -- Return True if C is a blank character: CR, LF, HT or ' ' procedure Next_Line (Buffer : String; P : Natural; Next : out Natural; Success : out Boolean); -- Return the start of the next line in Next or Buffer'Last if the end of -- the buffer is reached. -- Success is set to True if a new line was found, false otherwise (end of -- buffer reached). procedure Parse_Num (Type_Str : String; Index : in out Natural; Result : out Long_Integer); -- Parse the integer found at position Index in Type_Str. -- Index is set to the position of the first character that does not -- belong to the integer. function Looking_At (Type_Str : String; Index : Natural; Substring : String) return Boolean; -- Return True if the characters starting at Index in Type_Str are -- equivalent to Substring. procedure Parse_Cst_String (Type_Str : String; Index : in out Natural; Str : out String; Str_Last : out Natural; Backslash_Special : Boolean := True); -- Parse the string pointed to by Index, and copy the result in Str. -- Index must point to the opening " character, and will be set to -- point after the closing " character. -- Special characters, as output by gdb (["0a"]) are also interpreted -- and converted to the equivalent Character value. -- Str must be long enough to contain the string, not check is done. As a -- special case, if Str'Length = 0 then no attempt is done to fill up -- the string, and only Length is computed. Str_Last is set to the last -- meaningful character in Str. -- -- Index is set to the number of characters parsed in the string. procedure Skip_Simple_Value (Type_Str : String; Index : in out Natural; Array_Item_Separator : Character := ','; End_Of_Array : Character := ')'; Repeat_Item_Start : Character := '<'); -- Skip the value of a simple value ("65 'A'" for instance). -- This stops at the first special character. -- -- Array_Item_Separator is the separator in an array value (ie "5, 2, 3"). -- End_Of_Array is the array that indicates the end of an array value, as -- in "((1, 2), (3, 4))". -- Repeat_Item_Start if the character that starts a repeat statements, as -- in "<repeats .. times>" function Reduce (S : String; Max_Length : Positive := Positive'Last; Continuation : String := "...") return String; -- Replace in string S all ASCII.LF and ASCII.HT characters with a space, -- and replace multiple spaces with a single one. Return the resulting -- string with at most Max_Length character including the continuation -- characters. S should be encoded in UTF-8. function Krunch (S : String; Max_String_Length : Positive := 20) return String; -- If String is less than Max_String_Length characters long, return it, -- otherwise return a krunched string no longer than Max_String_Length. procedure Strip_CR (Text : in out String; Last : out Integer; CR_Found : out Boolean); -- Same as above, but works on Text, and more efficient -- Text (Text'First .. Last) contains the new result. -- CR_Found is set to True if a CR was found in Text. procedure Strip_CR_And_NUL (Text : in out String; Last : out Integer; CR_Found : out Boolean; NUL_Found : out Boolean; Trailing_Space_Found : out Boolean); -- Same as Strip_CR, and strip also ASCII.NUL characters -- Note that CR chars alone are not replaced by LF chars. -- Also check if Text has trailing spaces in a line. function Strip_Ending_Linebreaks (Text : String) return String; -- Return a version of Text after stripping all ending CR and LF -- characters. function Do_Tab_Expansion (Text : String; Tab_Size : Integer) return String; -- Return a version of Text after all tabs have been correctly expanded -- depending on the value of Tab_Size. -- This function works correctly with multiple-line strings. function Strip_Quotes (S : String) return String; -- Remove the quotes and the spaces at the beginning and end of S function Strip_Single_Underscores (S : String) return String; -- Return S stripped of single underscores, and with multiple underscores -- concatenated into one. -- This is used to process menu shortcuts, for example -- Strip_Single_Underscores ("/_Project/C_lean") returns "/Project/Clean" function Image (N : Integer) return String; -- Create a string image of the given Integer function Safe_Value (S : String; Default : Integer := 1) return Integer; -- Convert S to a Natural, making sure there is no exception raised. -- If S doesn't contain a valid number, Default is returned. function Number_Of_Digits (N : Integer) return Natural; -- Return the number of digits for the given Integer number; function Is_Entity_Letter (Char : Wide_Wide_Character) return Boolean; pragma Inline (Is_Entity_Letter); -- Return True if the given letter is a valid letter for an entity name -- (ie if the letter is either alphanumeric or an '_'). function Is_Operator_Letter (Char : Wide_Wide_Character) return Boolean; -- Return True if the given letter is a valid operator function Is_File_Letter (Char : Wide_Wide_Character) return Boolean; pragma Inline (Is_File_Letter); -- Return True if the given letter is a valid letter for a file name. procedure Replace (S : in out GNAT.Strings.String_Access; Value : String); -- Set S to Value, free previous content if any procedure Replace (S : in out GNAT.Strings.String_Access; Value : GNAT.Strings.String_Access); -- Idem, but does nothing if Value is null function Has_Include_Directive (Str : String) return Boolean; -- Return True is Str contains an #include directive ------------------- -- Argument_List -- ------------------- function Clone (List : GNAT.Strings.String_List) return GNAT.Strings.String_List; -- Return a deep-copy of List. The returned value must be freed by the -- caller. procedure Append (List : in out GNAT.Strings.String_List_Access; List2 : GNAT.Strings.String_List); procedure Append (List : in out GNAT.Strings.String_List_Access; Item : String); -- Append all the strings in List2 to the end of List. -- The strings in List2 are not duplicated. -- List might be null initially. --------------------------- -- C String manipulation -- --------------------------- procedure Copy_String (Item : Interfaces.C.Strings.chars_ptr; Str : out String; Len : Natural); -- Copy Len characters from Item to Str ---------------------------- -- Arguments manipulation -- ---------------------------- function Protect (S : String; Protect_Quotes : Boolean := True; Protect_Spaces : Boolean := False; Protect_Backslashes : Boolean := True) return String; -- Escape special characters in S. -- Quotes are only escaped when Protect_Quotes is true. -- Spaces are only escaped when Protect_Spaces is true. function Unprotect (S : String) return String; -- Unprotect an argument: remove the leading and ending '"', -- and un-escape the "\" when necessary. function Unquote (S : String) return String; -- Remove the leading and ending '"' if present function Revert (S : String; Separator : String := ".") return String; -- Given a string S composed of names separated with Separator -- (e.g. Put_Line.Text_IO.Ada), return the names reversed -- (e.g. Ada.Text_IO.Put_Line). ---------------------- -- URL manipulation -- ---------------------- function URL_Decode (URL : String) return String; -- Decode URL into a regular string. Many characters are forbiden into an -- URL and needs to be encoded. A character is encoded by %XY where XY is -- the character's ASCII hexadecimal code. For example a space is encoded -- as %20. function Compare (A, B : String) return Integer; function Compare (A, B : Integer) return Integer; -- Return -1 if A<B, 1 if A>B and 0 otherwise. This routine is useful for -- model specific sorting. The second version does the same comparing -- integers. Even if not using string, it is better to keep this routine -- next to the compare based on strings. ---------- -- Hash -- ---------- generic type Header_Num is range <>; function Hash (Key : String) return Header_Num; -- A generic hashing function working on String keys generic type Header_Num is range <>; function Case_Insensitive_Hash (Key : String) return Header_Num; -- A generic hashing function working on case insensitive String keys private pragma Inline (Is_Blank); pragma Inline (Looking_At); pragma Inline (Skip_To_Char); pragma Inline (Copy_String); pragma Inline (Replace); pragma Inline (Compare); end String_Utils;
jhumphry/PRNG_Zoo
Ada
5,159
adb
-- Copyright (c) 2014 - 2015, 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. package body PRNG_Zoo.Linear_Congruential is ----------------- -- Generic_LCG -- ----------------- package body Generic_LCG is ----------- -- Reset -- ----------- procedure Reset (G: in out LCG; S: in U64) is begin G.s := S; end Reset; -------------- -- Generate -- -------------- function Generate (G: in out LCG) return U64 is begin G.s := (G.s * Multiplier + Increment) mod Modulus; return G.s; end Generate; end Generic_LCG; ------------------------ -- Generic_LCG_32Only -- ------------------------ package body Generic_LCG_32Only is ----------- -- Reset -- ----------- procedure Reset (G: in out LCG_32Only; S: in U64) is begin G.s := U32(S and 16#FFFFFFFF#); end Reset; -------------- -- Generate -- -------------- function Generate (G: in out LCG_32Only) return U32 is begin G.s := (G.s * Multiplier + Increment) mod Modulus; return G.s; end Generate; end Generic_LCG_32Only; ----------------- -- Constructor -- ----------------- function Constructor(Params : not null access PRNG_Parameters'Class) return LCG is P : LCG_Parameters; begin if Params.all in LCG_Parameters then P := LCG_Parameters(Params.all); return LCG'(Modulus => P.Modulus, Multiplier => P.Multiplier, Increment => P.Increment, Usable_Width => P.Usable_Width, s => P.s); elsif Params.Contains("Modulus") and Params.Contains("Multiplier") and Params.Contains("Increment") and Params.Contains("Usable_Width") then return LCG'(Modulus => Params.Parameter("Modulus"), Multiplier => Params.Parameter("Multiplier"), Increment => Params.Parameter("Increment"), Usable_Width => Params.Parameter("Usable_Width"), s => 1); else raise Invalid_Parameters with "Must specify Modulus, Multiplier, Increment and Usable_Width for LCG generator"; end if; end Constructor; ----------- -- Reset -- ----------- procedure Reset (G: in out LCG; S: in U64) is begin G.s := S; end Reset; -------------- -- Generate -- -------------- function Generate (G: in out LCG) return U64 is begin G.s := (G.s * G.Multiplier + G.Increment) mod G.Modulus; return G.s; end Generate; ----------------- -- Constructor -- ----------------- function Constructor(Params : not null access PRNG_Parameters'Class) return LCG_32Only is P : LCG_32Only_Parameters; begin if Params.all in LCG_32Only_Parameters then P := LCG_32Only_Parameters(Params.all); return LCG_32Only'(Modulus => P.Modulus, Multiplier => P.Multiplier, Increment => P.Increment, Usable_Width => P.Usable_Width, s => P.s); elsif Params.Contains("Modulus") and Params.Contains("Multiplier") and Params.Contains("Increment") and Params.Contains("Usable_Width") then return LCG_32Only'(Modulus => U32(U64'(Params.Parameter("Modulus"))), Multiplier => U32(U64'(Params.Parameter("Multiplier"))), Increment => U32(U64'(Params.Parameter("Increment"))), Usable_Width => Params.Parameter("Usable_Width"), s => 1); else raise Invalid_Parameters with "Must specify Modulus, Multiplier, Increment and Usable_Width for LCG32 generator"; end if; end Constructor; ----------- -- Reset -- ----------- procedure Reset (G: in out LCG_32Only; S: in U64) is begin G.s := U32(S and 16#FFFFFFFF#); end Reset; -------------- -- Generate -- -------------- function Generate (G: in out LCG_32Only) return U32 is begin G.s := (G.s * G.Multiplier + G.Increment) mod G.Modulus; return G.s; end Generate; end PRNG_Zoo.Linear_Congruential;
AaronC98/PlaneSystem
Ada
8,600
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2014, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Calendar; with Ada.Strings.Unbounded; with SOAP.Types; package SOAP.Parameters is use Ada.Strings.Unbounded; Data_Error : exception renames Types.Data_Error; Max_Parameters : constant := 50; -- This is the maximum number of parameters supported by this -- implementation. type List is private; function Argument_Count (P : List) return Natural with Post => Argument_Count'Result <= Max_Parameters; -- Returns the number of parameters in P function Argument (P : List; Name : String) return Types.Object'Class; -- Returns parameters named Name in P. Raises Types.Data_Error if not -- found. function Argument (P : List; N : Positive) return Types.Object'Class; -- Returns Nth parameters in P. Raises Types.Data_Error if not found function Exist (P : List; Name : String) return Boolean; -- Returns True if parameter named Name exist in P and False otherwise function Get (P : List; Name : String) return Types.Long with Inline; -- Returns parameter named Name in P as a Long value. Raises -- Types.Data_Error if this parameter does not exist or is not a Long. function Get (P : List; Name : String) return Integer with Inline; -- Returns parameter named Name in P as an Integer value. Raises -- Types.Data_Error if this parameter does not exist or is not an Integer. function Get (P : List; Name : String) return Types.Short with Inline; -- Returns parameter named Name in P as a Short value. Raises -- Types.Data_Error if this parameter does not exist or is not an Short. function Get (P : List; Name : String) return Types.Byte with Inline; -- Returns parameter named Name in P as a Byte value. Raises -- Types.Data_Error if this parameter does not exist or is not a Byte. function Get (P : List; Name : String) return Float with Inline; -- Returns parameter named Name in P as a Float value. Raises -- Types.Data_Error if this parameter does not exist or is not a Float. function Get (P : List; Name : String) return Long_Float with Inline; -- Returns parameter named Name in P as a Float value. Raises -- Types.Data_Error if this parameter does not exist or is not a Double. function Get (P : List; Name : String) return String with Inline; -- Returns parameter named Name in P as a String value. Raises -- Types.Data_Error if this parameter does not exist or is not a String. function Get (P : List; Name : String) return Unbounded_String with Inline; -- Idem as above, but return an Unbounded_String function Get (P : List; Name : String) return Boolean with Inline; -- Returns parameter named Name in P as a Boolean value. Raises -- Types.Data_Error if this parameter does not exist or is not a Boolean. function Get (P : List; Name : String) return Ada.Calendar.Time with Inline; -- Returns parameter named Name in P as a Time value. Raises -- Types.Data_Error if this parameter does not exist or is not a time. function Get (P : List; Name : String) return Types.Unsigned_Long with Inline; -- Returns parameter named Name in P as a Unsigned_Long value. Raises -- Types.Data_Error if this parameter does not exist or is not an -- Unsigned_Long. function Get (P : List; Name : String) return Types.Unsigned_Int with Inline; -- Returns parameter named Name in P as a Unsigned_Int value. Raises -- Types.Data_Error if this parameter does not exist or is not an -- Unsigned_Int. function Get (P : List; Name : String) return Types.Unsigned_Short with Inline; -- Returns parameter named Name in P as a Unsigned_Short value. Raises -- Types.Data_Error if this parameter does not exist or is not an -- Unsigned_Short. function Get (P : List; Name : String) return Types.Unsigned_Byte with Inline; -- Returns parameter named Name in P as a Unsigned_Byte value. Raises -- Types.Data_Error if this parameter does not exist or is not an -- Unsigned_Byte. function Get (P : List; Name : String) return Types.SOAP_Base64 with Inline; -- Returns parameter named Name in P as a SOAP Base64 value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Base64. function Get (P : List; Name : String) return Types.SOAP_Record with Inline; -- Returns parameter named Name in P as a SOAP Struct value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Struct. function Get (P : List; Name : String) return Types.SOAP_Array with Inline; -- Returns parameter named Name in P as a SOAP Array value. Raises -- Types.Data_Error if this parameter does not exist or is not a SOAP -- Array. ------------------ -- Constructors -- ------------------ function "&" (P : List; O : Types.Object'Class) return List with Post => Argument_Count ("&"'Result) = Argument_Count (P) + 1; function "+" (O : Types.Object'Class) return List with Post => Argument_Count ("+"'Result) = 1; ---------------- -- Validation -- ---------------- procedure Check (P : List; N : Natural); -- Checks that there is exactly N parameters or raise Types.Data_Error procedure Check_Integer (P : List; Name : String); -- Checks that parameter named Name exist and is an Integer value procedure Check_Float (P : List; Name : String); -- Checks that parameter named Name exist and is a Float value procedure Check_Boolean (P : List; Name : String); -- Checks that parameter named Name exist and is a Boolean value procedure Check_Time_Instant (P : List; Name : String); -- Checks that parameter named Name exist and is a Time_Instant value procedure Check_Base64 (P : List; Name : String); -- Checks that parameter named Name exist and is a Base64 value procedure Check_Null (P : List; Name : String); -- Checks that parameter named Name exist and is a Null value procedure Check_Record (P : List; Name : String); -- Checks that parameter named Name exist and is a Record value procedure Check_Array (P : List; Name : String); -- Checks that parameter named Name exist and is an Array value private type List is record V : Types.Object_Set (1 .. Max_Parameters); N : Natural := 0; end record; end SOAP.Parameters;
etorri/protobuf-ada
Ada
3,981
ads
pragma Ada_2012; with Ada.Streams.Stream_IO; with Protocol_Buffers.IO.Coded_Output_Stream; with Protocol_Buffers.IO.Coded_Input_Stream; with Protocol_Buffers.Wire_Format; with Ada.Unchecked_Deallocation; with Ada.Finalization; with Ada.Containers.Vectors; package Protocol_Buffers.Message is type Instance is abstract new Ada.Finalization.Controlled with null record; type Instance_Access is access all Instance'Class; package Message_Vector is new Ada.Containers.Vectors (Protocol_Buffers.Wire_Format.PB_Object_Size, Instance_Access); procedure Clear (The_Message : in out Message.Instance) is abstract; procedure Serialize_To_Output_Stream (The_Message : in out Message.Instance'Class; Output_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Serialize_To_Coded_Output_Stream (The_Message : in out Message.Instance'Class; The_Coded_Output_Stream : in out Protocol_Buffers.IO.Coded_Output_Stream.Instance); procedure Serialize_Partial_To_Output_Stream (The_Message : in out Message.Instance'Class; Output_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Serialize_Partial_To_Coded_Output_Stream (The_Message : in out Message.Instance'Class; The_Coded_Output_Stream : in out Protocol_Buffers.IO.Coded_Output_Stream.Instance); procedure Serialize_With_Cached_Sizes (The_Message : in Message.Instance; The_Coded_Output_Stream : in Protocol_Buffers.IO.Coded_Output_Stream.Instance) is abstract; procedure Parse_From_Input_Stream (The_Message : in out Message.Instance'Class; Input_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Parse_From_Coded_Input_Stream (The_Message : in out Message.Instance'Class; The_Coded_Input_Stream : in out Protocol_Buffers.IO.Coded_Input_Stream.Instance); procedure Parse_Partial_From_Input_Stream (The_Message : in out Message.Instance'Class; Input_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Parse_Partial_From_Coded_Input_Stream (The_Message : in out Message.Instance'Class; The_Coded_Input_Stream : in out Protocol_Buffers.IO.Coded_Input_Stream.Instance); procedure Merge_From_Input_Stream (The_Message : in out Message.Instance'Class; Input_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Merge_From_Coded_Input_Stream (The_Message : in out Message.Instance'Class; The_Coded_Input_Stream : in out Protocol_Buffers.IO.Coded_Input_Stream.Instance); procedure Merge_Partial_From_Input_Stream (The_Message : in out Message.Instance'Class; Input_Stream : not null access Ada.Streams.Root_Stream_Type'Class); procedure Merge_Partial_From_Coded_Input_Stream (The_Message : in out Message.Instance; The_Coded_Input_Stream : in out Protocol_Buffers.IO.Coded_Input_Stream.Instance) is abstract; procedure Merge (To : in out Message.Instance; From : in Message.Instance) is abstract; procedure Copy (To : in out Message.Instance; From : in Message.Instance) is abstract; function Get_Type_Name (The_Message : in Message.Instance) return Protocol_Buffers.Wire_Format.PB_String is abstract; function Byte_Size (The_Message : in out Message.Instance) return Protocol_Buffers.Wire_Format.PB_Object_Size is abstract; function Get_Cached_Size (The_Message : in Message.Instance) return Protocol_Buffers.Wire_Format.PB_Object_Size is abstract; function Is_Initialized (The_Message : in Message.Instance) return Boolean is abstract; procedure Free is new Ada.Unchecked_Deallocation (Instance'Class, Instance_Access); end Protocol_Buffers.Message;
reznikmm/matreshka
Ada
4,608
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Direction_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Direction_Attribute_Node is begin return Self : Table_Direction_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Direction_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Direction_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Direction_Attribute, Table_Direction_Attribute_Node'Tag); end Matreshka.ODF_Table.Direction_Attributes;
reznikmm/matreshka
Ada
48
ads
package Server.Servlets is end Server.Servlets;
reznikmm/matreshka
Ada
54,893
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ package body AMF.Internals.Tables.Standard_Profile_L2_Metamodel is ------------------------------------------------ -- MM_Standard_Profile_L2_Standard_Profile_L2 -- ------------------------------------------------ function MM_Standard_Profile_L2_Standard_Profile_L2 return AMF.Internals.CMOF_Element is begin return Base + 95; end MM_Standard_Profile_L2_Standard_Profile_L2; -------------------------------------- -- MC_Standard_Profile_L2_Auxiliary -- -------------------------------------- function MC_Standard_Profile_L2_Auxiliary return AMF.Internals.CMOF_Element is begin return Base + 1; end MC_Standard_Profile_L2_Auxiliary; --------------------------------- -- MC_Standard_Profile_L2_Call -- --------------------------------- function MC_Standard_Profile_L2_Call return AMF.Internals.CMOF_Element is begin return Base + 2; end MC_Standard_Profile_L2_Call; ----------------------------------- -- MC_Standard_Profile_L2_Create -- ----------------------------------- function MC_Standard_Profile_L2_Create return AMF.Internals.CMOF_Element is begin return Base + 3; end MC_Standard_Profile_L2_Create; ----------------------------------- -- MC_Standard_Profile_L2_Derive -- ----------------------------------- function MC_Standard_Profile_L2_Derive return AMF.Internals.CMOF_Element is begin return Base + 4; end MC_Standard_Profile_L2_Derive; ------------------------------------ -- MC_Standard_Profile_L2_Destroy -- ------------------------------------ function MC_Standard_Profile_L2_Destroy return AMF.Internals.CMOF_Element is begin return Base + 5; end MC_Standard_Profile_L2_Destroy; ------------------------------------- -- MC_Standard_Profile_L2_Document -- ------------------------------------- function MC_Standard_Profile_L2_Document return AMF.Internals.CMOF_Element is begin return Base + 6; end MC_Standard_Profile_L2_Document; ----------------------------------- -- MC_Standard_Profile_L2_Entity -- ----------------------------------- function MC_Standard_Profile_L2_Entity return AMF.Internals.CMOF_Element is begin return Base + 7; end MC_Standard_Profile_L2_Entity; --------------------------------------- -- MC_Standard_Profile_L2_Executable -- --------------------------------------- function MC_Standard_Profile_L2_Executable return AMF.Internals.CMOF_Element is begin return Base + 8; end MC_Standard_Profile_L2_Executable; --------------------------------- -- MC_Standard_Profile_L2_File -- --------------------------------- function MC_Standard_Profile_L2_File return AMF.Internals.CMOF_Element is begin return Base + 9; end MC_Standard_Profile_L2_File; ---------------------------------- -- MC_Standard_Profile_L2_Focus -- ---------------------------------- function MC_Standard_Profile_L2_Focus return AMF.Internals.CMOF_Element is begin return Base + 10; end MC_Standard_Profile_L2_Focus; -------------------------------------- -- MC_Standard_Profile_L2_Framework -- -------------------------------------- function MC_Standard_Profile_L2_Framework return AMF.Internals.CMOF_Element is begin return Base + 11; end MC_Standard_Profile_L2_Framework; -------------------------------------- -- MC_Standard_Profile_L2_Implement -- -------------------------------------- function MC_Standard_Profile_L2_Implement return AMF.Internals.CMOF_Element is begin return Base + 12; end MC_Standard_Profile_L2_Implement; ------------------------------------------------- -- MC_Standard_Profile_L2_Implementation_Class -- ------------------------------------------------- function MC_Standard_Profile_L2_Implementation_Class return AMF.Internals.CMOF_Element is begin return Base + 13; end MC_Standard_Profile_L2_Implementation_Class; ---------------------------------------- -- MC_Standard_Profile_L2_Instantiate -- ---------------------------------------- function MC_Standard_Profile_L2_Instantiate return AMF.Internals.CMOF_Element is begin return Base + 14; end MC_Standard_Profile_L2_Instantiate; ------------------------------------ -- MC_Standard_Profile_L2_Library -- ------------------------------------ function MC_Standard_Profile_L2_Library return AMF.Internals.CMOF_Element is begin return Base + 15; end MC_Standard_Profile_L2_Library; -------------------------------------- -- MC_Standard_Profile_L2_Metaclass -- -------------------------------------- function MC_Standard_Profile_L2_Metaclass return AMF.Internals.CMOF_Element is begin return Base + 16; end MC_Standard_Profile_L2_Metaclass; ------------------------------------------ -- MC_Standard_Profile_L2_Model_Library -- ------------------------------------------ function MC_Standard_Profile_L2_Model_Library return AMF.Internals.CMOF_Element is begin return Base + 17; end MC_Standard_Profile_L2_Model_Library; ------------------------------------ -- MC_Standard_Profile_L2_Process -- ------------------------------------ function MC_Standard_Profile_L2_Process return AMF.Internals.CMOF_Element is begin return Base + 18; end MC_Standard_Profile_L2_Process; ---------------------------------------- -- MC_Standard_Profile_L2_Realization -- ---------------------------------------- function MC_Standard_Profile_L2_Realization return AMF.Internals.CMOF_Element is begin return Base + 19; end MC_Standard_Profile_L2_Realization; ----------------------------------- -- MC_Standard_Profile_L2_Refine -- ----------------------------------- function MC_Standard_Profile_L2_Refine return AMF.Internals.CMOF_Element is begin return Base + 20; end MC_Standard_Profile_L2_Refine; ------------------------------------------- -- MC_Standard_Profile_L2_Responsibility -- ------------------------------------------- function MC_Standard_Profile_L2_Responsibility return AMF.Internals.CMOF_Element is begin return Base + 21; end MC_Standard_Profile_L2_Responsibility; ----------------------------------- -- MC_Standard_Profile_L2_Script -- ----------------------------------- function MC_Standard_Profile_L2_Script return AMF.Internals.CMOF_Element is begin return Base + 22; end MC_Standard_Profile_L2_Script; --------------------------------- -- MC_Standard_Profile_L2_Send -- --------------------------------- function MC_Standard_Profile_L2_Send return AMF.Internals.CMOF_Element is begin return Base + 23; end MC_Standard_Profile_L2_Send; ------------------------------------ -- MC_Standard_Profile_L2_Service -- ------------------------------------ function MC_Standard_Profile_L2_Service return AMF.Internals.CMOF_Element is begin return Base + 24; end MC_Standard_Profile_L2_Service; ----------------------------------- -- MC_Standard_Profile_L2_Source -- ----------------------------------- function MC_Standard_Profile_L2_Source return AMF.Internals.CMOF_Element is begin return Base + 25; end MC_Standard_Profile_L2_Source; ------------------------------------------ -- MC_Standard_Profile_L2_Specification -- ------------------------------------------ function MC_Standard_Profile_L2_Specification return AMF.Internals.CMOF_Element is begin return Base + 26; end MC_Standard_Profile_L2_Specification; -------------------------------------- -- MC_Standard_Profile_L2_Subsystem -- -------------------------------------- function MC_Standard_Profile_L2_Subsystem return AMF.Internals.CMOF_Element is begin return Base + 27; end MC_Standard_Profile_L2_Subsystem; ---------------------------------- -- MC_Standard_Profile_L2_Trace -- ---------------------------------- function MC_Standard_Profile_L2_Trace return AMF.Internals.CMOF_Element is begin return Base + 28; end MC_Standard_Profile_L2_Trace; --------------------------------- -- MC_Standard_Profile_L2_Type -- --------------------------------- function MC_Standard_Profile_L2_Type return AMF.Internals.CMOF_Element is begin return Base + 29; end MC_Standard_Profile_L2_Type; ------------------------------------ -- MC_Standard_Profile_L2_Utility -- ------------------------------------ function MC_Standard_Profile_L2_Utility return AMF.Internals.CMOF_Element is begin return Base + 30; end MC_Standard_Profile_L2_Utility; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Auxiliary_Base_Class_A_Extension_Auxiliary -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Auxiliary_Base_Class_A_Extension_Auxiliary return AMF.Internals.CMOF_Element is begin return Base + 31; end MP_Standard_Profile_L2_Auxiliary_Base_Class_A_Extension_Auxiliary; ------------------------------------------------------------- -- MP_Standard_Profile_L2_Call_Base_Usage_A_Extension_Call -- ------------------------------------------------------------- function MP_Standard_Profile_L2_Call_Base_Usage_A_Extension_Call return AMF.Internals.CMOF_Element is begin return Base + 32; end MP_Standard_Profile_L2_Call_Base_Usage_A_Extension_Call; ------------------------------------------------------------------------------ -- MP_Standard_Profile_L2_Create_Base_Behavioral_Feature_A_Extension_Create -- ------------------------------------------------------------------------------ function MP_Standard_Profile_L2_Create_Base_Behavioral_Feature_A_Extension_Create return AMF.Internals.CMOF_Element is begin return Base + 33; end MP_Standard_Profile_L2_Create_Base_Behavioral_Feature_A_Extension_Create; ----------------------------------------------------------------- -- MP_Standard_Profile_L2_Create_Base_Usage_A_Extension_Create -- ----------------------------------------------------------------- function MP_Standard_Profile_L2_Create_Base_Usage_A_Extension_Create return AMF.Internals.CMOF_Element is begin return Base + 34; end MP_Standard_Profile_L2_Create_Base_Usage_A_Extension_Create; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Derive_Base_Abstraction_A_Extension_Derive -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Derive_Base_Abstraction_A_Extension_Derive return AMF.Internals.CMOF_Element is begin return Base + 35; end MP_Standard_Profile_L2_Derive_Base_Abstraction_A_Extension_Derive; ------------------------------------------------------------------ -- MP_Standard_Profile_L2_Derive_Computation_A_Extension_Derive -- ------------------------------------------------------------------ function MP_Standard_Profile_L2_Derive_Computation_A_Extension_Derive return AMF.Internals.CMOF_Element is begin return Base + 36; end MP_Standard_Profile_L2_Derive_Computation_A_Extension_Derive; -------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Destroy_Base_Behavioral_Feature_A_Extension_Destroy -- -------------------------------------------------------------------------------- function MP_Standard_Profile_L2_Destroy_Base_Behavioral_Feature_A_Extension_Destroy return AMF.Internals.CMOF_Element is begin return Base + 37; end MP_Standard_Profile_L2_Destroy_Base_Behavioral_Feature_A_Extension_Destroy; ------------------------------------------------------------------------ -- MP_Standard_Profile_L2_Document_Base_Artifact_A_Extension_Document -- ------------------------------------------------------------------------ function MP_Standard_Profile_L2_Document_Base_Artifact_A_Extension_Document return AMF.Internals.CMOF_Element is begin return Base + 38; end MP_Standard_Profile_L2_Document_Base_Artifact_A_Extension_Document; --------------------------------------------------------------------- -- MP_Standard_Profile_L2_Entity_Base_Component_A_Extension_Entity -- --------------------------------------------------------------------- function MP_Standard_Profile_L2_Entity_Base_Component_A_Extension_Entity return AMF.Internals.CMOF_Element is begin return Base + 39; end MP_Standard_Profile_L2_Entity_Base_Component_A_Extension_Entity; ---------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Executable_Base_Artifact_A_Extension_Executable -- ---------------------------------------------------------------------------- function MP_Standard_Profile_L2_Executable_Base_Artifact_A_Extension_Executable return AMF.Internals.CMOF_Element is begin return Base + 40; end MP_Standard_Profile_L2_Executable_Base_Artifact_A_Extension_Executable; ---------------------------------------------------------------- -- MP_Standard_Profile_L2_File_Base_Artifact_A_Extension_File -- ---------------------------------------------------------------- function MP_Standard_Profile_L2_File_Base_Artifact_A_Extension_File return AMF.Internals.CMOF_Element is begin return Base + 41; end MP_Standard_Profile_L2_File_Base_Artifact_A_Extension_File; --------------------------------------------------------------- -- MP_Standard_Profile_L2_Focus_Base_Class_A_Extension_Focus -- --------------------------------------------------------------- function MP_Standard_Profile_L2_Focus_Base_Class_A_Extension_Focus return AMF.Internals.CMOF_Element is begin return Base + 42; end MP_Standard_Profile_L2_Focus_Base_Class_A_Extension_Focus; ------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Framework_Base_Package_A_Extension_Framework -- ------------------------------------------------------------------------- function MP_Standard_Profile_L2_Framework_Base_Package_A_Extension_Framework return AMF.Internals.CMOF_Element is begin return Base + 43; end MP_Standard_Profile_L2_Framework_Base_Package_A_Extension_Framework; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Implement_Base_Component_A_Extension_Implement -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_Implement_Base_Component_A_Extension_Implement return AMF.Internals.CMOF_Element is begin return Base + 44; end MP_Standard_Profile_L2_Implement_Base_Component_A_Extension_Implement; --------------------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Implementation_Class_Base_Class_A_Extension_Implementation_Class -- --------------------------------------------------------------------------------------------- function MP_Standard_Profile_L2_Implementation_Class_Base_Class_A_Extension_Implementation_Class return AMF.Internals.CMOF_Element is begin return Base + 45; end MP_Standard_Profile_L2_Implementation_Class_Base_Class_A_Extension_Implementation_Class; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Instantiate_Base_Usage_A_Extension_Instantiate -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_Instantiate_Base_Usage_A_Extension_Instantiate return AMF.Internals.CMOF_Element is begin return Base + 46; end MP_Standard_Profile_L2_Instantiate_Base_Usage_A_Extension_Instantiate; ---------------------------------------------------------------------- -- MP_Standard_Profile_L2_Library_Base_Artifact_A_Extension_Library -- ---------------------------------------------------------------------- function MP_Standard_Profile_L2_Library_Base_Artifact_A_Extension_Library return AMF.Internals.CMOF_Element is begin return Base + 47; end MP_Standard_Profile_L2_Library_Base_Artifact_A_Extension_Library; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Metaclass_Base_Class_A_Extension_Metaclass -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Metaclass_Base_Class_A_Extension_Metaclass return AMF.Internals.CMOF_Element is begin return Base + 48; end MP_Standard_Profile_L2_Metaclass_Base_Class_A_Extension_Metaclass; --------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Model_Library_Base_Package_A_Extension_Model_Library -- --------------------------------------------------------------------------------- function MP_Standard_Profile_L2_Model_Library_Base_Package_A_Extension_Model_Library return AMF.Internals.CMOF_Element is begin return Base + 49; end MP_Standard_Profile_L2_Model_Library_Base_Package_A_Extension_Model_Library; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Process_Base_Component_A_Extension_Process -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Process_Base_Component_A_Extension_Process return AMF.Internals.CMOF_Element is begin return Base + 50; end MP_Standard_Profile_L2_Process_Base_Component_A_Extension_Process; -------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Realization_Base_Classifier_A_Extension_Realization -- -------------------------------------------------------------------------------- function MP_Standard_Profile_L2_Realization_Base_Classifier_A_Extension_Realization return AMF.Internals.CMOF_Element is begin return Base + 51; end MP_Standard_Profile_L2_Realization_Base_Classifier_A_Extension_Realization; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Refine_Base_Abstraction_A_Extension_Refine -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Refine_Base_Abstraction_A_Extension_Refine return AMF.Internals.CMOF_Element is begin return Base + 52; end MP_Standard_Profile_L2_Refine_Base_Abstraction_A_Extension_Refine; --------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Responsibility_Base_Usage_A_Extension_Responsibility -- --------------------------------------------------------------------------------- function MP_Standard_Profile_L2_Responsibility_Base_Usage_A_Extension_Responsibility return AMF.Internals.CMOF_Element is begin return Base + 53; end MP_Standard_Profile_L2_Responsibility_Base_Usage_A_Extension_Responsibility; -------------------------------------------------------------------- -- MP_Standard_Profile_L2_Script_Base_Artifact_A_Extension_Script -- -------------------------------------------------------------------- function MP_Standard_Profile_L2_Script_Base_Artifact_A_Extension_Script return AMF.Internals.CMOF_Element is begin return Base + 54; end MP_Standard_Profile_L2_Script_Base_Artifact_A_Extension_Script; ------------------------------------------------------------- -- MP_Standard_Profile_L2_Send_Base_Usage_A_Extension_Send -- ------------------------------------------------------------- function MP_Standard_Profile_L2_Send_Base_Usage_A_Extension_Send return AMF.Internals.CMOF_Element is begin return Base + 55; end MP_Standard_Profile_L2_Send_Base_Usage_A_Extension_Send; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_Service_Base_Component_A_Extension_Service -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_Service_Base_Component_A_Extension_Service return AMF.Internals.CMOF_Element is begin return Base + 56; end MP_Standard_Profile_L2_Service_Base_Component_A_Extension_Service; -------------------------------------------------------------------- -- MP_Standard_Profile_L2_Source_Base_Artifact_A_Extension_Source -- -------------------------------------------------------------------- function MP_Standard_Profile_L2_Source_Base_Artifact_A_Extension_Source return AMF.Internals.CMOF_Element is begin return Base + 57; end MP_Standard_Profile_L2_Source_Base_Artifact_A_Extension_Source; ------------------------------------------------------------------------------------ -- MP_Standard_Profile_L2_Specification_Base_Classifier_A_Extension_Specification -- ------------------------------------------------------------------------------------ function MP_Standard_Profile_L2_Specification_Base_Classifier_A_Extension_Specification return AMF.Internals.CMOF_Element is begin return Base + 58; end MP_Standard_Profile_L2_Specification_Base_Classifier_A_Extension_Specification; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_Subsystem_Base_Component_A_Extension_Subsystem -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_Subsystem_Base_Component_A_Extension_Subsystem return AMF.Internals.CMOF_Element is begin return Base + 59; end MP_Standard_Profile_L2_Subsystem_Base_Component_A_Extension_Subsystem; --------------------------------------------------------------------- -- MP_Standard_Profile_L2_Trace_Base_Abstraction_A_Extension_Trace -- --------------------------------------------------------------------- function MP_Standard_Profile_L2_Trace_Base_Abstraction_A_Extension_Trace return AMF.Internals.CMOF_Element is begin return Base + 60; end MP_Standard_Profile_L2_Trace_Base_Abstraction_A_Extension_Trace; ------------------------------------------------------------- -- MP_Standard_Profile_L2_Type_Base_Class_A_Extension_Type -- ------------------------------------------------------------- function MP_Standard_Profile_L2_Type_Base_Class_A_Extension_Type return AMF.Internals.CMOF_Element is begin return Base + 61; end MP_Standard_Profile_L2_Type_Base_Class_A_Extension_Type; ------------------------------------------------------------------- -- MP_Standard_Profile_L2_Utility_Base_Class_A_Extension_Utility -- ------------------------------------------------------------------- function MP_Standard_Profile_L2_Utility_Base_Class_A_Extension_Utility return AMF.Internals.CMOF_Element is begin return Base + 62; end MP_Standard_Profile_L2_Utility_Base_Class_A_Extension_Utility; --------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Focus_Focus_Base_Class -- --------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Focus_Focus_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 109; end MP_Standard_Profile_L2_A_Extension_Focus_Focus_Base_Class; --------------------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Implementation_Class_Implementation_Class_Base_Class -- --------------------------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Implementation_Class_Implementation_Class_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 110; end MP_Standard_Profile_L2_A_Extension_Implementation_Class_Implementation_Class_Base_Class; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Metaclass_Metaclass_Base_Class -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Metaclass_Metaclass_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 111; end MP_Standard_Profile_L2_A_Extension_Metaclass_Metaclass_Base_Class; ------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Type_Type_Base_Class -- ------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Type_Type_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 112; end MP_Standard_Profile_L2_A_Extension_Type_Type_Base_Class; ------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Utility_Utility_Base_Class -- ------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Utility_Utility_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 113; end MP_Standard_Profile_L2_A_Extension_Utility_Utility_Base_Class; -------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Realization_Realization_Base_Classifier -- -------------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Realization_Realization_Base_Classifier return AMF.Internals.CMOF_Element is begin return Base + 114; end MP_Standard_Profile_L2_A_Extension_Realization_Realization_Base_Classifier; ------------------------------------------------------------------------------------ -- MP_Standard_Profile_L2_A_Extension_Specification_Specification_Base_Classifier -- ------------------------------------------------------------------------------------ function MP_Standard_Profile_L2_A_Extension_Specification_Specification_Base_Classifier return AMF.Internals.CMOF_Element is begin return Base + 115; end MP_Standard_Profile_L2_A_Extension_Specification_Specification_Base_Classifier; --------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Entity_Entity_Base_Component -- --------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Entity_Entity_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 116; end MP_Standard_Profile_L2_A_Extension_Entity_Entity_Base_Component; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Implement_Implement_Base_Component -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Implement_Implement_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 117; end MP_Standard_Profile_L2_A_Extension_Implement_Implement_Base_Component; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Process_Process_Base_Component -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Process_Process_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 118; end MP_Standard_Profile_L2_A_Extension_Process_Process_Base_Component; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Service_Service_Base_Component -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Service_Service_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 119; end MP_Standard_Profile_L2_A_Extension_Service_Service_Base_Component; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Subsystem_Subsystem_Base_Component -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Subsystem_Subsystem_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 120; end MP_Standard_Profile_L2_A_Extension_Subsystem_Subsystem_Base_Component; ------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Framework_Framework_Base_Package -- ------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Framework_Framework_Base_Package return AMF.Internals.CMOF_Element is begin return Base + 121; end MP_Standard_Profile_L2_A_Extension_Framework_Framework_Base_Package; --------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Model_Library_Model_Library_Base_Package -- --------------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Model_Library_Model_Library_Base_Package return AMF.Internals.CMOF_Element is begin return Base + 122; end MP_Standard_Profile_L2_A_Extension_Model_Library_Model_Library_Base_Package; ------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Call_Call_Base_Usage -- ------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Call_Call_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 123; end MP_Standard_Profile_L2_A_Extension_Call_Call_Base_Usage; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Derive_Derive_Base_Abstraction -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Derive_Derive_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 97; end MP_Standard_Profile_L2_A_Extension_Derive_Derive_Base_Abstraction; ----------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Usage -- ----------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 124; end MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Usage; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Refine_Refine_Base_Abstraction -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Refine_Refine_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 98; end MP_Standard_Profile_L2_A_Extension_Refine_Refine_Base_Abstraction; ------------------------------------------------------------------ -- MP_Standard_Profile_L2_A_Extension_Derive_Derive_Computation -- ------------------------------------------------------------------ function MP_Standard_Profile_L2_A_Extension_Derive_Derive_Computation return AMF.Internals.CMOF_Element is begin return Base + 125; end MP_Standard_Profile_L2_A_Extension_Derive_Derive_Computation; --------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Trace_Trace_Base_Abstraction -- --------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Trace_Trace_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 99; end MP_Standard_Profile_L2_A_Extension_Trace_Trace_Base_Abstraction; --------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Instantiate_Instantiate_Base_Usage -- --------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Instantiate_Instantiate_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 126; end MP_Standard_Profile_L2_A_Extension_Instantiate_Instantiate_Base_Usage; ------------------------------------------------------------------------ -- MP_Standard_Profile_L2_A_Extension_Document_Document_Base_Artifact -- ------------------------------------------------------------------------ function MP_Standard_Profile_L2_A_Extension_Document_Document_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 100; end MP_Standard_Profile_L2_A_Extension_Document_Document_Base_Artifact; --------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Responsibility_Responsibility_Base_Usage -- --------------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Responsibility_Responsibility_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 127; end MP_Standard_Profile_L2_A_Extension_Responsibility_Responsibility_Base_Usage; ---------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Executable_Executable_Base_Artifact -- ---------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Executable_Executable_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 101; end MP_Standard_Profile_L2_A_Extension_Executable_Executable_Base_Artifact; ------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Send_Send_Base_Usage -- ------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Send_Send_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 128; end MP_Standard_Profile_L2_A_Extension_Send_Send_Base_Usage; ---------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_File_File_Base_Artifact -- ---------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_File_File_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 102; end MP_Standard_Profile_L2_A_Extension_File_File_Base_Artifact; ---------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Library_Library_Base_Artifact -- ---------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Library_Library_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 103; end MP_Standard_Profile_L2_A_Extension_Library_Library_Base_Artifact; -------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Script_Script_Base_Artifact -- -------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Script_Script_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 104; end MP_Standard_Profile_L2_A_Extension_Script_Script_Base_Artifact; -------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Source_Source_Base_Artifact -- -------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Source_Source_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 105; end MP_Standard_Profile_L2_A_Extension_Source_Source_Base_Artifact; ------------------------------------------------------------------------------ -- MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Behavioral_Feature -- ------------------------------------------------------------------------------ function MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Behavioral_Feature return AMF.Internals.CMOF_Element is begin return Base + 106; end MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Behavioral_Feature; -------------------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Destroy_Destroy_Base_Behavioral_Feature -- -------------------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Destroy_Destroy_Base_Behavioral_Feature return AMF.Internals.CMOF_Element is begin return Base + 107; end MP_Standard_Profile_L2_A_Extension_Destroy_Destroy_Base_Behavioral_Feature; ----------------------------------------------------------------------- -- MP_Standard_Profile_L2_A_Extension_Auxiliary_Auxiliary_Base_Class -- ----------------------------------------------------------------------- function MP_Standard_Profile_L2_A_Extension_Auxiliary_Auxiliary_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 108; end MP_Standard_Profile_L2_A_Extension_Auxiliary_Auxiliary_Base_Class; --------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Focus_Base_Class -- --------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Focus_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 63; end MA_Standard_Profile_L2_A_Extension_Focus_Base_Class; ------------------------------------------------------------------------ -- MA_Standard_Profile_L2_A_Extension_Implementation_Class_Base_Class -- ------------------------------------------------------------------------ function MA_Standard_Profile_L2_A_Extension_Implementation_Class_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 64; end MA_Standard_Profile_L2_A_Extension_Implementation_Class_Base_Class; ------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Metaclass_Base_Class -- ------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Metaclass_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 65; end MA_Standard_Profile_L2_A_Extension_Metaclass_Base_Class; -------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Type_Base_Class -- -------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Type_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 66; end MA_Standard_Profile_L2_A_Extension_Type_Base_Class; ----------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Utility_Base_Class -- ----------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Utility_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 67; end MA_Standard_Profile_L2_A_Extension_Utility_Base_Class; -------------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Realization_Base_Classifier -- -------------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Realization_Base_Classifier return AMF.Internals.CMOF_Element is begin return Base + 68; end MA_Standard_Profile_L2_A_Extension_Realization_Base_Classifier; ---------------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Specification_Base_Classifier -- ---------------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Specification_Base_Classifier return AMF.Internals.CMOF_Element is begin return Base + 69; end MA_Standard_Profile_L2_A_Extension_Specification_Base_Classifier; -------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Entity_Base_Component -- -------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Entity_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 70; end MA_Standard_Profile_L2_A_Extension_Entity_Base_Component; ----------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Implement_Base_Component -- ----------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Implement_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 71; end MA_Standard_Profile_L2_A_Extension_Implement_Base_Component; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Process_Base_Component -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Process_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 72; end MA_Standard_Profile_L2_A_Extension_Process_Base_Component; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Service_Base_Component -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Service_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 73; end MA_Standard_Profile_L2_A_Extension_Service_Base_Component; ----------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Subsystem_Base_Component -- ----------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Subsystem_Base_Component return AMF.Internals.CMOF_Element is begin return Base + 74; end MA_Standard_Profile_L2_A_Extension_Subsystem_Base_Component; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Framework_Base_Package -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Framework_Base_Package return AMF.Internals.CMOF_Element is begin return Base + 75; end MA_Standard_Profile_L2_A_Extension_Framework_Base_Package; ------------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Model_Library_Base_Package -- ------------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Model_Library_Base_Package return AMF.Internals.CMOF_Element is begin return Base + 76; end MA_Standard_Profile_L2_A_Extension_Model_Library_Base_Package; -------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Call_Base_Usage -- -------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Call_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 77; end MA_Standard_Profile_L2_A_Extension_Call_Base_Usage; ---------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Derive_Base_Abstraction -- ---------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Derive_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 78; end MA_Standard_Profile_L2_A_Extension_Derive_Base_Abstraction; ---------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Create_Base_Usage -- ---------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Create_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 79; end MA_Standard_Profile_L2_A_Extension_Create_Base_Usage; ---------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Refine_Base_Abstraction -- ---------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Refine_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 80; end MA_Standard_Profile_L2_A_Extension_Refine_Base_Abstraction; ----------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Derive_Computation -- ----------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Derive_Computation return AMF.Internals.CMOF_Element is begin return Base + 81; end MA_Standard_Profile_L2_A_Extension_Derive_Computation; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Trace_Base_Abstraction -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Trace_Base_Abstraction return AMF.Internals.CMOF_Element is begin return Base + 82; end MA_Standard_Profile_L2_A_Extension_Trace_Base_Abstraction; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Instantiate_Base_Usage -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Instantiate_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 83; end MA_Standard_Profile_L2_A_Extension_Instantiate_Base_Usage; --------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Document_Base_Artifact -- --------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Document_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 84; end MA_Standard_Profile_L2_A_Extension_Document_Base_Artifact; ------------------------------------------------------------------ -- MA_Standard_Profile_L2_A_Extension_Responsibility_Base_Usage -- ------------------------------------------------------------------ function MA_Standard_Profile_L2_A_Extension_Responsibility_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 85; end MA_Standard_Profile_L2_A_Extension_Responsibility_Base_Usage; ----------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Executable_Base_Artifact -- ----------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Executable_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 86; end MA_Standard_Profile_L2_A_Extension_Executable_Base_Artifact; -------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Send_Base_Usage -- -------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Send_Base_Usage return AMF.Internals.CMOF_Element is begin return Base + 87; end MA_Standard_Profile_L2_A_Extension_Send_Base_Usage; ----------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_File_Base_Artifact -- ----------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_File_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 88; end MA_Standard_Profile_L2_A_Extension_File_Base_Artifact; -------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Library_Base_Artifact -- -------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Library_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 89; end MA_Standard_Profile_L2_A_Extension_Library_Base_Artifact; ------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Script_Base_Artifact -- ------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Script_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 90; end MA_Standard_Profile_L2_A_Extension_Script_Base_Artifact; ------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Source_Base_Artifact -- ------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Source_Base_Artifact return AMF.Internals.CMOF_Element is begin return Base + 91; end MA_Standard_Profile_L2_A_Extension_Source_Base_Artifact; ----------------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Create_Base_Behavioral_Feature -- ----------------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Create_Base_Behavioral_Feature return AMF.Internals.CMOF_Element is begin return Base + 92; end MA_Standard_Profile_L2_A_Extension_Create_Base_Behavioral_Feature; ------------------------------------------------------------------------ -- MA_Standard_Profile_L2_A_Extension_Destroy_Base_Behavioral_Feature -- ------------------------------------------------------------------------ function MA_Standard_Profile_L2_A_Extension_Destroy_Base_Behavioral_Feature return AMF.Internals.CMOF_Element is begin return Base + 93; end MA_Standard_Profile_L2_A_Extension_Destroy_Base_Behavioral_Feature; ------------------------------------------------------------- -- MA_Standard_Profile_L2_A_Extension_Auxiliary_Base_Class -- ------------------------------------------------------------- function MA_Standard_Profile_L2_A_Extension_Auxiliary_Base_Class return AMF.Internals.CMOF_Element is begin return Base + 94; end MA_Standard_Profile_L2_A_Extension_Auxiliary_Base_Class; ---------------------------- -- MB_Standard_Profile_L2 -- ---------------------------- function MB_Standard_Profile_L2 return AMF.Internals.AMF_Element is begin return Base; end MB_Standard_Profile_L2; ---------------------------- -- MB_Standard_Profile_L2 -- ---------------------------- function ML_Standard_Profile_L2 return AMF.Internals.AMF_Element is begin return Base + 180; end ML_Standard_Profile_L2; end AMF.Internals.Tables.Standard_Profile_L2_Metamodel;
zenharris/ada-bbs
Ada
14,214
adb
with Text_File_Scroller; with Texaco; use Texaco; with Message.Post; package body Message.Reader is -- CurrentLine : Line_Position := 0; -- CurrentCurs : Cursor; -- TopLine : Line_Position; -- TermLnth : Line_Position; -- TermWdth : Column_Position; -- BottomLine : Line_Position ; -- Curr_Dir : string := Current_Directory; procedure Scroll_Up is begin Move_Cursor(Line => TopLine,Column => 0); Delete_Line; Move_Cursor(Line => BottomLine,Column => 0); Insert_Line; Box; Refresh; end Scroll_Up; procedure Scroll_Down is begin Move_Cursor(Line => BottomLine,Column => 0); Delete_Line; Move_Cursor(Line => TopLine,Column => 0); Insert_Line; Box; Refresh; end Scroll_Down; Procedure Clear_Region is begin for i in TopLine .. BottomLine loop Move_Cursor(Line => i,Column => 2); Clear_To_End_Of_Line; end loop; -- CurrentLine := 0; end Clear_Region; procedure Increment (IncLine : in out Line_Position) is begin if TopLine + Incline < BottomLine then IncLine := IncLine + 1; else Scroll_Up; end if; end Increment; procedure Decrement (IncLine : in out Line_Position) is begin if Incline > 0 then IncLine := IncLine - 1; else Scroll_Down; end if; end Decrement; procedure HiLite (Win : Window; Prompt : Unbounded_String; Line_Num : Line_Position) is begin Set_Character_Attributes(Win, (Reverse_Video => True,others => False)); Add (Win => Win, Line => Line_Num, Column => 2, Str => To_String(Prompt)); Refresh(Win); Set_Character_Attributes(Win, Normal_Video); end HiLite; procedure LoLite (Win : Window; Prompt : Unbounded_String; Line_Num : Line_Position) is begin Set_Character_Attributes(Win, Normal_Video); Add (Win => Win, Line => Line_Num, Column => 2, Str => To_String(Prompt)); Refresh(Win); end LoLite; procedure Redraw_Screen is curs2 : Cursor; LineNum : Line_Position := 0; begin Clear_Region; if not Directory_Buffer.Is_Empty then curs2 := CurrentCurs; for i in 1 .. CurrentLine loop if curs2 /= Directory_Buffer.First then Directory_List.Previous(curs2); end if; end loop; while curs2 /= Directory_Buffer.Last loop Add(Standard_Window,Line => TopLine + LineNum,Column => 2,Str => To_String(Element(curs2).Prompt) ); Clear_To_End_Of_Line; Refresh; Directory_List.Next(curs2); LineNum := LineNum +1; exit when LineNum+ TopLine >= BottomLine; end loop; Add(Standard_Window,Line => TopLine + LineNum,Column => 2,Str => To_String(Element(curs2).Prompt) ); Clear_To_End_Of_Line; Refresh; Add (Line => TermLnth - 2,Column => 1, Str => " | Func 2 | Esc to exit"); Clear_To_End_Of_Line; Box; end if; end Redraw_Screen; procedure Read_Header (FileName : in String; Sender : out Unbounded_String; Subject : out Unbounded_String; Msgid : out Unbounded_String; ReplyTo : out Unbounded_String) is HeaderType, HeaderText, scratch : Unbounded_String; File : File_Type; begin Open (File => File, Mode => In_File, Name => Filename); scratch := SUIO.Get_Line(File); while scratch /= "" loop HeaderType := To_Unbounded_String(SU.Slice(scratch,1,SU.Index(scratch,":")-1)); HeaderText := To_Unbounded_String(SU.Slice(scratch,SU.Index(scratch,":")+2,SU.Length(scratch))); if HeaderType = "Sender" then Sender := HeaderText; elsif HeaderType = "Subject" then Subject := HeaderText; elsif HeaderType = "Msgid" then Msgid := HeaderText; elsif HeaderType = "ReplyTo" then ReplyTo := HeaderText; end if; scratch := SUIO.Get_Line(File); end loop; Close (File); exception when End_Error => Close (File); null; end Read_Header; function CharPad(InStr : Unbounded_String; PadWidth : Integer) return String is padstr : Unbounded_String; begin if SU.Length(InStr) <= PadWidth then for i in SU.Length(InStr) .. PadWidth loop padstr := padstr & " "; end loop; end if; return To_String(Instr & padstr); end CharPad; procedure Read_Directory (ReplyID : Unbounded_String := To_Unbounded_String("")) is Dir : Directory_Entry_Type; Dir_Search : Search_Type; -- Curr_Dir : string := Current_Directory; Sender, Subject,Msgid,ReplyTo : Unbounded_String; I, J, SortCurs : Cursor; swapped : Boolean; begin Clear(Directory_Buffer); Start_Search(Search => Dir_Search, Directory => Curr_Dir&"/messages", Pattern => "*.msg"); loop Get_Next_Entry(Dir_Search, Dir); ReplyTo := To_Unbounded_String(""); Msgid := To_Unbounded_String(""); Read_Header(Full_Name(Dir),Sender => Sender, Subject => Subject,Msgid => Msgid,ReplyTo => ReplyTo); if SU.Length(ReplyID) > 0 then if ReplyTo = ReplyID or else Msgid = ReplyID then Directory_Buffer.Append(New_Item => (To_Unbounded_String(Full_Name(Dir)), CharPad(Sender,15) & Subject) ); end if; else Directory_Buffer.Append(New_Item => (To_Unbounded_String(Full_Name(Dir)), CharPad(Sender,15) & Subject) ); end if; exit when not More_Entries(Dir_Search); end loop; End_Search(Dir_Search); -- Bubble Sort Director Buffer loop SortCurs := Directory_Buffer.First; swapped := False; while SortCurs /= Directory_Buffer.Last loop I := SortCurs; Directory_List.Next(SortCurs); J := SortCurs; if Element(J).FileName < Element(I).FileName then Swap(Directory_Buffer,I,J); swapped := True; end if; end loop; exit when not swapped; end loop; end Read_Directory; procedure ReRead_Directory is begin Read_Directory; end ReRead_Directory; procedure Post_Reply is Sender, Subject, MsgId, ReplyTo : Unbounded_String; begin Read_Header(To_String(Element(CurrentCurs).FileName) ,Sender => Sender, Subject => Subject,Msgid => Msgid,ReplyTo => ReplyTo); Subject := "Re. " & Subject; Message.Post.Quote(Msgid => Msgid); Message.Post.Post_Message(MsgId,Subject); end; procedure Post_Thread_Reply is Sender, Subject, MsgId, ReplyTo : Unbounded_String; begin Read_Header(To_String(Element(CurrentCurs).FileName) ,Sender => Sender, Subject => Subject,Msgid => Msgid,ReplyTo => ReplyTo); if SU.Length(ReplyTo) > 0 then Message.Post.Quote(Msgid => Msgid); Message.Post.Post_Message(ReplyTo,Subject); else Display_Warning.Warning("Selected message not part of a thread"); end if; end Post_Thread_Reply; procedure Show_Thread is Sender, Subject, MsgId, ReplyTo : Unbounded_String; DefaultLength : Ada.Containers.Count_Type := 1; begin Read_Header(To_String(Element(CurrentCurs).FileName) ,Sender => Sender, Subject => Subject,Msgid => Msgid,ReplyTo => ReplyTo); if SU.Length(ReplyTo) = 0 then Read_Directory(ReplyID => MsgId); if Directory_Buffer.Length = DefaultLength then Display_Warning.Warning("No Replys to this message"); Read_Directory; end if; if CurrentLine > Line_Position(Directory_Buffer.Length-1) then CurrentLine := Line_Position(Directory_Buffer.Length-1); end if; -- CurrentLine := 0; -- CurrentCurs := Directory_Buffer.First; else Read_Directory(ReplyID => ReplyTo); if CurrentLine > Line_Position(Directory_Buffer.Length) then -- CurrentLine := 0; -- Line_Position(Directory_Buffer.Length); -- CurrentCurs := Directory_Buffer.Last; null; end if; -- CurrentLine := 0; -- CurrentCurs := Directory_Buffer.First; end if; end Show_Thread; procedure Run_Post_Message is begin Text_Buffer.Clear; Message.Post.Post_Message; end Run_Post_Message; MessageMenu : Process_Menu.Menu_Type := ((new String'("Show Reply Thread"),Show_Thread'Access), (new String'("Reply To Thread"),Post_Thread_Reply'Access), (new String'("Reply To Message"),Post_Reply'Access), (new String'("Post New Message"),Run_Post_Message'Access), (new String'("Reload Messages"),ReRead_Directory'Access), (new String'("User Login"),Message.Login.Login_User'Access), (new String'("Create User"),Message.Login.Create_User'Access)); function Count_Back(Csr : Cursor) return integer is CountCsr : Cursor := Csr; Counter : Integer := 1; begin loop exit when CountCsr = Directory_Buffer.First; Directory_List.Previous(CountCsr); Counter := Counter +1; end loop; return Counter; end Count_Back; procedure Read_Messages is c : Key_Code; FindElement : Directory_Record; begin Clear; Get_Size(Standard_Window,Number_Of_Lines => TermLnth,Number_Of_Columns => TermWdth); TopLine := 4; BottomLine := TermLnth - 4; CurrentLine := 0; Read_Directory; CurrentCurs := Directory_Buffer.First; Redraw_Screen; Refresh; loop HiLite(Standard_Window,Element(CurrentCurs).Prompt,CurrentLine+TopLine); c := Get_Keystroke; if c in Special_Key_Code'Range then case c is when Key_F2 => FindElement := Element(CurrentCurs); Process_Menu.Open_Menu (Function_Number => 2,Menu_Array => MessageMenu ); CurrentCurs := Directory_Buffer.Find(Item => FindElement); if CurrentCurs = No_Element then CurrentCurs := Directory_Buffer.Last; end if; -- Try to make CurrentLine right for repositioned CurrentCurs if Line_Position(Directory_Buffer.Length) < BottomLine-TopLine then declare CountCurs : Cursor := Directory_Buffer.First; Counter : Integer := 0; begin while CountCurs /= Directory_Buffer.Last loop exit when CountCurs = CurrentCurs; Counter := Counter +1; CountCurs := Directory_List.Next(CountCurs); end loop; CurrentLine := Line_Position(Counter); end; end if; Clear; Redraw_Screen; when Key_Cursor_Down => if (CurrentCurs /= Directory_Buffer.Last) then LoLite(Standard_Window,Element(CurrentCurs).Prompt,CurrentLine+TopLine); Increment(CurrentLine); Directory_List.Next(CurrentCurs); end if; when Key_Cursor_Up => if (CurrentCurs /= Directory_Buffer.First) then LoLite(Standard_Window,Element(CurrentCurs).Prompt,CurrentLine+TopLine); Decrement(CurrentLine); Directory_List.Previous(CurrentCurs); end if; when Key_Next_Page => for i in 0 .. BottomLine-TopLine loop if CurrentCurs /= Directory_Buffer.Last then Directory_List.Next(CurrentCurs); end if; end loop; Redraw_Screen; when Key_Previous_Page => for i in 0 .. BottomLine-TopLine loop if CurrentCurs /= Directory_Buffer.First then Directory_List.Previous(CurrentCurs); end if; end loop; if Line_Position(Count_Back(CurrentCurs)) < BottomLine-TopLine then CurrentLine := 0; end if; Redraw_Screen; when Key_Home => CurrentCurs := Directory_Buffer.First; CurrentLine := 0; Redraw_Screen; when Key_End => CurrentCurs := Directory_Buffer.Last; CurrentLine := BottomLine-TopLine; Redraw_Screen; when Key_Resize => Get_Size(Standard_Window,Number_Of_Lines => TermLnth,Number_Of_Columns => TermWdth); BottomLine := TermLnth - 4; Clear; Redraw_Screen; -- when Key_End => exit; when others => null; end case; elsif c in Real_Key_Code'Range then -- Ch := Character'Val (c); case Character'Val (c) is when LF | CR => begin if Exists(To_String(Element(CurrentCurs).FileName)) then Text_File_Scroller(To_String(Element(CurrentCurs).FileName)); Redraw_Screen; else Display_Warning.Warning("Message Has been deleted"); end if; end; when ESC => Exit; when others => null; end case; end if; end loop; end Read_Messages; end Message.Reader;
reznikmm/matreshka
Ada
4,752
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Chart_Symbol_Image_Elements; package Matreshka.ODF_Chart.Symbol_Image_Elements is type Chart_Symbol_Image_Element_Node is new Matreshka.ODF_Chart.Abstract_Chart_Element_Node and ODF.DOM.Chart_Symbol_Image_Elements.ODF_Chart_Symbol_Image with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Chart_Symbol_Image_Element_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Symbol_Image_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Chart_Symbol_Image_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Chart_Symbol_Image_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Chart_Symbol_Image_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Chart.Symbol_Image_Elements;
zhmu/ananas
Ada
4,506
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ T E X T _ I O . I N T E G E R _ A U X -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux; package body Ada.Wide_Text_IO.Integer_Aux is --------- -- Get -- --------- procedure Get (File : File_Type; Item : out Num; Width : Field) is Buf : String (1 .. Field'Last); Ptr : aliased Integer := 1; Stop : Integer := 0; begin if Width /= 0 then Load_Width (File, Width, Buf, Stop); String_Skip (Buf, Ptr); else Load_Integer (File, Buf, Stop); end if; Scan (Buf, Ptr'Access, Stop, Item); Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get; ---------- -- Gets -- ---------- procedure Gets (From : String; Item : out Num; Last : out Positive) is Pos : aliased Integer; begin String_Skip (From, Pos); Scan (From, Pos'Access, From'Last, Item); Last := Pos - 1; exception when Constraint_Error => raise Data_Error; end Gets; --------- -- Put -- --------- procedure Put (File : File_Type; Item : Num; Width : Field; Base : Number_Base) is Buf : String (1 .. Integer'Max (Field'Last, Width)); Ptr : Natural := 0; begin if Base = 10 and then Width = 0 then Set_Image (Item, Buf, Ptr); elsif Base = 10 then Set_Image_Width (Item, Width, Buf, Ptr); else Set_Image_Based (Item, Base, Width, Buf, Ptr); end if; Put_Item (File, Buf (1 .. Ptr)); end Put; ---------- -- Puts -- ---------- procedure Puts (To : out String; Item : Num; Base : Number_Base) is Buf : String (1 .. Integer'Max (Field'Last, To'Length)); Ptr : Natural := 0; begin if Base = 10 then Set_Image_Width (Item, To'Length, Buf, Ptr); else Set_Image_Based (Item, Base, To'Length, Buf, Ptr); end if; if Ptr > To'Length then raise Layout_Error; else To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr); end if; end Puts; end Ada.Wide_Text_IO.Integer_Aux;
jscparker/math_packages
Ada
11,772
ads
-- package Spline -- -- Package of cubic splines, for interpolation, integration, -- and differentiation of tabulated data. -- -- Splines of this sort are especially useful for smooth data -- sets (Y_1, Y_2, ... Y_n) defined at unequally spaced -- knots: X_1, X_2, X_3, ... X_n. They are not least squares -- fits, so they are not much use for fitting noisy data. -- -- The splines are, optionally, Natural or Clamped, at either end -- point. The user inputs a value for either the derivative of the -- curve of the second derivative of the curve at the end points. If -- the user sets the second derivative of the curve to 0.0 at the -- end point, then the spline (at that end point) is called Natural. -- (But the value of the 2nd derivative there can be anything.) If -- instead he chooses to input a value for the 1st derivative at the -- end point then the spline (at that end point) is called clamped. -- -- These spline routines are for interpolation, not curve fitting, -- so they are not normally useful for data with noise. (The -- interpolated curve produced passes through all of the data -- points input.) The user inputs points (X1,Y1) (X2,Y2)..(Xn,Yn). -- The X points are input as X_Data(i), the Y points as Y_Data(i). -- The spline interpolation algorithm creates a function F(X) such -- that (X, F(X)) passes through each the points input. -- The function F(X) can then be used predict the value of Y -- associated with a value of X that lies between Xm and Xm+1. -- -- The interpolated curve is a different 3rd order polynomial for -- each Xm. It gives the value of Y at point X near Xm according to: -- -- Y = F(X) = Ym + F(1,m)*(X-Xm) + F(2,m)*(X-Xm)^2 + F(3,m)*(X-Xm)^3, -- -- assuming that X satisfies Xm <= X < Xm+1. The Spline coefficients -- F(O,m) are calculated by solving equations -- derived from the requirement that the spline segments (given above) -- are continuous at each Xm, and have the same first and second -- derivatives at each Xm, (with the exception of m = n). However, -- at the first X and the last X, the spline segments may have -- zero valued second derivatives (Natural Splines). The user also -- has the option of inputting the values for the first derivatives -- at the end points (Clamped Splines). -- -- Notes on algorithm -- -- A cubic spline is a collection of third order polynomials S(X) -- connecting tabulated data points (X_i, Y_i): -- -- S_i(X) = Y_i + B_i * (X-X_i) + C_i * (X-X_i)**2 + D_i * (X-X_i)**3 -- -- Here the knots X_i are indexed on the range 0, 1, ..., N. So the -- spline segments are valid on the range i = 0,..N-1. -- In what follows, X_i+1 - X_i will be called h_i, the standard variable -- in numerical analysis texts for DeltaX. (In the code below these -- deltas will be called dX, and (B, C, D) will be (F(1), F(2), F(3)).) -- From the requirement that the polynomials S_i are continuous at the -- knots X = X_i, and have continuous 1st and 2nd derivatives there, you -- get the simultaneous equations, -- -- Y_i+1 = Y_i + B_i * h_i + C_i * h_i**2 + D_i * h_i**3 (1) -- -- B_i+1 = B_i + 2 * C_i * h_i + 3 * D_i * h_i**2 (2) -- -- C_i+1 = C_i + 3 * D_i * h_i (3) -- -- These are valid on the range i = 0,..,N-1. At the end points, -- X_0 and X_N, there are no equations; we must impose some value on -- the 1st or the 2nd derivative of Y there. -- So these are the equations to solve for B, C, and D, given Y and -- h_i. To solve these we eliminate B and D from the equations, and -- solve for C. (We also need to imput boundary conditions into the -- the equations, by fixing either the 1st of 2nd derivative of Y at -- the end points.) First eliminate D from equations (1) and (2) by -- solving for D in (3), and substituting into (1) and (2): -- -- Y_i+1 = Y_i + B_i * h_i + (2*C_i +C_i+1) * h_i**2 / 3 (4) -- -- B_i+1 = B_i + (C_i + C_i+1) * h_i (5) -- -- Again, i = 0,..,N-1. -- Finally, solve for B_i in (4), reduce the Indices by one, and plug -- into (5) to get equations solely in terms of C_i: -- -- h_j-1*C_j-1 + 2(h(j-1 + h_j)*C_j + h_j*C_j+1 = 3*dY_i/h_i - 3*dY_i-1/h_i-1 -- -- where dY_i = Y_i+1 - Y_i and where i is in 1,...,N-1. So we now -- have N-1 equations for N+1 variables C_i, where i is in 0,...,N. -- The last two equations will come from boundary conditions at -- X_0 and X_N. Remember that C is twice the second derivative of Y -- so that if we impose a value on the second derivative of Y at the -- end points, (call it Y_dot_dot), then we have the final two equations: -- C_0 = Y_dot_dot_First / 2, and C_N = Y_dot_dot_Last / 2. Suppose -- instead we wish to impose a value on the 1st derivative of Y at -- one or both end points. (Call it Y_dot.) This is trickier. The -- equations are B_0 = Y_dot_First, and B_N = Y_dot_Last. The full -- equations are in terms of the variable C, so we must eliminate B from -- the above two with equ. (4) for the i=0 end point and equ. (5) -- substituted into (4) for the i=n end point. At i=0 we get, -- -- Y_dot_First = B_0 = (Y_i+1 - Y_i)/h_i - (2*C_i + C_i+1)*h_i/3 (i=0) -- -- Y_dot_Last = B_n = B_n-1 + (C_n-1 + C_n)*h_n-1 (i=n) -- -- The first equation above is -- -- 2*h_0*C_0 + h_0*C_1 = -3*Y_dot_First + 3*(Y_1 - Y_0)/h_0 -- -- The second equation above is plugged into (4) at i=n-1 to give -- -- h_n-1*C_n-1 + 2*h_n-1*C_n = 3*Y_dot_Last - 3*(Y_n - Y_n-1)/h_n-1. -- -- So at either end point you can specify Y_dot or Y_dot_dot to get -- unique solutions of the equations that establish continuity of the -- cubic polynomial spline segments and their first two derivatives. -- -- Sometimes mixed boundary conditions are required. Instead of specifying -- Y_dot or Y_dot_dot, you impose a value on Alpha*Y_dot_dot + Beta*Y_dot. -- (A common reason for doing this is that the solutions of some PDE -- equations have boundary conditions of this sort.) It should -- be clear how to do this now. The two alternatives at the first end -- point are: -- -- 2*h_0*C_0 + h_0*C_1 = -3*Y_dot_First + 3*(Y_1 - Y_0)/h_0, -- -- C_0 = Y_dot_dot_first / 2. -- -- Multiply the second equation by -6*Alpha, multiply the first -- equation by Beta, add them together to get: -- -- (2*h_0*Beta - 6*Alpha)*C_0 + Beta*h_0*C_1 -- = -3*(Alpha*Y_dot_dot_First + Beta*Y_dot_First) + -- + 3*Beta*(Y_1 - Y_0)/h_0. -- -- Impose a value Boundary_Value_First = Alpha*Y_dot_dot + Beta*Y_dot: -- -- (2*h_0*Beta - 6*Alpha)*C_0 + Beta*h_0*C_1 -- = -3*Boundary_Value_First + 3*Beta*(Y_1 - Y_0)/h_0. -- -- At the other end set Boundary_Value_Last = Alpha2*Y_dot_dot + Beta2*Y_dot, -- to get: -- -- (2*h_n-1*Beta2 + 6*Alpha2)*C_n + Beta2*h_n-1*C_n-1 -- = 3*Boundary_Value_Last - 3*Beta2*(Y_n - Y_n-1)/h_n-1. -- -- (Might not always find solutions for arbitrary values of Alpha, Beta, -- and Boundary_Value.) -- with Tridiagonal_LU; generic type Real is digits <>; type Index is range <>; type Data_Vector is array(Index) of Real; package Spline is type Coefficients is array(1..3) of Data_Vector; type Spline_Coefficients is record F : Coefficients; I_Start : Index; I_Finish : Index; end record; -- For each boundary point, the following boundary condition is defined: -- -- Alpha * Y_dot_dot + Beta * Y_dot = Boundary_Val. -- -- If Alpha = 1 and Beta = 0 then the boundary condition is that the -- the 2nd derivative of the curve Y_dot_dot is set to value -- Boundary_Val. (if then Boundary_Val is 0.0, then this is called a -- Natural spline.) If Alpha = 0 and Beta = 1 then the boundary condition -- is that the 1st derivative of the curve Y_dot is set to a value -- Boundary_Val. This is called a clamped spline. In the two special -- cases given above, a unique spline exists and can be calculated by -- the routines below. In some cases mixed boundary conditions are -- required, Alpha and Beta both non-zero. In this case we can't -- guarantee that a unique spline can be found satisfying this boundary -- condition and satisfying the equations of continuity. Use with -- care under these circumstances. This option is provided because -- some differential equations satisfy mixed boundary conditions. type Boundary is record Alpha : Real := 1.0; Beta : Real := 0.0; Boundary_Val : Real := 0.0; end record; Natural_BC : constant Boundary := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 0.0); -- Procedure Prepare_X_Data -- prepares the data Arrays for use by Get_Spline. -- It's a separate procedure so that it can be removed -- from inner loops .. might call this once, and Get_Spline many -- times. The procedure only cares about the X positions of the -- knots (X(i)). In many problems the knots remain constant, but -- the Y values (Y(i)) change in an inner loop. -- The procedure also performs the LU decomposition in preparation -- for solution of the coupled equations that determine the -- spline coefficients. type X_Structure is limited private; procedure Prepare_X_Data (X_Stuff : out X_Structure; X_Data : in Data_Vector; I_Start : in Index := Index'first; I_Finish : in Index := Index'Last; Bound_First : in Boundary := Natural_BC; Bound_Last : in Boundary := Natural_BC); -- Procedure Get_Spline -- calculates the coefficients of powers of X in the cubic -- spline polynomial: F(1), F(2), and F(3). (These F's are -- in the record Spline.) If Ym and and Xm are elements of -- the set of data points being fit with a spline (the knots), -- then a value of the function Y where Ym <= Y < Ym+1 -- is given by the interpolation formula: -- -- Y = Ym + F(1,m)*(X-Xm) + F(2,m)*(X-Xm)^2 + F(3,m)*(X-Xm)^3, -- -- Procedure Get_Spline only calculates Spline.F. To get Y at points -- not equal to Ym, Ym=1 etc, use function Value_At. -- -- Notice that the 1st derivatives of the spline at the data points -- (Xm, Ym) are given by F(1,m), the second derivatives are given -- by 2*F(2,m) and the 3rd derivative by 6*F(3,m). To get derivatives -- of the spline away from the data points (knots), one must use -- the interpolatory formulas derived from the equation for Y above. procedure Get_Spline (Spline : out Spline_Coefficients; X_Stuff : in X_Structure; Y_Data : in Data_Vector); function Value_At (X : in Real; X_Data : in Data_Vector; Y_Data : in Data_Vector; Spline : in Spline_Coefficients) return Real; function First_Derivative_At (X : in Real; X_Data : in Data_Vector; Spline : in Spline_Coefficients) return Real; function Second_Derivative_At (X : in Real; X_Data : in Data_Vector; Spline : in Spline_Coefficients) return Real; -- Second_Derivative_At is highly inaccurate. function Integral (X_Data : in Data_Vector; Y_Data : in Data_Vector; Spline : in Spline_Coefficients) return Real; Must_Call_Prepare_X_Data_First : exception; private package Tri is new Tridiagonal_LU (Real, Index); type X_Structure is record Initialized : Boolean := False; dX : Data_Vector := (others => 0.0); dX_Inverse : Data_Vector := (others => 0.0); M : Tri.Matrix := (others => (others => 0.0)); I_Start : Index := Index'First; I_Finish : Index := Index'Last; Bound_First : Boundary := Natural_BC; Bound_Last : Boundary := Natural_BC; end record; end Spline;
Fabien-Chouteau/GESTE
Ada
4,063
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_SDL_stdinc_h; with Interfaces.C.Strings; package SDL_SDL_cdrom_h is SDL_MAX_TRACKS : constant := 99; -- ../include/SDL/SDL_cdrom.h:48 SDL_AUDIO_TRACK : constant := 16#00#; -- ../include/SDL/SDL_cdrom.h:54 SDL_DATA_TRACK : constant := 16#04#; -- ../include/SDL/SDL_cdrom.h:55 -- arg-macro: function CD_INDRIVE (status) -- return (int)(status) > 0; CD_FPS : constant := 75; -- ../include/SDL/SDL_cdrom.h:96 -- arg-macro: procedure FRAMES_TO_MSF (f, M, S, F) -- { int value := f; *(F) := valuemodCD_FPS; value /= CD_FPS; *(S) := valuemod60; value /= 60; *(M) := value; } -- arg-macro: function MSF_TO_FRAMES (M, S, F) -- return (M)*60*CD_FPS+(S)*CD_FPS+(F); subtype CDstatus is unsigned; CD_TRAYEMPTY : constant CDstatus := 0; CD_STOPPED : constant CDstatus := 1; CD_PLAYING : constant CDstatus := 2; CD_PAUSED : constant CDstatus := 3; CD_ERROR : constant CDstatus := -1; -- ../include/SDL/SDL_cdrom.h:65 type SDL_CDtrack is record id : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_cdrom.h:71 c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_cdrom.h:72 unused : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_cdrom.h:73 length : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_cdrom.h:74 offset : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_cdrom.h:75 end record; pragma Convention (C_Pass_By_Copy, SDL_CDtrack); -- ../include/SDL/SDL_cdrom.h:70 type SDL_CD_track_array is array (0 .. 99) of aliased SDL_CDtrack; type SDL_CD is record id : aliased int; -- ../include/SDL/SDL_cdrom.h:80 status : aliased CDstatus; -- ../include/SDL/SDL_cdrom.h:81 numtracks : aliased int; -- ../include/SDL/SDL_cdrom.h:85 cur_track : aliased int; -- ../include/SDL/SDL_cdrom.h:86 cur_frame : aliased int; -- ../include/SDL/SDL_cdrom.h:87 track : aliased SDL_CD_track_array; -- ../include/SDL/SDL_cdrom.h:88 end record; pragma Convention (C_Pass_By_Copy, SDL_CD); -- ../include/SDL/SDL_cdrom.h:79 function SDL_CDNumDrives return int; -- ../include/SDL/SDL_cdrom.h:114 pragma Import (C, SDL_CDNumDrives, "SDL_CDNumDrives"); function SDL_CDName (drive : int) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_cdrom.h:123 pragma Import (C, SDL_CDName, "SDL_CDName"); function SDL_CDOpen (drive : int) return access SDL_CD; -- ../include/SDL/SDL_cdrom.h:132 pragma Import (C, SDL_CDOpen, "SDL_CDOpen"); function SDL_CDStatus (cdrom : access SDL_CD) return CDstatus; -- ../include/SDL/SDL_cdrom.h:139 pragma Import (C, SDL_CDStatus, "SDL_CDStatus"); function SDL_CDPlayTracks (cdrom : access SDL_CD; start_track : int; start_frame : int; ntracks : int; nframes : int) return int; -- ../include/SDL/SDL_cdrom.h:163 pragma Import (C, SDL_CDPlayTracks, "SDL_CDPlayTracks"); function SDL_CDPlay (cdrom : access SDL_CD; start : int; length : int) return int; -- ../include/SDL/SDL_cdrom.h:170 pragma Import (C, SDL_CDPlay, "SDL_CDPlay"); function SDL_CDPause (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:175 pragma Import (C, SDL_CDPause, "SDL_CDPause"); function SDL_CDResume (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:180 pragma Import (C, SDL_CDResume, "SDL_CDResume"); function SDL_CDStop (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:185 pragma Import (C, SDL_CDStop, "SDL_CDStop"); function SDL_CDEject (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:190 pragma Import (C, SDL_CDEject, "SDL_CDEject"); procedure SDL_CDClose (cdrom : access SDL_CD); -- ../include/SDL/SDL_cdrom.h:193 pragma Import (C, SDL_CDClose, "SDL_CDClose"); end SDL_SDL_cdrom_h;
zhmu/ananas
Ada
3,906
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V A L _ L L U -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines for scanning modular Long_Long_Unsigned -- values for use in Text_IO.Modular_IO, and the Value attribute. -- Preconditions in this unit are meant for analysis only, not for run-time -- checking, so that the expected exceptions are raised. This is enforced by -- setting the corresponding assertion policy to Ignore. Postconditions and -- contract cases should not be executed at runtime as well, in order not to -- slow down the execution of these functions. pragma Assertion_Policy (Pre => Ignore, Post => Ignore, Contract_Cases => Ignore, Ghost => Ignore, Subprogram_Variant => Ignore); with System.Unsigned_Types; with System.Value_U; package System.Val_LLU with SPARK_Mode is pragma Preelaborate; subtype Long_Long_Unsigned is Unsigned_Types.Long_Long_Unsigned; package Impl is new Value_U (Long_Long_Unsigned); procedure Scan_Raw_Long_Long_Unsigned (Str : String; Ptr : not null access Integer; Max : Integer; Res : out Long_Long_Unsigned) renames Impl.Scan_Raw_Unsigned; procedure Scan_Long_Long_Unsigned (Str : String; Ptr : not null access Integer; Max : Integer; Res : out Long_Long_Unsigned) renames Impl.Scan_Unsigned; function Value_Long_Long_Unsigned (Str : String) return Long_Long_Unsigned renames Impl.Value_Unsigned; end System.Val_LLU;
reznikmm/matreshka
Ada
4,869
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- Initial implementation of SAX writer has bugs in namespace mapping -- management. ------------------------------------------------------------------------------ with Ada.Command_Line; with League.Characters; with League.Strings; with Put_Line; with Read_File; with XML.SAX.Pretty_Writers; with XML.SAX.Simple_Readers; with XML.SAX.String_Input_Sources; with XML.SAX.String_Output_Destinations; procedure Test_126 is use type League.Strings.Universal_String; Source : aliased XML.SAX.String_Input_Sources.String_Input_Source; Output : aliased XML.SAX.String_Output_Destinations.String_Output_Destination; Reader : aliased XML.SAX.Simple_Readers.Simple_Reader; Writer : aliased XML.SAX.Pretty_Writers.XML_Pretty_Writer; Root : constant String := Ada.Command_Line.Argument (1); Input : constant League.Strings.Universal_String := Read_File (Root & "a.xml"); Expected : constant League.Strings.Universal_String := Read_File (Root & "a-expected.xml"); begin Reader.Set_Content_Handler (Writer'Unchecked_Access); Writer.Set_Output_Destination (Output'Unchecked_Access); Writer.Set_Value_Delimiter (League.Characters.To_Universal_Character ('"')); -- Parse XML document. Source.Set_String (Input); Reader.Parse (Source'Access); -- Check output document. if Output.Get_Text /= Expected then Put_Line ("Expected: '" & Expected & '''); Put_Line ("Actual : '" & Output.Get_Text & '''); raise Program_Error; end if; end Test_126;
reznikmm/gela
Ada
18,952
adb
------------------------------------------------------------------------------ -- G E L A G R A M M A R S -- -- Library for dealing with grammars for for Gela project, -- -- a portable Ada compiler -- -- http://gela.ada-ru.org/ -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license in gela.ads file -- ------------------------------------------------------------------------------ with League.Characters; with League.Strings; with Gela.Lexical_Types; use Gela.Lexical_Types; package body Gela.Lexical_Handler is function To_Token (X : League.Strings.Universal_String) return Gela.Lexical_Types.Token_Kind; -- Convert folded text to token subtype Hash_Value is Positive range 2 + 2 * 6 .. 12 + 3 * 115; function Hash (W : League.Strings.Universal_String) return Hash_Value; Map : constant array (Gela.Scanner_Types.Rule_Index range 1 .. 27) of Gela.Lexical_Types.Token_Kind := (1 => Arrow_Token, 2 => Double_Dot_Token, 3 => Double_Star_Token, 4 => Assignment_Token, 5 => Inequality_Token, 6 => Greater_Or_Equal_Token, 7 => Less_Or_Equal_Token, 8 => Left_Label_Token, 9 => Right_Label_Token, 10 => Box_Token, 11 => Ampersand_Token, 12 => Apostrophe_Token, 13 => Left_Parenthesis_Token, 14 => Right_Parenthesis_Token, 15 => Star_Token, 16 => Plus_Token, 17 => Comma_Token, 18 => Hyphen_Token, 19 => Dot_Token, 20 => Slash_Token, 21 => Colon_Token, 22 => Semicolon_Token, 23 => Less_Token, 24 => Equal_Token, 25 => Greater_Token, 26 => Vertical_Line_Token, 27 => Vertical_Line_Token); Id : constant Gela.Lexical_Types.Token_Kind := Gela.Lexical_Types.Identifier_Token; -- generated by gperf -m 100 Word_Map : constant array (Hash_Value range 22 .. 114) of Gela.Lexical_Types.Token_Kind := (Gela.Lexical_Types.Else_Token, Gela.Lexical_Types.At_Token, Gela.Lexical_Types.Task_Token, Gela.Lexical_Types.Then_Token, Gela.Lexical_Types.Not_Token, Gela.Lexical_Types.Range_Token, Gela.Lexical_Types.Abs_Token, Gela.Lexical_Types.Renames_Token, Gela.Lexical_Types.Return_Token, Gela.Lexical_Types.End_Token, Gela.Lexical_Types.Terminate_Token, Gela.Lexical_Types.Case_Token, Gela.Lexical_Types.Xor_Token, Gela.Lexical_Types.Abstract_Token, Gela.Lexical_Types.Synchronized_Token, Gela.Lexical_Types.Reverse_Token, Gela.Lexical_Types.And_Token, Gela.Lexical_Types.Exception_Token, Gela.Lexical_Types.Constant_Token, Gela.Lexical_Types.Declare_Token, Gela.Lexical_Types.Access_Token, Gela.Lexical_Types.Record_Token, Gela.Lexical_Types.Accept_Token, Gela.Lexical_Types.Is_Token, Gela.Lexical_Types.In_Token, Gela.Lexical_Types.Type_Token, Gela.Lexical_Types.Entry_Token, Gela.Lexical_Types.Separate_Token, Gela.Lexical_Types.Or_Token, Gela.Lexical_Types.Requeue_Token, Gela.Lexical_Types.Do_Token, Gela.Lexical_Types.Select_Token, Gela.Lexical_Types.When_Token, Gela.Lexical_Types.Exit_Token, Gela.Lexical_Types.Array_Token, Gela.Lexical_Types.Raise_Token, Gela.Lexical_Types.Out_Token, Gela.Lexical_Types.Package_Token, Gela.Lexical_Types.Interface_Token, Gela.Lexical_Types.Pragma_Token, Gela.Lexical_Types.Delta_Token, Gela.Lexical_Types.Use_Token, Gela.Lexical_Types.Digits_Token, Gela.Lexical_Types.Abort_Token, Gela.Lexical_Types.Tagged_Token, Gela.Lexical_Types.Some_Token, Gela.Lexical_Types.Aliased_Token, Gela.Lexical_Types.Elsif_Token, Gela.Lexical_Types.Subtype_Token, Id, Gela.Lexical_Types.Generic_Token, Gela.Lexical_Types.For_Token, Gela.Lexical_Types.Function_Token, Id, Gela.Lexical_Types.Mod_Token, Gela.Lexical_Types.Null_Token, Gela.Lexical_Types.Delay_Token, Gela.Lexical_Types.Private_Token, Id, Id, Gela.Lexical_Types.All_Token, Gela.Lexical_Types.Procedure_Token, Gela.Lexical_Types.New_Token, Gela.Lexical_Types.While_Token, Id, Gela.Lexical_Types.With_Token, Gela.Lexical_Types.Protected_Token, Gela.Lexical_Types.Others_Token, Id, Gela.Lexical_Types.If_Token, Gela.Lexical_Types.Goto_Token, Gela.Lexical_Types.Of_Token, Gela.Lexical_Types.Until_Token, Gela.Lexical_Types.Body_Token, Gela.Lexical_Types.Overriding_Token, Id, Id, Id, Id, Id, Gela.Lexical_Types.Limited_Token, Id, Gela.Lexical_Types.Begin_Token, Gela.Lexical_Types.Loop_Token, Id, Id, Id, Id, Id, Id, Id, Id, Gela.Lexical_Types.Rem_Token); type Universal_String_Array is array (Hash_Value range 22 .. 114) of League.Strings.Universal_String; type Universal_String_Array_Access is access all Universal_String_Array; Word_List : Universal_String_Array_Access; ----------------------- -- Character_Literal -- ----------------------- overriding procedure Character_Literal (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); Length : constant Positive := Scanner.Get_Token_Length; Value : Gela.Lexical_Types.Token; Text : constant League.Strings.Universal_String := Scanner.Get_Text; Symbol : constant Gela.Lexical_Types.Symbol := Self.Symbols.Get (Text); begin Scanner.Set_Start_Condition (Gela.Scanner_Types.Allow_Char); Token := Gela.Lexical_Types.Character_Literal_Token; Skip := False; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => Symbol); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Separator := Self.Last; Self.Last_Token := Token; end Character_Literal; ------------- -- Comment -- ------------- overriding procedure Comment (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); pragma Unreferenced (Token); Length : constant Positive := Scanner.Get_Token_Length; begin Skip := True; Self.Comment := Self.Last; Self.Last := Self.Last + Length; end Comment; --------------- -- Delimiter -- --------------- overriding procedure Delimiter (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is Length : constant Positive := Scanner.Get_Token_Length; Value : Gela.Lexical_Types.Token; Text : League.Strings.Universal_String; Symbol : Gela.Lexical_Types.Symbol; begin Text.Append ('"'); Text.Append (Scanner.Get_Text); Text.Append ('"'); Self.Symbols.Fetch (Text, Symbol); Scanner.Set_Start_Condition (Gela.Scanner_Types.Allow_Char); Token := Map (Rule); Skip := False; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => Symbol); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Separator := Self.Last; Self.Last_Token := Token; end Delimiter; ----------- -- Error -- ----------- overriding procedure Error (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); Length : constant Positive := Scanner.Get_Token_Length; Value : Gela.Lexical_Types.Token; begin Token := Gela.Lexical_Types.Error; Skip := True; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => 0); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Last_Token := Token; end Error; ---------- -- Hash -- ---------- function Hash (W : League.Strings.Universal_String) return Hash_Value is X : constant array (Wide_Wide_Character range 'a' .. 'y') of Positive := (13, 51, 17, 11, 6, 52, 41, 38, 37, 115, 6, 33, 51, 7, 39, 29, 29, 9, 6, 8, 48, 15, 37, 13, 29); function Y (Z : League.Characters.Universal_Character) return Positive; function Y (Z : League.Characters.Universal_Character) return Positive is Val : constant Wide_Wide_Character := Z.To_Wide_Wide_Character; begin if Val in X'Range then return X (Val); else return 115; end if; end Y; Length : constant Positive := W.Length; Result : Positive := Length; -- 2 .. 12 begin if Length > 2 then Result := Result + Y (W.Element (3)); -- 6 .. 115 end if; Result := Result + Y (W.Element (1)); -- 6 .. 115 Result := Result + Y (W.Element (Length)); -- 6 .. 115 return Result; end Hash; ---------------- -- Identifier -- ---------------- overriding procedure Identifier (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); Length : constant Positive := Scanner.Get_Token_Length; Text : constant League.Strings.Universal_String := Scanner.Get_Text; Value : Gela.Lexical_Types.Token; Symbol : Gela.Lexical_Types.Symbol; begin Self.Symbols.Fetch (Text, Symbol); Token := To_Token (Self.Symbols.Folded (Symbol)); Skip := False; if Self.Last_Token = Gela.Lexical_Types.Apostrophe_Token and Token /= Gela.Lexical_Types.Range_Token then Token := Id; end if; if Token = Id then Scanner.Set_Start_Condition (Gela.Scanner_Types.INITIAL); else Scanner.Set_Start_Condition (Gela.Scanner_Types.Allow_Char); end if; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => Symbol); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Separator := Self.Last; Self.Last_Token := Token; end Identifier; ---------------- -- Initialize -- ---------------- procedure Initialize is function "+" (Left : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Nil : constant League.Strings.Universal_String := League.Strings.Empty_Universal_String; begin Word_List := new Universal_String_Array' (+"else", +"at", +"task", +"then", +"not", +"range", +"abs", +"renames", +"return", +"end", +"terminate", +"case", +"xor", +"abstract", +"synchronized", +"reverse", +"and", +"exception", +"constant", +"declare", +"access", +"record", +"accept", +"is", +"in", +"type", +"entry", +"separate", +"or", +"requeue", +"do", +"select", +"when", +"exit", +"array", +"raise", +"out", +"package", +"interface", +"pragma", +"delta", +"use", +"digits", +"abort", +"tagged", +"some", +"aliased", +"elsif", +"subtype", Nil, +"generic", +"for", +"function", Nil, +"mod", +"null", +"delay", +"private", Nil, Nil, +"all", +"procedure", +"new", +"while", Nil, +"with", +"protected", +"others", Nil, +"if", +"goto", +"of", +"until", +"body", +"overriding", Nil, Nil, Nil, Nil, Nil, +"limited", Nil, +"begin", +"loop", Nil, Nil, Nil, Nil, Nil, Nil, Nil, Nil, +"rem"); end Initialize; -------------- -- New_Line -- -------------- overriding procedure New_Line (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); pragma Unreferenced (Token); Length : constant Positive := Scanner.Get_Token_Length; Comment : Text_Index; Value : Gela.Lexical_Types.Line_Span; begin Skip := True; if Self.Comment >= Self.Line_First then Comment := Self.Comment; else Comment := Self.Last + 1; end if; Value := (First => Self.Line_First, Last => Self.Last - 1, Comment => Comment); Self.Output.New_Line (Value); Self.Last := Self.Last + Length; Self.Line := Self.Line + 1; Self.Line_First := Self.Last; end New_Line; --------------------- -- Numeric_Literal -- --------------------- overriding procedure Numeric_Literal (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); Length : constant Positive := Scanner.Get_Token_Length; Value : Gela.Lexical_Types.Token; begin Scanner.Set_Start_Condition (Gela.Scanner_Types.Allow_Char); Token := Gela.Lexical_Types.Numeric_Literal_Token; Skip := False; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => 0); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Separator := Self.Last; Self.Last_Token := Token; end Numeric_Literal; --------------------------------- -- Obsolescent_Numeric_Literal -- --------------------------------- overriding procedure Obsolescent_Numeric_Literal (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) renames Numeric_Literal; -------------------------------- -- Obsolescent_String_Literal -- -------------------------------- overriding procedure Obsolescent_String_Literal (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) renames String_Literal; ----------- -- Space -- ----------- overriding procedure Space (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); pragma Unreferenced (Token); Length : constant Positive := Scanner.Get_Token_Length; begin Skip := True; Self.Last := Self.Last + Length; end Space; -------------------- -- String_Literal -- -------------------- overriding procedure String_Literal (Self : not null access Handler; Scanner : not null access Gela.Scanners.Scanner'Class; Rule : Gela.Scanner_Types.Rule_Index; Token : out Gela.Lexical_Types.Token_Kind; Skip : in out Boolean) is pragma Unreferenced (Rule); Length : constant Positive := Scanner.Get_Token_Length; Text : constant League.Strings.Universal_String := Scanner.Get_Text; Value : Gela.Lexical_Types.Token; Symbol : constant Gela.Lexical_Types.Symbol := Self.Symbols.Get (Text); begin Scanner.Set_Start_Condition (Gela.Scanner_Types.Allow_Char); Token := Gela.Lexical_Types.String_Literal_Token; Skip := False; Value := (Line => Self.Line, First => Self.Last, Last => Self.Last + Length - 1, Separator => Self.Separator, Kind => Token, Symbol => Symbol); Self.Output.New_Token (Value); Self.Last := Self.Last + Length; Self.Separator := Self.Last; Self.Last_Token := Token; end String_Literal; -------------- -- To_Token -- -------------- function To_Token (X : League.Strings.Universal_String) return Gela.Lexical_Types.Token_Kind is use type League.Strings.Universal_String; H : Hash_Value; begin if X.Length in 2 .. 12 then H := Hash (X); if H in Word_List'Range and then Word_List (H) = X then return Word_Map (H); else return Gela.Lexical_Types.Identifier_Token; end if; else return Gela.Lexical_Types.Identifier_Token; end if; end To_Token; end Gela.Lexical_Handler;
zhmu/ananas
Ada
104
adb
-- { dg-do compile } package body Nested_Generic2 is procedure Dummy is null; end Nested_Generic2;
AdaCore/Ada_Drivers_Library
Ada
5,235
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; package body nRF.Events is function To_UInt32 is new Ada.Unchecked_Conversion (System.Address, UInt32); function To_Address is new Ada.Unchecked_Conversion (UInt32, System.Address); --------------- -- Triggered -- --------------- function Triggered (Evt : Event_Type) return Boolean is Reg : UInt32; for Reg'Address use System.Address (Evt); begin return Reg /= 0; end Triggered; ---------------------- -- Enable_Interrupt -- ---------------------- procedure Enable_Interrupt (Evt : Event_Type) is Reg_Addr : constant UInt32 := To_UInt32 (System.Address (Evt)); Device_Base : constant UInt32 := Reg_Addr and 16#FFFF_F000#; Event_Index : constant UInt7 := UInt7 (Reg_Addr and 16#0000_007F#) / 4; -- The bit corresponding to an event is determined by the offset of the -- event. (nRF Series Reference Manual, section 9.1.6) Set_Register_Addr : constant UInt32 := Device_Base + 16#0000_0304#; -- For each device the "Interrupt enable set register" is always located -- at the same offset: 0x304. (nRF Series Reference Manual, -- section 9.1.6) Set_Register : UInt32 with Address => To_Address (Set_Register_Addr); begin Set_Register := 2**Natural (Event_Index); end Enable_Interrupt; ----------------------- -- Disable_Interrupt -- ----------------------- procedure Disable_Interrupt (Evt : Event_Type) is Reg_Addr : constant UInt32 := To_UInt32 (System.Address (Evt)); Device_Base : constant UInt32 := Reg_Addr and 16#FFFF_F000#; Event_Index : constant UInt7 := UInt7 (Reg_Addr and 16#0000_007F#) / 4; -- The bit corresponding to an event is determined by the offset of the -- event. (nRF Series Reference Manual, section 9.1.6) Clear_Register_Addr : constant UInt32 := Device_Base + 16#0000_0308#; -- For each device the "Interrupt enable clear register" is always -- located at the same offset: 0x308. (nRF Series Reference Manual, -- section 9.1.6) Clear_Register : UInt32 with Address => To_Address (Clear_Register_Addr); begin Clear_Register := 2**Natural (Event_Index); end Disable_Interrupt; ----------- -- Clear -- ----------- procedure Clear (Evt : Event_Type) is Reg : UInt32 with Address => System.Address (Evt); begin Reg := 0; end Clear; ----------------- -- Get_Address -- ----------------- function Get_Address (Evt : Event_Type) return System.Address is begin return System.Address (Evt); end Get_Address; ----------------- -- Get_Address -- ----------------- function Get_Address (Evt : Event_Type) return UInt32 is begin return To_UInt32 (System.Address (Evt)); end Get_Address; end nRF.Events;
reznikmm/matreshka
Ada
3,884
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal is type Draw_Start_Line_Spacing_Horizontal_Node is new Matreshka.ODF_Attributes.Draw.Draw_Node_Base with null record; type Draw_Start_Line_Spacing_Horizontal_Access is access all Draw_Start_Line_Spacing_Horizontal_Node'Class; overriding function Get_Local_Name (Self : not null access constant Draw_Start_Line_Spacing_Horizontal_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
4,918
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f407xx.h et al. -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides register definitions for the STM32 (ARM Cortex M4/7F) -- microcontrollers from ST Microelectronics. package STM32GD.EXTI is pragma Preelaborate; type External_Line_Number is (EXTI_Line_0, EXTI_Line_1, EXTI_Line_2, EXTI_Line_3, EXTI_Line_4, EXTI_Line_5, EXTI_Line_6, EXTI_Line_7, EXTI_Line_8, EXTI_Line_9, EXTI_Line_10, EXTI_Line_11, EXTI_Line_12, EXTI_Line_13, EXTI_Line_14, EXTI_Line_15, EXTI_Line_16, EXTI_Line_17, EXTI_Line_18, EXTI_Line_19); type External_Triggers is (Interrupt_Rising_Edge, Interrupt_Falling_Edge, Interrupt_Rising_Falling_Edge, Event_Rising_Edge, Event_Falling_Edge, Event_Rising_Falling_Edge); subtype Interrupt_Triggers is External_Triggers range Interrupt_Rising_Edge .. Interrupt_Rising_Falling_Edge; subtype Event_Triggers is External_Triggers range Event_Rising_Edge .. Event_Rising_Falling_Edge; procedure Enable_External_Interrupt (Line : External_Line_Number; Trigger : Interrupt_Triggers) with Inline; procedure Disable_External_Interrupt (Line : External_Line_Number) with Inline; procedure Enable_External_Event (Line : External_Line_Number; Trigger : Event_Triggers) with Inline; procedure Disable_External_Event (Line : External_Line_Number) with Inline; procedure Generate_SWI (Line : External_Line_Number) with Inline; function External_Interrupt_Pending (Line : External_Line_Number) return Boolean with Inline; procedure Clear_External_Interrupt (Line : External_Line_Number) with Inline; end STM32GD.EXTI;
reznikmm/matreshka
Ada
3,554
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Application; with CSMIB.Generator; with CSMIB.Parser; procedure CSMIB.Driver is begin CSMIB.Parser.Parse (League.Application.Arguments.Element (1)); CSMIB.Generator.Generate; end CSMIB.Driver;
gerph/PrivateEye
Ada
5,997
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.adb,v 1.1.1.1 2005-10-29 18:01:49 dpt Exp $ with Ada.Unchecked_Deallocation; package body ZLib.Streams is ----------- -- Close -- ----------- procedure Close (Stream : in out Stream_Type) is procedure Free is new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access); begin if Stream.Mode = Out_Stream or Stream.Mode = Duplex then -- We should flush the data written by the writer. Flush (Stream, Finish); Close (Stream.Writer); end if; if Stream.Mode = In_Stream or Stream.Mode = Duplex then Close (Stream.Reader); Free (Stream.Buffer); end if; end Close; ------------ -- Create -- ------------ procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size) is subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean); ----------------- -- Init_Filter -- ----------------- procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean) is begin if Compress then Deflate_Init (Filter, Level, Strategy, Header => Header); else Inflate_Init (Filter, Header => Header); end if; end Init_Filter; begin Stream.Back := Back; Stream.Mode := Mode; if Mode = Out_Stream or Mode = Duplex then Init_Filter (Stream.Writer, Back_Compressed); Stream.Buffer_Size := Write_Buffer_Size; else Stream.Buffer_Size := 0; end if; if Mode = In_Stream or Mode = Duplex then Init_Filter (Stream.Reader, not Back_Compressed); Stream.Buffer := new Buffer_Subtype; Stream.Rest_First := Stream.Buffer'Last + 1; Stream.Rest_Last := Stream.Buffer'Last; end if; end Create; ----------- -- Flush -- ----------- procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush) is Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); Last : Stream_Element_Offset; begin loop Flush (Stream.Writer, Buffer, Last, Mode); Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Flush; ------------- -- Is_Open -- ------------- function Is_Open (Stream : Stream_Type) return Boolean is begin return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); end Is_Open; ---------- -- Read -- ---------- procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Ada.Streams.Read (Stream.Back.all, Item, Last); end Read; procedure Read is new ZLib.Read (Read => Read, Buffer => Stream.Buffer.all, Rest_First => Stream.Rest_First, Rest_Last => Stream.Rest_Last); begin Read (Stream.Reader, Item, Last); end Read; ------------------- -- Read_Total_In -- ------------------- function Read_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Reader); end Read_Total_In; -------------------- -- Read_Total_Out -- -------------------- function Read_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Reader); end Read_Total_Out; ----------- -- Write -- ----------- procedure Write (Stream : in out Stream_Type; Item : in Stream_Element_Array) is procedure Write (Item : in Stream_Element_Array); ----------- -- Write -- ----------- procedure Write (Item : in Stream_Element_Array) is begin Ada.Streams.Write (Stream.Back.all, Item); end Write; procedure Write is new ZLib.Write (Write => Write, Buffer_Size => Stream.Buffer_Size); begin Write (Stream.Writer, Item, No_Flush); end Write; -------------------- -- Write_Total_In -- -------------------- function Write_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Writer); end Write_Total_In; --------------------- -- Write_Total_Out -- --------------------- function Write_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Writer); end Write_Total_Out; end ZLib.Streams;
sungyeon/drake
Ada
3,834
ads
pragma License (Unrestricted); -- implementation unit required by compiler package System.Fat_Lflt is pragma Pure; package Attr_Long_Float is -- required for Long_Float'Adjacent by compiler (s-fatgen.ads) function Adjacent (X, Towards : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nextafter"; -- required for Long_Float'Ceiling by compiler (s-fatgen.ads) function Ceiling (X : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_ceil"; -- required for Long_Float'Compose by compiler (s-fatgen.ads) function Compose (Fraction : Long_Float; Exponent : Integer) return Long_Float; -- required for Long_Float'Copy_Sign by compiler (s-fatgen.ads) function Copy_Sign (X, Y : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_copysign"; -- required for Long_Float'Exponent by compiler (s-fatgen.ads) function Exponent (X : Long_Float) return Integer; -- required for Long_Float'Floor by compiler (s-fatgen.ads) function Floor (X : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_floor"; -- required for Long_Float'Fraction by compiler (s-fatgen.ads) function Fraction (X : Long_Float) return Long_Float; -- required for Long_Float'Leading_Part by compiler (s-fatgen.ads) function Leading_Part (X : Long_Float; Radix_Digits : Integer) return Long_Float; -- required for Long_Float'Machine by compiler (s-fatgen.ads) function Machine (X : Long_Float) return Long_Float; -- required for Long_Float'Machine_Rounding by compiler (s-fatgen.ads) function Machine_Rounding (X : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nearbyint"; -- required for Long_Float'Model by compiler (s-fatgen.ads) function Model (X : Long_Float) return Long_Float renames Machine; -- required for Long_Float'Pred by compiler (s-fatgen.ads) function Pred (X : Long_Float) return Long_Float; -- required for Long_Float'Remainder by compiler (s-fatgen.ads) function Remainder (X, Y : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_remainder"; -- required for Long_Float'Rounding by compiler (s-fatgen.ads) function Rounding (X : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_round"; -- required for Long_Float'Scaling by compiler (s-fatgen.ads) function Scaling (X : Long_Float; Adjustment : Integer) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_ldexp"; -- required for Long_Float'Succ by compiler (s-fatgen.ads) function Succ (X : Long_Float) return Long_Float; -- required for Long_Float'Truncation by compiler (s-fatgen.ads) function Truncation (X : Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_trunc"; -- required for Long_Float'Unbiased_Rounding by compiler (s-fatgen.ads) function Unbiased_Rounding (X : Long_Float) return Long_Float; -- required for Long_Float'Valid by compiler (s-fatgen.ads) function Valid (X : not null access Long_Float) return Boolean; type S is new String (1 .. Long_Float'Size / Character'Size); type P is access all S; for P'Storage_Size use 0; end Attr_Long_Float; end System.Fat_Lflt;
burratoo/Acton
Ada
1,216
ads
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- FREESCALE MPC5544 -- -- -- -- OAK.PROCESSOR_SUPPORT_PACKAGE -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package Oak.Processor_Support_Package with Pure is Number_Of_Processors : constant := 1; type Processors is range 1 .. Number_Of_Processors; -- Defines the number of processors used by the processor package -- (yes, overloading the term processors here). end Oak.Processor_Support_Package;
AdaCore/gpr
Ada
11,748
ads
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with GNATCOLL.Refcount; with Gpr_Parser_Support.Generic_API.Introspection; use Gpr_Parser_Support.Generic_API.Introspection; with Gpr_Parser_Support.Iterators; private with Gpr_Parser_Support.Tree_Traversal_Iterator; with Gpr_Parser.Analysis; use Gpr_Parser.Analysis; with Gpr_Parser.Common; use Gpr_Parser.Common; -- This package provides an interface to iterate on nodes in parse trees and -- to look for node patterns. -- -- First, as an alternative to ``Gpr_Parser.Analysis.Traverse``, you can -- do: -- -- .. code-block:: ada -- -- declare -- It : Traverse_Iterator'Class := Traverse (My_Unit.Root); -- Node : Gpr_Node; -- begin -- while It.Next (Node) loop -- -- Process Node -- end loop; -- end; -- -- Now, if you are exclusively looking for nodes whose text is either ``foo`` -- or ``bar``, you can replace the call to ``Traverse`` with the following: -- -- .. code-block:: ada -- -- Find (My_Unit.Root, Text_Is ("foo") or Text_Is ("bar")); -- -- The ``Find``-like functions below take as a second argument a *predicate*, -- which is an object that can decide if a node should be processed or not. -- This package provides several built-in predicates (``Kind_Is``, -- ``Text_Is``, etc.), then you can either define your own, derivating the -- ``Gpr_Node_Predicate_Interface`` type, or compose them using Ada's boolean operators. package Gpr_Parser.Iterators is use Support.Text; -------------------- -- Iterators core -- -------------------- package Gpr_Node_Iterators is new Support.Iterators (Element_Type => Gpr_Node, Element_Array => Gpr_Node_Array); type Traverse_Iterator is new Gpr_Node_Iterators.Iterator with private; -- Iterator that yields nodes from a tree function Traverse (Root : Gpr_Node'Class) return Traverse_Iterator'Class; -- Return an iterator that yields all nodes under ``Root`` (included) in a -- prefix DFS (depth first search) fashion. --------------------- -- Predicates core -- --------------------- type Gpr_Node_Predicate_Interface is interface; -- Predicate on nodes. -- -- Useful predicates often rely on values from some context, so predicates -- that are mere accesses to a function are not powerful enough. Having a -- full interface for this makes it possible to package both the predicate -- code and some data it needs. -- -- Note that predicates are not thread-safe: make sure you don't use a -- predicate from multiple threads, as they can contain caches. function Evaluate (P : in out Gpr_Node_Predicate_Interface; N : Gpr_Node) return Boolean is abstract; -- Return the value of the predicate for the ``N`` node package Gpr_Node_Predicate_References is new GNATCOLL.Refcount.Shared_Pointers (Gpr_Node_Predicate_Interface'Class); subtype Gpr_Node_Predicate is Gpr_Node_Predicate_References.Ref; -- Ref-counted reference to a predicate type Gpr_Node_Predicate_Array is array (Positive range <>) of Gpr_Node_Predicate; function "not" (Predicate : Gpr_Node_Predicate) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that are *not* accepted by -- ``Predicate``. -- --% belongs-to: Gpr_Node_Predicate function "and" (Left, Right : Gpr_Node_Predicate) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that are accepted by both -- ``Left`` and ``Right``. -- --% belongs-to: Gpr_Node_Predicate function "or" (Left, Right : Gpr_Node_Predicate) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that are accepted by ``Left`` -- or ``Right``. -- --% belongs-to: Gpr_Node_Predicate function For_All (Predicates : Gpr_Node_Predicate_Array) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that are accepted by all -- given ``Predicates``. -- --% belongs-to: Gpr_Node_Predicate function For_Some (Predicates : Gpr_Node_Predicate_Array) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that are accepted by at least -- one of the given ``Predicates``. -- --% belongs-to: Gpr_Node_Predicate function For_All_Children (Predicate : Gpr_Node_Predicate; Skip_Null : Boolean := True) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes for which ``Predicate`` -- accepts all children. Unless ``Skip_Null`` is false, this does not -- evaluate the predicate on null children. -- --% belongs-to: Gpr_Node_Predicate function For_Some_Children (Predicate : Gpr_Node_Predicate; Skip_Null : Boolean := True) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes for which ``Predicate`` -- accepts at least one child. Unless ``Skip_Null`` is false, this does not -- evaluate the predicate on null children. -- --% belongs-to: Gpr_Node_Predicate function Child_With (Field : Struct_Member_Ref; Predicate : Gpr_Node_Predicate) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes which have a child -- corresponding to the given field reference and for which this child is -- accepted by the given predicate. -- -- Raise a ``Precondition_Failure`` if ``Field`` is not a valid node field -- reference. -- --% belongs-to: Gpr_Node_Predicate --------------------------- -- Node search functions -- --------------------------- function Find (Root : Gpr_Node'Class; Predicate : access function (N : Gpr_Node) return Boolean := null) return Traverse_Iterator'Class; -- Return an iterator that yields all nodes under ``Root`` (included) that -- satisfy the ``Predicate`` predicate. function Find (Root : Gpr_Node'Class; Predicate : Gpr_Node_Predicate'Class) return Traverse_Iterator'Class; -- Return an iterator that yields all nodes under ``Root`` (included) that -- satisfy the ``Predicate`` predicate. function Find_First (Root : Gpr_Node'Class; Predicate : access function (N : Gpr_Node) return Boolean := null) return Gpr_Node; -- Return the first node found under ``Root`` (included) that satisfies the -- given ``Predicate``. Return a null node if there is no such node. function Find_First (Root : Gpr_Node'Class; Predicate : Gpr_Node_Predicate'Class) return Gpr_Node; -- Return the first node found under ``Root`` (included) that satisfies the -- given ``Predicate``. Return a null node if there is no such node. ---------------- -- Predicates -- ---------------- function Kind_Is (Kind : Gpr_Node_Kind_Type) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes of the given ``Kind`` -- --% belongs-to: Gpr_Node_Predicate function Kind_In (First, Last : Gpr_Node_Kind_Type) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes whose kind is in First .. -- Last. -- --% belongs-to: Gpr_Node_Predicate function Text_Is (Text : Text_Type) return Gpr_Node_Predicate; -- Return a predicate that accepts only nodes that match the given ``Text`` -- --% belongs-to: Gpr_Node_Predicate function Node_Is_Null return Gpr_Node_Predicate; -- Return a predicate that accepts only null nodes -- --% belongs-to: Gpr_Node_Predicate private ------------------------ -- Iterator internals -- ------------------------ function Get_Parent (N : Gpr_Node) return Gpr_Node; function First_Child_Index_For_Traverse (N : Gpr_Node) return Natural; function Last_Child_Index_For_Traverse (N : Gpr_Node) return Natural; function Get_Child (N : Gpr_Node; I : Natural) return Gpr_Node; package Traversal_Iterators is new Gpr_Parser_Support.Tree_Traversal_Iterator (Node_Type => Gpr_Node, No_Node => No_Gpr_Node, Node_Array => Gpr_Node_Array, First_Child_Index => First_Child_Index_For_Traverse, Last_Child_Index => Last_Child_Index_For_Traverse, Iterators => Gpr_Node_Iterators); type Traverse_Iterator is new Traversal_Iterators.Traverse_Iterator with null record; type Find_Iterator is new Traverse_Iterator with record Predicate : Gpr_Node_Predicate; -- Predicate used to filter the nodes Traverse_It yields end record; -- Iterator type for the ``Find`` function overriding function Next (It : in out Find_Iterator; Element : out Gpr_Node) return Boolean; type Local_Find_Iterator is new Traverse_Iterator with record Predicate : access function (N : Gpr_Node) return Boolean; -- Predicate used to filter the nodes Traverse_It yields end record; -- Iterator type for the ``Find`` function that takes an access to -- function. It is called ``Local_Find_Iterator`` because if you use a -- locally declared function, the iterator itself will only be valid in the -- scope of the function. overriding function Next (It : in out Local_Find_Iterator; Element : out Gpr_Node) return Boolean; -------------------------- -- Predicates internals -- -------------------------- type Not_Predicate is new Gpr_Node_Predicate_Interface with record Predicate : Gpr_Node_Predicate; end record; overriding function Evaluate (P : in out Not_Predicate; N : Gpr_Node) return Boolean; type For_All_Predicate (N : Natural) is new Gpr_Node_Predicate_Interface with record Predicates : Gpr_Node_Predicate_Array (1 .. N); end record; overriding function Evaluate (P : in out For_All_Predicate; N : Gpr_Node) return Boolean; type For_Some_Predicate (N : Natural) is new Gpr_Node_Predicate_Interface with record Predicates : Gpr_Node_Predicate_Array (1 .. N); end record; overriding function Evaluate (P : in out For_Some_Predicate; N : Gpr_Node) return Boolean; type For_All_Children_Predicate is new Gpr_Node_Predicate_Interface with record Predicate : Gpr_Node_Predicate; Skip_Null : Boolean; end record; overriding function Evaluate (P : in out For_All_Children_Predicate; N : Gpr_Node) return Boolean; type For_Some_Children_Predicate is new Gpr_Node_Predicate_Interface with record Predicate : Gpr_Node_Predicate; Skip_Null : Boolean; end record; overriding function Evaluate (P : in out For_Some_Children_Predicate; N : Gpr_Node) return Boolean; type Child_With_Predicate is new Gpr_Node_Predicate_Interface with record Field : Struct_Member_Ref; Predicate : Gpr_Node_Predicate; end record; overriding function Evaluate (P : in out Child_With_Predicate; N : Gpr_Node) return Boolean; type Kind_Predicate is new Gpr_Node_Predicate_Interface with record First, Last : Gpr_Node_Kind_Type; end record; -- Predicate that returns true for all nodes whose kind is in a given range overriding function Evaluate (P : in out Kind_Predicate; N : Gpr_Node) return Boolean; type Text_Predicate is new Gpr_Node_Predicate_Interface with record Text : Unbounded_Text_Type; end record; -- Predicate that returns true for all nodes that match some text overriding function Evaluate (P : in out Text_Predicate; N : Gpr_Node) return Boolean; type Node_Is_Null_Predicate is new Gpr_Node_Predicate_Interface with null record; overriding function Evaluate (P : in out Node_Is_Null_Predicate; N : Gpr_Node) return Boolean; end Gpr_Parser.Iterators;
AdaCore/langkit
Ada
330
adb
package body Libfoolang.Implementation.Extensions is ---------------------- -- Literal_P_Result -- ---------------------- function Literal_P_Result (Node : Bare_Literal) return Integer is begin return Integer'Value (Image (Text (Node))); end Literal_P_Result; end Libfoolang.Implementation.Extensions;
KipodAfterFree/KAF-2019-FireHog
Ada
4,105
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Manifest -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; package Sample.Manifest is QUIT : constant User_Key_Code := User_Key_Code'First; SELECT_ITEM : constant User_Key_Code := QUIT + 1; FKEY_HELP : constant Label_Number := 1; HELP_CODE : constant Special_Key_Code := Key_F1; FKEY_EXPLAIN : constant Label_Number := 2; EXPLAIN_CODE : constant Special_Key_Code := Key_F2; FKEY_QUIT : constant Label_Number := 3; QUIT_CODE : constant Special_Key_Code := Key_F3; Menu_Marker : constant String := "=> "; Default_Colors : constant Redefinable_Color_Pair := 1; Menu_Fore_Color : constant Redefinable_Color_Pair := 2; Menu_Back_Color : constant Redefinable_Color_Pair := 3; Menu_Grey_Color : constant Redefinable_Color_Pair := 4; Form_Fore_Color : constant Redefinable_Color_Pair := 5; Form_Back_Color : constant Redefinable_Color_Pair := 6; Notepad_Color : constant Redefinable_Color_Pair := 7; Help_Color : constant Redefinable_Color_Pair := 8; Header_Color : constant Redefinable_Color_Pair := 9; end Sample.Manifest;
tum-ei-rcs/StratoX
Ada
21,852
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f429xx.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides declarations for devices on the STM32F42xx MCUs -- manufactured by ST Microelectronics. For example, an STM32F429. with STM32_SVD; use STM32_SVD; with STM32.DMA; use STM32.DMA; with STM32.GPIO; use STM32.GPIO; with STM32.ADC; use STM32.ADC; with STM32.USARTs; use STM32.USARTs; with STM32.SPI; use STM32.SPI; with STM32.I2C; use STM32.I2C; with STM32.Timers; use STM32.Timers; with STM32.DAC; use STM32.DAC; package STM32.Device with SPARK_Mode => Off is pragma Elaborate_Body; Unknown_Device : exception; -- Raised by the routines below for a device passed as an actual parameter -- when that device is not present on the given hardware instance. procedure Enable_Clock (This : aliased in out Internal_GPIO_Port) with Inline; procedure Enable_Clock (Point : GPIO_Point) with Inline; procedure Enable_Clock (Points : GPIO_Points) with Inline; procedure Reset (This : aliased in out Internal_GPIO_Port) with Inline; procedure Reset (Point : GPIO_Point) with Inline; procedure Reset (Points : GPIO_Points) with Inline; type GPIO_Port_Id is (GPIO_Port_A, GPIO_Port_B, GPIO_Port_C, GPIO_Port_D, GPIO_Port_E, GPIO_Port_F, GPIO_Port_G, GPIO_Port_H, GPIO_Port_I, GPIO_Port_J, GPIO_Port_K) with Size => 4; function As_GPIO_Port_Id (Port : Internal_GPIO_Port) return GPIO_Port_Id with Inline; GPIO_A : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOA_Base; GPIO_B : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOB_Base; GPIO_C : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOC_Base; GPIO_D : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOD_Base; GPIO_E : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOE_Base; GPIO_F : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOF_Base; GPIO_G : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOG_Base; GPIO_H : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOH_Base; GPIO_I : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOI_Base; GPIO_J : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOJ_Base; GPIO_K : aliased Internal_GPIO_Port with Import, Volatile, Address => GPIOK_Base; PNONE : aliased GPIO_Point:= (null, 0); -- use this if you must map a function to nothing PA0 : aliased GPIO_Point := (GPIO_A'Access, 0); PA1 : aliased GPIO_Point := (GPIO_A'Access, 1); PA2 : aliased GPIO_Point := (GPIO_A'Access, 2); PA3 : aliased GPIO_Point := (GPIO_A'Access, 3); PA4 : aliased GPIO_Point := (GPIO_A'Access, 4); PA5 : aliased GPIO_Point := (GPIO_A'Access, 5); PA6 : aliased GPIO_Point := (GPIO_A'Access, 6); PA7 : aliased GPIO_Point := (GPIO_A'Access, 7); PA8 : aliased GPIO_Point := (GPIO_A'Access, 8); PA9 : aliased GPIO_Point := (GPIO_A'Access, 9); PA10 : aliased GPIO_Point := (GPIO_A'Access, 10); PA11 : aliased GPIO_Point := (GPIO_A'Access, 11); PA12 : aliased GPIO_Point := (GPIO_A'Access, 12); PA13 : aliased GPIO_Point := (GPIO_A'Access, 13); PA14 : aliased GPIO_Point := (GPIO_A'Access, 14); PA15 : aliased GPIO_Point := (GPIO_A'Access, 15); PB0 : aliased GPIO_Point := (GPIO_B'Access, 0); PB1 : aliased GPIO_Point := (GPIO_B'Access, 1); PB2 : aliased GPIO_Point := (GPIO_B'Access, 2); PB3 : aliased GPIO_Point := (GPIO_B'Access, 3); PB4 : aliased GPIO_Point := (GPIO_B'Access, 4); PB5 : aliased GPIO_Point := (GPIO_B'Access, 5); PB6 : aliased GPIO_Point := (GPIO_B'Access, 6); PB7 : aliased GPIO_Point := (GPIO_B'Access, 7); PB8 : aliased GPIO_Point := (GPIO_B'Access, 8); PB9 : aliased GPIO_Point := (GPIO_B'Access, 9); PB10 : aliased GPIO_Point := (GPIO_B'Access, 10); PB11 : aliased GPIO_Point := (GPIO_B'Access, 11); PB12 : aliased GPIO_Point := (GPIO_B'Access, 12); PB13 : aliased GPIO_Point := (GPIO_B'Access, 13); PB14 : aliased GPIO_Point := (GPIO_B'Access, 14); PB15 : aliased GPIO_Point := (GPIO_B'Access, 15); PC0 : aliased GPIO_Point := (GPIO_C'Access, 0); PC1 : aliased GPIO_Point := (GPIO_C'Access, 1); PC2 : aliased GPIO_Point := (GPIO_C'Access, 2); PC3 : aliased GPIO_Point := (GPIO_C'Access, 3); PC4 : aliased GPIO_Point := (GPIO_C'Access, 4); PC5 : aliased GPIO_Point := (GPIO_C'Access, 5); PC6 : aliased GPIO_Point := (GPIO_C'Access, 6); PC7 : aliased GPIO_Point := (GPIO_C'Access, 7); PC8 : aliased GPIO_Point := (GPIO_C'Access, 8); PC9 : aliased GPIO_Point := (GPIO_C'Access, 9); PC10 : aliased GPIO_Point := (GPIO_C'Access, 10); PC11 : aliased GPIO_Point := (GPIO_C'Access, 11); PC12 : aliased GPIO_Point := (GPIO_C'Access, 12); PC13 : aliased GPIO_Point := (GPIO_C'Access, 13); PC14 : aliased GPIO_Point := (GPIO_C'Access, 14); PC15 : aliased GPIO_Point := (GPIO_C'Access, 15); PD0 : aliased GPIO_Point := (GPIO_D'Access, 0); PD1 : aliased GPIO_Point := (GPIO_D'Access, 1); PD2 : aliased GPIO_Point := (GPIO_D'Access, 2); PD3 : aliased GPIO_Point := (GPIO_D'Access, 3); PD4 : aliased GPIO_Point := (GPIO_D'Access, 4); PD5 : aliased GPIO_Point := (GPIO_D'Access, 5); PD6 : aliased GPIO_Point := (GPIO_D'Access, 6); PD7 : aliased GPIO_Point := (GPIO_D'Access, 7); PD8 : aliased GPIO_Point := (GPIO_D'Access, 8); PD9 : aliased GPIO_Point := (GPIO_D'Access, 9); PD10 : aliased GPIO_Point := (GPIO_D'Access, 10); PD11 : aliased GPIO_Point := (GPIO_D'Access, 11); PD12 : aliased GPIO_Point := (GPIO_D'Access, 12); PD13 : aliased GPIO_Point := (GPIO_D'Access, 13); PD14 : aliased GPIO_Point := (GPIO_D'Access, 14); PD15 : aliased GPIO_Point := (GPIO_D'Access, 15); PE0 : aliased GPIO_Point := (GPIO_E'Access, 0); PE1 : aliased GPIO_Point := (GPIO_E'Access, 1); PE2 : aliased GPIO_Point := (GPIO_E'Access, 2); PE3 : aliased GPIO_Point := (GPIO_E'Access, 3); PE4 : aliased GPIO_Point := (GPIO_E'Access, 4); PE5 : aliased GPIO_Point := (GPIO_E'Access, 5); PE6 : aliased GPIO_Point := (GPIO_E'Access, 6); PE7 : aliased GPIO_Point := (GPIO_E'Access, 7); PE8 : aliased GPIO_Point := (GPIO_E'Access, 8); PE9 : aliased GPIO_Point := (GPIO_E'Access, 9); PE10 : aliased GPIO_Point := (GPIO_E'Access, 10); PE11 : aliased GPIO_Point := (GPIO_E'Access, 11); PE12 : aliased GPIO_Point := (GPIO_E'Access, 12); PE13 : aliased GPIO_Point := (GPIO_E'Access, 13); PE14 : aliased GPIO_Point := (GPIO_E'Access, 14); PE15 : aliased GPIO_Point := (GPIO_E'Access, 15); PF0 : aliased GPIO_Point := (GPIO_F'Access, 0); PF1 : aliased GPIO_Point := (GPIO_F'Access, 1); PF2 : aliased GPIO_Point := (GPIO_F'Access, 2); PF3 : aliased GPIO_Point := (GPIO_F'Access, 3); PF4 : aliased GPIO_Point := (GPIO_F'Access, 4); PF5 : aliased GPIO_Point := (GPIO_F'Access, 5); PF6 : aliased GPIO_Point := (GPIO_F'Access, 6); PF7 : aliased GPIO_Point := (GPIO_F'Access, 7); PF8 : aliased GPIO_Point := (GPIO_F'Access, 8); PF9 : aliased GPIO_Point := (GPIO_F'Access, 9); PF10 : aliased GPIO_Point := (GPIO_F'Access, 10); PF11 : aliased GPIO_Point := (GPIO_F'Access, 11); PF12 : aliased GPIO_Point := (GPIO_F'Access, 12); PF13 : aliased GPIO_Point := (GPIO_F'Access, 13); PF14 : aliased GPIO_Point := (GPIO_F'Access, 14); PF15 : aliased GPIO_Point := (GPIO_F'Access, 15); PG0 : aliased GPIO_Point := (GPIO_G'Access, 0); PG1 : aliased GPIO_Point := (GPIO_G'Access, 1); PG2 : aliased GPIO_Point := (GPIO_G'Access, 2); PG3 : aliased GPIO_Point := (GPIO_G'Access, 3); PG4 : aliased GPIO_Point := (GPIO_G'Access, 4); PG5 : aliased GPIO_Point := (GPIO_G'Access, 5); PG6 : aliased GPIO_Point := (GPIO_G'Access, 6); PG7 : aliased GPIO_Point := (GPIO_G'Access, 7); PG8 : aliased GPIO_Point := (GPIO_G'Access, 8); PG9 : aliased GPIO_Point := (GPIO_G'Access, 9); PG10 : aliased GPIO_Point := (GPIO_G'Access, 10); PG11 : aliased GPIO_Point := (GPIO_G'Access, 11); PG12 : aliased GPIO_Point := (GPIO_G'Access, 12); PG13 : aliased GPIO_Point := (GPIO_G'Access, 13); PG14 : aliased GPIO_Point := (GPIO_G'Access, 14); PG15 : aliased GPIO_Point := (GPIO_G'Access, 15); PH0 : aliased GPIO_Point := (GPIO_H'Access, 0); PH1 : aliased GPIO_Point := (GPIO_H'Access, 1); PH2 : aliased GPIO_Point := (GPIO_H'Access, 2); PH3 : aliased GPIO_Point := (GPIO_H'Access, 3); PH4 : aliased GPIO_Point := (GPIO_H'Access, 4); PH5 : aliased GPIO_Point := (GPIO_H'Access, 5); PH6 : aliased GPIO_Point := (GPIO_H'Access, 6); PH7 : aliased GPIO_Point := (GPIO_H'Access, 7); PH8 : aliased GPIO_Point := (GPIO_H'Access, 8); PH9 : aliased GPIO_Point := (GPIO_H'Access, 9); PH10 : aliased GPIO_Point := (GPIO_H'Access, 10); PH11 : aliased GPIO_Point := (GPIO_H'Access, 11); PH12 : aliased GPIO_Point := (GPIO_H'Access, 12); PH13 : aliased GPIO_Point := (GPIO_H'Access, 13); PH14 : aliased GPIO_Point := (GPIO_H'Access, 14); PH15 : aliased GPIO_Point := (GPIO_H'Access, 15); PI0 : aliased GPIO_Point := (GPIO_I'Access, 0); PI1 : aliased GPIO_Point := (GPIO_I'Access, 1); PI2 : aliased GPIO_Point := (GPIO_I'Access, 2); PI3 : aliased GPIO_Point := (GPIO_I'Access, 3); PI4 : aliased GPIO_Point := (GPIO_I'Access, 4); PI5 : aliased GPIO_Point := (GPIO_I'Access, 5); PI6 : aliased GPIO_Point := (GPIO_I'Access, 6); PI7 : aliased GPIO_Point := (GPIO_I'Access, 7); PI8 : aliased GPIO_Point := (GPIO_I'Access, 8); PI9 : aliased GPIO_Point := (GPIO_I'Access, 9); PI10 : aliased GPIO_Point := (GPIO_I'Access, 10); PI11 : aliased GPIO_Point := (GPIO_I'Access, 11); PI12 : aliased GPIO_Point := (GPIO_I'Access, 12); PI13 : aliased GPIO_Point := (GPIO_I'Access, 13); PI14 : aliased GPIO_Point := (GPIO_I'Access, 14); PI15 : aliased GPIO_Point := (GPIO_I'Access, 15); PJ0 : aliased GPIO_Point := (GPIO_J'Access, 0); PJ1 : aliased GPIO_Point := (GPIO_J'Access, 1); PJ2 : aliased GPIO_Point := (GPIO_J'Access, 2); PJ3 : aliased GPIO_Point := (GPIO_J'Access, 3); PJ4 : aliased GPIO_Point := (GPIO_J'Access, 4); PJ5 : aliased GPIO_Point := (GPIO_J'Access, 5); PJ6 : aliased GPIO_Point := (GPIO_J'Access, 6); PJ7 : aliased GPIO_Point := (GPIO_J'Access, 7); PJ8 : aliased GPIO_Point := (GPIO_J'Access, 8); PJ9 : aliased GPIO_Point := (GPIO_J'Access, 9); PJ10 : aliased GPIO_Point := (GPIO_J'Access, 10); PJ11 : aliased GPIO_Point := (GPIO_J'Access, 11); PJ12 : aliased GPIO_Point := (GPIO_J'Access, 12); PJ13 : aliased GPIO_Point := (GPIO_J'Access, 13); PJ14 : aliased GPIO_Point := (GPIO_J'Access, 14); PJ15 : aliased GPIO_Point := (GPIO_J'Access, 15); PK0 : aliased GPIO_Point := (GPIO_K'Access, 0); PK1 : aliased GPIO_Point := (GPIO_K'Access, 1); PK2 : aliased GPIO_Point := (GPIO_K'Access, 2); PK3 : aliased GPIO_Point := (GPIO_K'Access, 3); PK4 : aliased GPIO_Point := (GPIO_K'Access, 4); PK5 : aliased GPIO_Point := (GPIO_K'Access, 5); PK6 : aliased GPIO_Point := (GPIO_K'Access, 6); PK7 : aliased GPIO_Point := (GPIO_K'Access, 7); PK8 : aliased GPIO_Point := (GPIO_K'Access, 8); PK9 : aliased GPIO_Point := (GPIO_K'Access, 9); PK10 : aliased GPIO_Point := (GPIO_K'Access, 10); PK11 : aliased GPIO_Point := (GPIO_K'Access, 11); PK12 : aliased GPIO_Point := (GPIO_K'Access, 12); PK13 : aliased GPIO_Point := (GPIO_K'Access, 13); PK14 : aliased GPIO_Point := (GPIO_K'Access, 14); PK15 : aliased GPIO_Point := (GPIO_K'Access, 15); ADC_1 : aliased Analog_To_Digital_Converter with Import, Volatile, Address => ADC1_Base; ADC_2 : aliased Analog_To_Digital_Converter with Import, Volatile, Address => ADC2_Base; ADC_3 : aliased Analog_To_Digital_Converter with Import, Volatile, Address => ADC3_Base; VBat : constant ADC_Point := (ADC_1'Access, Channel => VBat_Channel); Temperature_Sensor : constant ADC_Point := VBat; -- see RM pg 410, section 13.10, also pg 389 VBat_Bridge_Divisor : constant := 4; -- The VBAT pin is internally connected to a bridge divider. The actual -- voltage is the raw conversion value * the divisor. See section 13.11, -- pg 412 of the RM. procedure Enable_Clock (This : aliased in out Analog_To_Digital_Converter); procedure Reset_All_ADC_Units; DAC_1 : aliased Digital_To_Analog_Converter with Import, Volatile, Address => DAC_Base; DAC_Channel_1_IO : GPIO_Point renames PA4; DAC_Channel_2_IO : GPIO_Point renames PA5; procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter); procedure Reset (This : aliased in out Digital_To_Analog_Converter); USART_1 : aliased USART with Import, Volatile, Address => USART1_Base; USART_2 : aliased USART with Import, Volatile, Address => USART2_Base; USART_3 : aliased USART with Import, Volatile, Address => USART3_Base; UART_4 : aliased USART with Import, Volatile, Address => UART4_Base; UART_5 : aliased USART with Import, Volatile, Address => UART5_Base; USART_6 : aliased USART with Import, Volatile, Address => USART6_Base; USART_7 : aliased USART with Import, Volatile, Address => UART7_Base; USART_8 : aliased USART with Import, Volatile, Address => UART8_Base; procedure Enable_Clock (This : aliased in out USART); procedure Reset (This : aliased in out USART); DMA_1 : aliased DMA_Controller with Import, Volatile, Address => DMA1_Base; DMA_2 : aliased DMA_Controller with Import, Volatile, Address => DMA2_Base; procedure Enable_Clock (This : aliased in out DMA_Controller); procedure Reset (This : aliased in out DMA_Controller); Internal_I2C_Port_1 : aliased Internal_I2C_Port with Import, Volatile, Address => I2C1_Base; Internal_I2C_Port_2 : aliased Internal_I2C_Port with Import, Volatile, Address => I2C2_Base; Internal_I2C_Port_3 : aliased Internal_I2C_Port with Import, Volatile, Address => I2C3_Base; type I2C_Port_Id is (I2C_Id_1, I2C_Id_2, I2C_Id_3); I2C_1 : aliased I2C_Port (Internal_I2C_Port_1'Access); I2C_2 : aliased I2C_Port (Internal_I2C_Port_2'Access); I2C_3 : aliased I2C_Port (Internal_I2C_Port_3'Access); function As_Port_Id (Port : I2C_Port) return I2C_Port_Id with Inline; procedure Enable_Clock (This : I2C_Port); procedure Enable_Clock (This : I2C_Port_Id); procedure Reset (This : I2C_Port); procedure Reset (This : I2C_Port_Id); Internal_SPI_1 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI1_Base; Internal_SPI_2 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI2_Base; Internal_SPI_3 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI3_Base; Internal_SPI_4 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI4_Base; Internal_SPI_5 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI5_Base; Internal_SPI_6 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI6_Base; SPI_1 : aliased SPI_Port (Internal_SPI_1'Access); SPI_2 : aliased SPI_Port (Internal_SPI_2'Access); SPI_3 : aliased SPI_Port (Internal_SPI_3'Access); SPI_4 : aliased SPI_Port (Internal_SPI_4'Access); SPI_5 : aliased SPI_Port (Internal_SPI_5'Access); --SPI_6 : aliased SPI_Port (Internal_SPI_6'Access); procedure Enable_Clock (This : SPI_Port); procedure Reset (This : SPI_Port); Timer_1 : aliased Timer with Volatile, Address => TIM1_Base; pragma Import (Ada, Timer_1); Timer_2 : aliased Timer with Volatile, Address => TIM2_Base; pragma Import (Ada, Timer_2); Timer_3 : aliased Timer with Volatile, Address => TIM3_Base; pragma Import (Ada, Timer_3); Timer_4 : aliased Timer with Volatile, Address => TIM4_Base; pragma Import (Ada, Timer_4); Timer_5 : aliased Timer with Volatile, Address => TIM5_Base; pragma Import (Ada, Timer_5); Timer_6 : aliased Timer with Volatile, Address => TIM6_Base; pragma Import (Ada, Timer_6); Timer_7 : aliased Timer with Volatile, Address => TIM7_Base; pragma Import (Ada, Timer_7); Timer_8 : aliased Timer with Volatile, Address => TIM8_Base; pragma Import (Ada, Timer_8); Timer_9 : aliased Timer with Volatile, Address => TIM9_Base; pragma Import (Ada, Timer_9); Timer_10 : aliased Timer with Volatile, Address => TIM10_Base; pragma Import (Ada, Timer_10); Timer_11 : aliased Timer with Volatile, Address => TIM11_Base; pragma Import (Ada, Timer_11); Timer_12 : aliased Timer with Volatile, Address => TIM12_Base; pragma Import (Ada, Timer_12); Timer_13 : aliased Timer with Volatile, Address => TIM13_Base; pragma Import (Ada, Timer_13); Timer_14 : aliased Timer with Volatile, Address => TIM14_Base; pragma Import (Ada, Timer_14); procedure Enable_Clock (This : in out Timer); procedure Reset (This : in out Timer); ----------------------------- -- Reset and Clock Control -- ----------------------------- type RCC_System_Clocks is record SYSCLK : HAL.Word; HCLK : HAL.Word; PCLK1 : HAL.Word; PCLK2 : HAL.Word; TIMCLK1 : HAL.Word; TIMCLK2 : HAL.Word; end record; function System_Clock_Frequencies return RCC_System_Clocks; type PLLSAI_DivR is new UInt2; PLLSAI_DIV2 : constant PLLSAI_DivR := 0; PLLSAI_DIV4 : constant PLLSAI_DivR := 1; PLLSAI_DIV8 : constant PLLSAI_DivR := 2; PLLSAI_DIV16 : constant PLLSAI_DivR := 3; procedure Set_PLLSAI_Factors (LCD : UInt3; VCO : UInt9; DivR : PLLSAI_DivR); procedure Enable_PLLSAI; procedure Disable_PLLSAI; function PLLSAI_Ready return Boolean; procedure Enable_DCMI_Clock; procedure Reset_DCMI; private pragma Compile_Time_Error (not (GPIO_Port_Id'First = GPIO_Port_A and GPIO_Port_Id'Last = GPIO_Port_K and GPIO_Port_A'Enum_Rep = 0 and GPIO_Port_B'Enum_Rep = 1 and GPIO_Port_C'Enum_Rep = 2 and GPIO_Port_D'Enum_Rep = 3 and GPIO_Port_E'Enum_Rep = 4 and GPIO_Port_F'Enum_Rep = 5 and GPIO_Port_G'Enum_Rep = 6 and GPIO_Port_H'Enum_Rep = 7 and GPIO_Port_I'Enum_Rep = 8 and GPIO_Port_J'Enum_Rep = 9 and GPIO_Port_K'Enum_Rep = 10), "Invalid representation for type GPIO_Port_Id"); -- Confirming, but depended upon so we check it. end STM32.Device;
strenkml/EE368
Ada
841
ads
-- Package to provide device-specific information. package Device is -- Supported devices. type Device_Type is ( ASIC, Virtex_4, Virtex_5, Virtex_6, Virtex_7 ); Invalid_Device : exception; -- Set the device to use. procedure Set_Device(name : in String); -- Set the number of address bits to use. procedure Set_Address_Bits(b : in Positive); -- Get the current device. function Get_Device return Device_Type; -- Get the width of a BRAM in bits. function Get_BRAM_Width return Positive; -- Get the depth of a BRAM in entries. function Get_BRAM_Depth return Positive; -- Get the maximum number of logic levels allowed. function Get_Max_Path return Positive; -- Get the number of address bits. function Get_Address_Bits return Positive; end Device;
zhmu/ananas
Ada
40,032
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a POSIX-like version of this package -- This package contains all the GNULL primitives that interface directly with -- the underlying OS. -- Note: this file can only be used for POSIX compliant systems that implement -- SCHED_FIFO and Ceiling Locking correctly. -- For configurations where SCHED_FIFO and priority ceiling are not a -- requirement, this file can also be used (e.g AiX threads) with Ada.Unchecked_Conversion; with Interfaces.C; with System.Tasking.Debug; with System.Interrupt_Management; with System.OS_Constants; with System.OS_Primitives; with System.Task_Info; with System.Soft_Links; -- We use System.Soft_Links instead of System.Tasking.Initialization -- because the later is a higher level package that we shouldn't depend on. -- For example when using the restricted run time, it is replaced by -- System.Tasking.Restricted.Stages. package body System.Task_Primitives.Operations is package OSC renames System.OS_Constants; package SSL renames System.Soft_Links; use System.Tasking.Debug; use System.Tasking; use Interfaces.C; use System.OS_Interface; use System.Parameters; use System.OS_Primitives; ---------------- -- Local Data -- ---------------- -- The followings are logically constants, but need to be initialized -- at run time. Single_RTS_Lock : aliased RTS_Lock; -- This is a lock to allow only one thread of control in the RTS at -- a time; it is used to execute in mutual exclusion from all other tasks. -- Used to protect All_Tasks_List Environment_Task_Id : Task_Id; -- A variable to hold Task_Id for the environment task Locking_Policy : constant Character; pragma Import (C, Locking_Policy, "__gl_locking_policy"); -- Value of the pragma Locking_Policy: -- 'C' for Ceiling_Locking -- 'I' for Inherit_Locking -- ' ' for none. Unblocked_Signal_Mask : aliased sigset_t; -- The set of signals that should unblocked in all tasks -- The followings are internal configuration constants needed Next_Serial_Number : Task_Serial_Number := 100; -- We start at 100, to reserve some special values for -- using in error checking. Time_Slice_Val : constant Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); Dispatching_Policy : constant Character; pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); Foreign_Task_Elaborated : aliased Boolean := True; -- Used to identified fake tasks (i.e., non-Ada Threads) Use_Alternate_Stack : constant Boolean := Alternate_Stack_Size /= 0; -- Whether to use an alternate signal stack for stack overflows Abort_Handler_Installed : Boolean := False; -- True if a handler for the abort signal is installed type RTS_Lock_Ptr is not null access all RTS_Lock; function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return int; -- Initialize the mutex L. If Ceiling_Support is True, then set the ceiling -- to Prio. Returns 0 for success, or ENOMEM for out-of-memory. function Get_Policy (Prio : System.Any_Priority) return Character; pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching"); -- Get priority specific dispatching policy -------------------- -- Local Packages -- -------------------- package Specific is procedure Initialize (Environment_Task : Task_Id); pragma Inline (Initialize); -- Initialize various data needed by this package function Is_Valid_Task return Boolean; pragma Inline (Is_Valid_Task); -- Does executing thread have a TCB? procedure Set (Self_Id : Task_Id); pragma Inline (Set); -- Set the self id for the current task function Self return Task_Id; pragma Inline (Self); -- Return a pointer to the Ada Task Control Block of the calling task end Specific; package body Specific is separate; -- The body of this package is target specific package Monotonic is function Monotonic_Clock return Duration; pragma Inline (Monotonic_Clock); -- Returns an absolute time, represented as an offset relative to some -- unspecified starting point, typically system boot time. This clock -- is not affected by discontinuous jumps in the system time. function RT_Resolution return Duration; pragma Inline (RT_Resolution); -- Returns resolution of the underlying clock used to implement RT_Clock procedure Timed_Sleep (Self_ID : ST.Task_Id; Time : Duration; Mode : ST.Delay_Modes; Reason : System.Tasking.Task_States; Timedout : out Boolean; Yielded : out Boolean); -- Combination of Sleep (above) and Timed_Delay procedure Timed_Delay (Self_ID : ST.Task_Id; Time : Duration; Mode : ST.Delay_Modes); -- Implement the semantics of the delay statement. -- The caller should be abort-deferred and should not hold any locks. end Monotonic; package body Monotonic is separate; ---------------------------------- -- ATCB allocation/deallocation -- ---------------------------------- package body ATCB_Allocation is separate; -- The body of this package is shared across several targets --------------------------------- -- Support for foreign threads -- --------------------------------- function Register_Foreign_Thread (Thread : Thread_Id; Sec_Stack_Size : Size_Type := Unspecified_Size) return Task_Id; -- Allocate and initialize a new ATCB for the current Thread. The size of -- the secondary stack can be optionally specified. function Register_Foreign_Thread (Thread : Thread_Id; Sec_Stack_Size : Size_Type := Unspecified_Size) return Task_Id is separate; ----------------------- -- Local Subprograms -- ----------------------- procedure Abort_Handler (Sig : Signal); -- Signal handler used to implement asynchronous abort. -- See also comment before body, below. function To_Address is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup (attr : access pthread_condattr_t) return int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); ------------------- -- Abort_Handler -- ------------------- -- Target-dependent binding of inter-thread Abort signal to the raising of -- the Abort_Signal exception. -- The technical issues and alternatives here are essentially the -- same as for raising exceptions in response to other signals -- (e.g. Storage_Error). See code and comments in the package body -- System.Interrupt_Management. -- Some implementations may not allow an exception to be propagated out of -- a handler, and others might leave the signal or interrupt that invoked -- this handler masked after the exceptional return to the application -- code. -- GNAT exceptions are originally implemented using setjmp()/longjmp(). On -- most UNIX systems, this will allow transfer out of a signal handler, -- which is usually the only mechanism available for implementing -- asynchronous handlers of this kind. However, some systems do not -- restore the signal mask on longjmp(), leaving the abort signal masked. procedure Abort_Handler (Sig : Signal) is pragma Unreferenced (Sig); T : constant Task_Id := Self; Old_Set : aliased sigset_t; Result : Interfaces.C.int; pragma Warnings (Off, Result); begin -- It's not safe to raise an exception when using GCC ZCX mechanism. -- Note that we still need to install a signal handler, since in some -- cases (e.g. shutdown of the Server_Task in System.Interrupts) we -- need to send the Abort signal to a task. if ZCX_By_Default then return; end if; if T.Deferral_Level = 0 and then T.Pending_ATC_Level < T.ATC_Nesting_Level and then not T.Aborting then T.Aborting := True; -- Make sure signals used for RTS internal purpose are unmasked Result := pthread_sigmask (SIG_UNBLOCK, Unblocked_Signal_Mask'Access, Old_Set'Access); pragma Assert (Result = 0); raise Standard'Abort_Signal; end if; end Abort_Handler; ----------------- -- Stack_Guard -- ----------------- procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is Stack_Base : constant Address := Get_Stack_Base (T.Common.LL.Thread); Page_Size : Address; Res : Interfaces.C.int; begin if Stack_Base_Available then -- Compute the guard page address Page_Size := Address (Get_Page_Size); Res := mprotect (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, size_t (Page_Size), prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if; end Stack_Guard; -------------------- -- Get_Thread_Id -- -------------------- function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is begin return T.Common.LL.Thread; end Get_Thread_Id; ---------- -- Self -- ---------- function Self return Task_Id renames Specific.Self; ---------------- -- Init_Mutex -- ---------------- function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return int is Attributes : aliased pthread_mutexattr_t; Result : int; Result_2 : aliased int; begin Result := pthread_mutexattr_init (Attributes'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result = ENOMEM then return Result; end if; if Locking_Policy = 'C' then Result := pthread_mutexattr_setprotocol (Attributes'Access, PTHREAD_PRIO_PROTECT); pragma Assert (Result = 0); Result := pthread_mutexattr_getprotocol (Attributes'Access, Result_2'Access); if Result_2 /= PTHREAD_PRIO_PROTECT then raise Program_Error with "setprotocol failed"; end if; Result := pthread_mutexattr_setprioceiling (Attributes'Access, To_Target_Priority (Prio)); pragma Assert (Result = 0); elsif Locking_Policy = 'I' then Result := pthread_mutexattr_setprotocol (Attributes'Access, PTHREAD_PRIO_INHERIT); pragma Assert (Result = 0); end if; Result := pthread_mutex_init (L, Attributes'Access); pragma Assert (Result = 0 or else Result = ENOMEM); Result_2 := pthread_mutexattr_destroy (Attributes'Access); pragma Assert (Result_2 = 0); return Result; end Init_Mutex; --------------------- -- Initialize_Lock -- --------------------- -- Note: mutexes and cond_variables needed per-task basis are initialized -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any -- status change of RTS. Therefore raising Storage_Error in the following -- routines should be able to be handled safely. procedure Initialize_Lock (Prio : System.Any_Priority; L : not null access Lock) is begin if Init_Mutex (L.WO'Access, Prio) = ENOMEM then raise Storage_Error with "Failed to allocate a lock"; end if; end Initialize_Lock; procedure Initialize_Lock (L : not null access RTS_Lock; Level : Lock_Level) is pragma Unreferenced (Level); begin if Init_Mutex (L.all'Access, Any_Priority'Last) = ENOMEM then raise Storage_Error with "Failed to allocate a lock"; end if; end Initialize_Lock; ------------------- -- Finalize_Lock -- ------------------- procedure Finalize_Lock (L : not null access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_destroy (L.WO'Access); pragma Assert (Result = 0); end Finalize_Lock; procedure Finalize_Lock (L : not null access RTS_Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); end Finalize_Lock; ---------------- -- Write_Lock -- ---------------- procedure Write_Lock (L : not null access Lock; Ceiling_Violation : out Boolean) is Self : constant pthread_t := pthread_self; Result : int; Policy : aliased int; Ceiling : aliased int; Sched : aliased struct_sched_param; begin Result := pthread_mutex_lock (L.WO'Access); -- The cause of EINVAL is a priority ceiling violation Ceiling_Violation := Result = EINVAL; pragma Assert (Result = 0 or else Ceiling_Violation); -- Workaround bug in QNX on ceiling locks: tasks with priority higher -- than the ceiling priority don't receive EINVAL upon trying to lock. if Result = 0 and then Locking_Policy = 'C' then Result := pthread_getschedparam (Self, Policy'Access, Sched'Access); pragma Assert (Result = 0); Result := pthread_mutex_getprioceiling (L.WO'Access, Ceiling'Access); pragma Assert (Result = 0); -- Ceiling < current priority means Ceiling violation -- (otherwise the current priority == ceiling) if Ceiling < Sched.sched_curpriority then Ceiling_Violation := True; Result := pthread_mutex_unlock (L.WO'Access); pragma Assert (Result = 0); end if; end if; end Write_Lock; procedure Write_Lock (L : not null access RTS_Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_lock (L); pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_Id) is Result : Interfaces.C.int; begin Result := pthread_mutex_lock (T.Common.LL.L'Access); pragma Assert (Result = 0); end Write_Lock; --------------- -- Read_Lock -- --------------- procedure Read_Lock (L : not null access Lock; Ceiling_Violation : out Boolean) is begin Write_Lock (L, Ceiling_Violation); end Read_Lock; ------------ -- Unlock -- ------------ procedure Unlock (L : not null access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L.WO'Access); pragma Assert (Result = 0); end Unlock; procedure Unlock (L : not null access RTS_Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_Id) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (T.Common.LL.L'Access); pragma Assert (Result = 0); end Unlock; ----------------- -- Set_Ceiling -- ----------------- procedure Set_Ceiling (L : not null access Lock; Prio : System.Any_Priority) is Result : Interfaces.C.int; begin Result := pthread_mutex_setprioceiling (L.WO'Access, To_Target_Priority (Prio), null); pragma Assert (Result = 0); end Set_Ceiling; ----------- -- Sleep -- ----------- procedure Sleep (Self_ID : Task_Id; Reason : System.Tasking.Task_States) is pragma Unreferenced (Reason); Result : Interfaces.C.int; begin Result := pthread_cond_wait (cond => Self_ID.Common.LL.CV'Access, mutex => Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure pragma Assert (Result = 0 or else Result = EINTR); end Sleep; ----------------- -- Timed_Sleep -- ----------------- -- This is for use within the run-time system, so abort is -- assumed to be already deferred, and the caller should be -- holding its own ATCB lock. procedure Timed_Sleep (Self_ID : Task_Id; Time : Duration; Mode : ST.Delay_Modes; Reason : Task_States; Timedout : out Boolean; Yielded : out Boolean) renames Monotonic.Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- -- This is for use in implementing delay statements, so we assume the -- caller is abort-deferred but is holding no locks. procedure Timed_Delay (Self_ID : Task_Id; Time : Duration; Mode : ST.Delay_Modes) renames Monotonic.Timed_Delay; --------------------- -- Monotonic_Clock -- --------------------- function Monotonic_Clock return Duration renames Monotonic.Monotonic_Clock; ------------------- -- RT_Resolution -- ------------------- function RT_Resolution return Duration renames Monotonic.RT_Resolution; ------------ -- Wakeup -- ------------ procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is pragma Unreferenced (Reason); Result : Interfaces.C.int; begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); end Wakeup; ----------- -- Yield -- ----------- procedure Yield (Do_Yield : Boolean := True) is Result : Interfaces.C.int; pragma Unreferenced (Result); begin if Do_Yield then Result := sched_yield; end if; end Yield; ------------------ -- Set_Priority -- ------------------ procedure Set_Priority (T : Task_Id; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is pragma Unreferenced (Loss_Of_Inheritance); Result : Interfaces.C.int; Old : constant System.Any_Priority := T.Common.Current_Priority; begin T.Common.Current_Priority := Prio; Result := pthread_setschedprio (T.Common.LL.Thread, To_Target_Priority (Prio)); pragma Assert (Result = 0); if T.Common.LL.Thread = pthread_self and then Old > Prio then -- When lowering the priority via a pthread_setschedprio, QNX ensures -- that the running thread remains in the head of the FIFO for tne -- new priority. Annex D expects the thread to be requeued so let's -- yield to the other threads of the same priority. Result := sched_yield; pragma Assert (Result = 0); end if; end Set_Priority; ------------------ -- Get_Priority -- ------------------ function Get_Priority (T : Task_Id) return System.Any_Priority is begin return T.Common.Current_Priority; end Get_Priority; ---------------- -- Enter_Task -- ---------------- procedure Enter_Task (Self_ID : Task_Id) is begin Self_ID.Common.LL.Thread := pthread_self; Self_ID.Common.LL.LWP := lwp_self; Specific.Set (Self_ID); if Use_Alternate_Stack then declare Stack : aliased stack_t; Result : Interfaces.C.int; begin Stack.ss_sp := Self_ID.Common.Task_Alternate_Stack; Stack.ss_size := Alternate_Stack_Size; Stack.ss_flags := 0; Result := sigaltstack (Stack'Access, null); pragma Assert (Result = 0); end; end if; end Enter_Task; ------------------- -- Is_Valid_Task -- ------------------- function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task; ----------------------------- -- Register_Foreign_Thread -- ----------------------------- function Register_Foreign_Thread return Task_Id is begin if Is_Valid_Task then return Self; else return Register_Foreign_Thread (pthread_self); end if; end Register_Foreign_Thread; -------------------- -- Initialize_TCB -- -------------------- procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is Result : Interfaces.C.int; Cond_Attr : aliased pthread_condattr_t; begin -- Give the task a unique serial number Self_ID.Serial_Number := Next_Serial_Number; Next_Serial_Number := Next_Serial_Number + 1; pragma Assert (Next_Serial_Number /= 0); Result := Init_Mutex (Self_ID.Common.LL.L'Access, Any_Priority'Last); pragma Assert (Result = 0); if Result /= 0 then Succeeded := False; return; end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result = 0 then Result := GNAT_pthread_condattr_setup (Cond_Attr'Access); pragma Assert (Result = 0); Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); pragma Assert (Result = 0); Succeeded := False; end if; Result := pthread_condattr_destroy (Cond_Attr'Access); pragma Assert (Result = 0); end Initialize_TCB; ----------------- -- Create_Task -- ----------------- procedure Create_Task (T : Task_Id; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean) is Attributes : aliased pthread_attr_t; Adjusted_Stack_Size : Interfaces.C.size_t; Page_Size : constant Interfaces.C.size_t := Interfaces.C.size_t (Get_Page_Size); Sched_Param : aliased struct_sched_param; Result : Interfaces.C.int; Priority_Specific_Policy : constant Character := Get_Policy (Priority); -- Upper case first character of the policy name corresponding to the -- task as set by a Priority_Specific_Dispatching pragma. function Thread_Body_Access is new Ada.Unchecked_Conversion (System.Address, Thread_Body); begin Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size + Alternate_Stack_Size); if Stack_Base_Available then -- If Stack Checking is supported then allocate 2 additional pages: -- In the worst case, stack is allocated at something like -- N * Get_Page_Size - epsilon, we need to add the size for 2 pages -- to be sure the effective stack size is greater than what -- has been asked. Adjusted_Stack_Size := Adjusted_Stack_Size + 2 * Page_Size; end if; -- Round stack size as this is required by some OSes (Darwin) Adjusted_Stack_Size := Adjusted_Stack_Size + Page_Size - 1; Adjusted_Stack_Size := Adjusted_Stack_Size - Adjusted_Stack_Size mod Page_Size; Result := pthread_attr_init (Attributes'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result /= 0 then Succeeded := False; return; end if; Result := pthread_attr_setdetachstate (Attributes'Access, PTHREAD_CREATE_DETACHED); pragma Assert (Result = 0); Result := pthread_attr_setstacksize (Attributes'Access, Adjusted_Stack_Size); pragma Assert (Result = 0); -- Set thread priority T.Common.Current_Priority := Priority; Sched_Param.sched_priority := To_Target_Priority (Priority); Result := pthread_attr_setinheritsched (Attributes'Access, PTHREAD_EXPLICIT_SCHED); pragma Assert (Result = 0); Result := pthread_attr_setschedparam (Attributes'Access, Sched_Param'Access); pragma Assert (Result = 0); if Time_Slice_Supported and then (Dispatching_Policy = 'R' or else Priority_Specific_Policy = 'R' or else Time_Slice_Val > 0) then Result := pthread_attr_setschedpolicy (Attributes'Access, SCHED_RR); elsif Dispatching_Policy = 'F' or else Priority_Specific_Policy = 'F' or else Time_Slice_Val = 0 then Result := pthread_attr_setschedpolicy (Attributes'Access, SCHED_FIFO); else Result := pthread_attr_setschedpolicy (Attributes'Access, SCHED_OTHER); end if; pragma Assert (Result = 0); -- Since the initial signal mask of a thread is inherited from the -- creator, and the Environment task has all its signals masked, we -- do not need to manipulate caller's signal mask at this point. -- All tasks in RTS will have All_Tasks_Mask initially. -- Note: the use of Unrestricted_Access in the following call is needed -- because otherwise we have an error of getting a access-to-volatile -- value which points to a non-volatile object. But in this case it is -- safe to do this, since we know we have no problems with aliasing and -- Unrestricted_Access bypasses this check. Result := pthread_create (T.Common.LL.Thread'Unrestricted_Access, Attributes'Access, Thread_Body_Access (Wrapper), To_Address (T)); pragma Assert (Result = 0 or else Result = EAGAIN); Succeeded := Result = 0; Result := pthread_attr_destroy (Attributes'Access); pragma Assert (Result = 0); end Create_Task; ------------------ -- Finalize_TCB -- ------------------ procedure Finalize_TCB (T : Task_Id) is Result : Interfaces.C.int; begin Result := pthread_mutex_destroy (T.Common.LL.L'Access); pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; ATCB_Allocation.Free_ATCB (T); end Finalize_TCB; --------------- -- Exit_Task -- --------------- procedure Exit_Task is begin -- Mark this task as unknown, so that if Self is called, it won't -- return a dangling pointer. Specific.Set (null); end Exit_Task; ---------------- -- Abort_Task -- ---------------- procedure Abort_Task (T : Task_Id) is Result : Interfaces.C.int; begin if Abort_Handler_Installed then Result := pthread_kill (T.Common.LL.Thread, Signal (System.Interrupt_Management.Abort_Task_Interrupt)); pragma Assert (Result = 0); end if; end Abort_Task; ---------------- -- Initialize -- ---------------- procedure Initialize (S : in out Suspension_Object) is Mutex_Attr : aliased pthread_mutexattr_t; Cond_Attr : aliased pthread_condattr_t; Result : Interfaces.C.int; begin -- Initialize internal state (always to False (RM D.10 (6))) S.State := False; S.Waiting := False; -- Initialize internal mutex Result := pthread_mutexattr_init (Mutex_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result = ENOMEM then raise Storage_Error; end if; Result := pthread_mutex_init (S.L'Access, Mutex_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result = ENOMEM then Result := pthread_mutexattr_destroy (Mutex_Attr'Access); pragma Assert (Result = 0); raise Storage_Error; end if; Result := pthread_mutexattr_destroy (Mutex_Attr'Access); pragma Assert (Result = 0); -- Initialize internal condition variable Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result /= 0 then Result := pthread_mutex_destroy (S.L'Access); pragma Assert (Result = 0); -- Storage_Error is propagated as intended if the allocation of the -- underlying OS entities fails. raise Storage_Error; else Result := GNAT_pthread_condattr_setup (Cond_Attr'Access); pragma Assert (Result = 0); end if; Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); if Result /= 0 then Result := pthread_mutex_destroy (S.L'Access); pragma Assert (Result = 0); Result := pthread_condattr_destroy (Cond_Attr'Access); pragma Assert (Result = 0); -- Storage_Error is propagated as intended if the allocation of the -- underlying OS entities fails. raise Storage_Error; end if; Result := pthread_condattr_destroy (Cond_Attr'Access); pragma Assert (Result = 0); end Initialize; -------------- -- Finalize -- -------------- procedure Finalize (S : in out Suspension_Object) is Result : Interfaces.C.int; begin -- Destroy internal mutex Result := pthread_mutex_destroy (S.L'Access); pragma Assert (Result = 0); -- Destroy internal condition variable Result := pthread_cond_destroy (S.CV'Access); pragma Assert (Result = 0); end Finalize; ------------------- -- Current_State -- ------------------- function Current_State (S : Suspension_Object) return Boolean is begin -- We do not want to use lock on this read operation. State is marked -- as Atomic so that we ensure that the value retrieved is correct. return S.State; end Current_State; --------------- -- Set_False -- --------------- procedure Set_False (S : in out Suspension_Object) is Result : Interfaces.C.int; begin SSL.Abort_Defer.all; Result := pthread_mutex_lock (S.L'Access); pragma Assert (Result = 0); S.State := False; Result := pthread_mutex_unlock (S.L'Access); pragma Assert (Result = 0); SSL.Abort_Undefer.all; end Set_False; -------------- -- Set_True -- -------------- procedure Set_True (S : in out Suspension_Object) is Result : Interfaces.C.int; begin SSL.Abort_Defer.all; Result := pthread_mutex_lock (S.L'Access); pragma Assert (Result = 0); -- If there is already a task waiting on this suspension object then -- we resume it, leaving the state of the suspension object to False, -- as it is specified in (RM D.10(9)). Otherwise, it just leaves -- the state to True. if S.Waiting then S.Waiting := False; S.State := False; Result := pthread_cond_signal (S.CV'Access); pragma Assert (Result = 0); else S.State := True; end if; Result := pthread_mutex_unlock (S.L'Access); pragma Assert (Result = 0); SSL.Abort_Undefer.all; end Set_True; ------------------------ -- Suspend_Until_True -- ------------------------ procedure Suspend_Until_True (S : in out Suspension_Object) is Result : Interfaces.C.int; begin SSL.Abort_Defer.all; Result := pthread_mutex_lock (S.L'Access); pragma Assert (Result = 0); if S.Waiting then -- Program_Error must be raised upon calling Suspend_Until_True -- if another task is already waiting on that suspension object -- (RM D.10(10)). Result := pthread_mutex_unlock (S.L'Access); pragma Assert (Result = 0); SSL.Abort_Undefer.all; raise Program_Error; else -- Suspend the task if the state is False. Otherwise, the task -- continues its execution, and the state of the suspension object -- is set to False (ARM D.10 par. 9). if S.State then S.State := False; else S.Waiting := True; loop -- Loop in case pthread_cond_wait returns earlier than expected -- (e.g. in case of EINTR caused by a signal). Result := pthread_cond_wait (S.CV'Access, S.L'Access); pragma Assert (Result = 0 or else Result = EINTR); exit when not S.Waiting; end loop; end if; Result := pthread_mutex_unlock (S.L'Access); pragma Assert (Result = 0); SSL.Abort_Undefer.all; end if; end Suspend_Until_True; ---------------- -- Check_Exit -- ---------------- -- Dummy version function Check_Exit (Self_ID : ST.Task_Id) return Boolean is pragma Unreferenced (Self_ID); begin return True; end Check_Exit; -------------------- -- Check_No_Locks -- -------------------- function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is pragma Unreferenced (Self_ID); begin return True; end Check_No_Locks; ---------------------- -- Environment_Task -- ---------------------- function Environment_Task return Task_Id is begin return Environment_Task_Id; end Environment_Task; -------------- -- Lock_RTS -- -------------- procedure Lock_RTS is begin Write_Lock (Single_RTS_Lock'Access); end Lock_RTS; ---------------- -- Unlock_RTS -- ---------------- procedure Unlock_RTS is begin Unlock (Single_RTS_Lock'Access); end Unlock_RTS; ------------------ -- Suspend_Task -- ------------------ function Suspend_Task (T : ST.Task_Id; Thread_Self : Thread_Id) return Boolean is pragma Unreferenced (T, Thread_Self); begin return False; end Suspend_Task; ----------------- -- Resume_Task -- ----------------- function Resume_Task (T : ST.Task_Id; Thread_Self : Thread_Id) return Boolean is pragma Unreferenced (T, Thread_Self); begin return False; end Resume_Task; -------------------- -- Stop_All_Tasks -- -------------------- procedure Stop_All_Tasks is begin null; end Stop_All_Tasks; --------------- -- Stop_Task -- --------------- function Stop_Task (T : ST.Task_Id) return Boolean is pragma Unreferenced (T); begin return False; end Stop_Task; ------------------- -- Continue_Task -- ------------------- function Continue_Task (T : ST.Task_Id) return Boolean is pragma Unreferenced (T); begin return False; end Continue_Task; ---------------- -- Initialize -- ---------------- procedure Initialize (Environment_Task : Task_Id) is act : aliased struct_sigaction; old_act : aliased struct_sigaction; Tmp_Set : aliased sigset_t; Result : Interfaces.C.int; function State (Int : System.Interrupt_Management.Interrupt_ID) return Character; pragma Import (C, State, "__gnat_get_interrupt_state"); -- Get interrupt state. Defined in a-init.c -- The input argument is the interrupt number, -- and the result is one of the following: Default : constant Character := 's'; -- 'n' this interrupt not set by any Interrupt_State pragma -- 'u' Interrupt_State pragma set state to User -- 'r' Interrupt_State pragma set state to Runtime -- 's' Interrupt_State pragma set state to System (use "default" -- system handler) begin Environment_Task_Id := Environment_Task; Interrupt_Management.Initialize; -- Prepare the set of signals that should unblocked in all tasks Result := sigemptyset (Unblocked_Signal_Mask'Access); pragma Assert (Result = 0); for J in Interrupt_Management.Interrupt_ID loop if System.Interrupt_Management.Keep_Unmasked (J) then Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J)); pragma Assert (Result = 0); end if; end loop; -- Initialize the lock used to synchronize chain of all ATCBs Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Specific.Initialize (Environment_Task); if Use_Alternate_Stack then Environment_Task.Common.Task_Alternate_Stack := Alternate_Stack'Address; end if; -- Make environment task known here because it doesn't go through -- Activate_Tasks, which does it for all other tasks. Known_Tasks (Known_Tasks'First) := Environment_Task; Environment_Task.Known_Tasks_Index := Known_Tasks'First; Enter_Task (Environment_Task); if State (System.Interrupt_Management.Abort_Task_Interrupt) /= Default then act.sa_flags := 0; act.sa_handler := Abort_Handler'Address; Result := sigemptyset (Tmp_Set'Access); pragma Assert (Result = 0); act.sa_mask := Tmp_Set; Result := sigaction (Signal (System.Interrupt_Management.Abort_Task_Interrupt), act'Unchecked_Access, old_act'Unchecked_Access); pragma Assert (Result = 0); Abort_Handler_Installed := True; end if; end Initialize; ----------------------- -- Set_Task_Affinity -- ----------------------- procedure Set_Task_Affinity (T : ST.Task_Id) is pragma Unreferenced (T); begin -- Setting task affinity is not supported by the underlying system null; end Set_Task_Affinity; end System.Task_Primitives.Operations;
zhmu/ananas
Ada
460
ads
package Aggr10_Pkg is type Name_Id is range 300_000_000 .. 399_999_999; type Int is range -2 ** 31 .. +2 ** 31 - 1; type Source_Id is range 5_000_000 .. 5_999_999; type Name_Location is record Name : Name_Id; Location : Int; Source : Source_Id; Except : Boolean; Found : Boolean := False; end record; function Get return Name_Location; procedure Set (Name_Loc : Name_Location); end Aggr10_Pkg;
Componolit/libsparkcrypto
Ada
6,612
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Debug; with LSC.Internal.Ops32; package body LSC.Internal.HMAC_SHA256 is IPad : constant SHA256.Block_Type := SHA256.Block_Type'(SHA256.Block_Index => 16#36363636#); OPad : constant SHA256.Block_Type := SHA256.Block_Type'(SHA256.Block_Index => 16#5C5C5C5C#); ---------------------------------------------------------------------------- function Context_Init (Key : SHA256.Block_Type) return Context_Type is Result : Context_Type; Temp : SHA256.Block_Type; begin pragma Debug (Debug.Put_Line ("HMAC.SHA256.Context_Init:")); Result.Key := Key; Result.SHA256_Context := SHA256.SHA256_Context_Init; Ops32.Block_XOR (IPad, Result.Key, Temp); SHA256.Context_Update (Result.SHA256_Context, Temp); return Result; end Context_Init; ---------------------------------------------------------------------------- procedure Context_Update (Context : in out Context_Type; Block : in SHA256.Block_Type) is begin pragma Debug (Debug.Put_Line ("HMAC.SHA256.Context_Update:")); SHA256.Context_Update (Context.SHA256_Context, Block); end Context_Update; ---------------------------------------------------------------------------- procedure Context_Finalize_Outer (Context : in out Context_Type) with Depends => (Context => Context); procedure Context_Finalize_Outer (Context : in out Context_Type) is Hash : SHA256.SHA256_Hash_Type; Temp : SHA256.Block_Type; begin Hash := SHA256.SHA256_Get_Hash (Context.SHA256_Context); Context.SHA256_Context := SHA256.SHA256_Context_Init; Ops32.Block_XOR (OPad, Context.Key, Temp); SHA256.Context_Update (Context.SHA256_Context, Temp); Temp := SHA256.Null_Block; Ops32.Block_Copy (Hash, Temp); SHA256.Context_Finalize (Context.SHA256_Context, Temp, 256); end Context_Finalize_Outer; ---------------------------------------------------------------------------- procedure Context_Finalize (Context : in out Context_Type; Block : in SHA256.Block_Type; Length : in SHA256.Block_Length_Type) is begin pragma Debug (Debug.Put_Line ("HMAC.SHA256.Context_Finalize:")); SHA256.Context_Finalize (Context.SHA256_Context, Block, Length); Context_Finalize_Outer (Context); end Context_Finalize; ---------------------------------------------------------------------------- function Get_Prf (Context : in Context_Type) return SHA256.SHA256_Hash_Type is begin return SHA256.SHA256_Get_Hash (Context.SHA256_Context); end Get_Prf; ---------------------------------------------------------------------------- function Get_Auth (Context : in Context_Type) return Auth_Type is Result : Auth_Type; Prf : SHA256.SHA256_Hash_Type; begin Prf := SHA256.SHA256_Get_Hash (Context.SHA256_Context); for Index in Auth_Index loop pragma Loop_Invariant (for all I in SHA256.SHA256_Hash_Index => (Prf (I) in Types.Word32)); Result (Index) := Prf (Index); end loop; return Result; end Get_Auth; ---------------------------------------------------------------------------- function Keyed_Hash (Key : SHA256.Block_Type; Message : SHA256.Message_Type; Length : SHA256.Message_Index) return Context_Type with Pre => Message'First <= Message'Last and Length / SHA256.Block_Size + (if Length mod SHA256.Block_Size = 0 then 0 else 1) <= Message'Length; function Keyed_Hash (Key : SHA256.Block_Type; Message : SHA256.Message_Type; Length : SHA256.Message_Index) return Context_Type is HMAC_Ctx : Context_Type; begin HMAC_Ctx := Context_Init (Key); SHA256.Hash_Context (Message, Length, HMAC_Ctx.SHA256_Context); Context_Finalize_Outer (HMAC_Ctx); return HMAC_Ctx; end Keyed_Hash; ---------------------------------------------------------------------------- function Pseudorandom (Key : SHA256.Block_Type; Message : SHA256.Message_Type; Length : SHA256.Message_Index) return SHA256.SHA256_Hash_Type is begin return Get_Prf (Keyed_Hash (Key, Message, Length)); end Pseudorandom; ---------------------------------------------------------------------------- function Authenticate (Key : SHA256.Block_Type; Message : SHA256.Message_Type; Length : SHA256.Message_Index) return Auth_Type is begin return Get_Auth (Keyed_Hash (Key, Message, Length)); end Authenticate; end LSC.Internal.HMAC_SHA256;
charlie5/lace
Ada
6,633
adb
with openGL.Geometry.textured, openGL.Texture, openGL.IO, openGL.Primitive.indexed; package body openGL.Model.sphere.textured is --------- --- Forge -- function new_Sphere (Radius : in Real; lat_Count : in Positive := 26; long_Count : in Positive := 52; Image : in asset_Name := null_Asset; is_Skysphere : in Boolean := False) return View is Self : constant View := new Item; begin Self.lat_Count := lat_Count; Self.long_Count := long_Count; Self.Image := Image; Self.is_Skysphere := is_Skysphere; Self.define (Radius); return Self; end new_Sphere; -------------- --- Attributes -- -- NB: - An extra vertex is required at the end of each latitude ring. -- - This last vertex has the same site as the rings initial vertex. -- - The last vertex has 's' texture coord of 1.0, whereas -- the initial vertex has 's' texture coord of 0.0. -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views is pragma unreferenced (Textures, Fonts); use Geometry, Geometry.textured; lat_Count : Positive renames Self.lat_Count; long_Count : Positive renames Self.long_Count; Num_lat_strips : constant Positive := lat_Count - 1; lat_Spacing : constant Real := Degrees_180 / Real (lat_Count - 1); long_Spacing : constant Real := Degrees_360 / Real (long_Count); vertex_Count : constant Index_t := 1 + 1 -- North and south pole. + Index_t ((long_Count + 1) * (lat_Count - 2)); -- Each latitude ring. indices_Count : constant long_Index_t := long_Index_t (Num_lat_strips * (long_Count + 1) * 2); the_Vertices : aliased Geometry.textured.Vertex_array := [1 .. vertex_Count => <>]; the_Indices : aliased Indices := [1 .. indices_Count => <>]; the_Geometry : constant Geometry.textured.view := Geometry.textured.new_Geometry; begin set_Sites: declare use linear_Algebra_3d; north_Pole : constant Site := [0.0, 0.5, 0.0]; south_Pole : constant Site := [0.0, -0.5, 0.0]; the_Site : Site := north_Pole; vert_Id : Index_t := 1; -- Start at '1' (not '0')to account for north pole. a, b : Real := 0.0; -- Angular 'cursors' used to track lat/long for texture coords. latitude_line_First : Site; begin the_Vertices (the_Vertices'First).Site := north_Pole; the_Vertices (the_Vertices'First).Coords := (S => 0.5, T => 1.0); the_Vertices (the_Vertices'Last).Site := south_Pole; the_Vertices (the_Vertices'Last).Coords := (S => 0.5, T => 0.0); for lat_Id in 2 .. lat_Count - 1 loop a := 0.0; b := b + lat_Spacing; the_Site := the_Site * z_rotation_from (lat_Spacing); latitude_line_First := the_Site; -- Store initial latitude lines 1st point. vert_Id := vert_Id + 1; the_Vertices (vert_Id).Site := the_Site; the_Vertices (vert_Id).Coords := (S => a / Degrees_360, T => 1.0 - b / Degrees_180); for long_Id in 1 .. long_Count loop a := a + long_Spacing; if long_Id /= long_Count then the_Site := the_Site * y_rotation_from (-long_Spacing); else the_Site := latitude_line_First; -- Restore the_Vertex back to initial latitude lines 1st point. end if; vert_Id := vert_Id + 1; the_Vertices (vert_Id).Site := the_Site; the_Vertices (vert_Id).Coords := (S => a / Degrees_360, T => 1.0 - b / Degrees_180); end loop; end loop; end set_Sites; for i in the_Vertices'Range loop the_Vertices (i).Site := the_Vertices (i).Site * Self.Radius * 2.0; end loop; set_Indices: declare strip_Id : long_Index_t := 0; Upper : Index_t; Lower : Index_t; begin upper := 1; lower := 2; for lat_Strip in 1 .. num_lat_Strips loop for Each in 1 .. long_Count + 1 loop strip_Id := strip_Id + 1; the_Indices (strip_Id) := Upper; strip_Id := strip_Id + 1; the_Indices (strip_Id) := Lower; if lat_Strip /= 1 then Upper := Upper + 1; end if; if lat_Strip /= num_lat_Strips then Lower := Lower + 1; end if; end loop; if lat_Strip = 1 then Upper := 2; end if; Lower := Upper + Index_t (long_Count) + 1; end loop; end set_Indices; declare Pad : Index_t; begin for i in the_Indices'Range loop if i mod 2 = 1 then Pad := the_Indices (i); the_Indices (i) := the_Indices (i+1); the_Indices (i+1) := Pad; end if; end loop; end; if Self.Image /= null_Asset then set_Texture: declare use Texture; the_Image : constant Image := IO .to_Image (Self.Image); the_Texture : constant Texture.object := Forge.to_Texture ( the_Image); begin the_Geometry.Texture_is (the_Texture); end set_Texture; end if; the_Geometry.is_Transparent (False); -- TODO: Base this on vertex data. the_Geometry.Vertices_are (the_Vertices); declare the_Primitive : constant Primitive.indexed.view := Primitive.indexed.new_Primitive (Primitive.triangle_Strip, the_Indices); begin the_Geometry.add (Primitive.view (the_Primitive)); end; return [1 => Geometry.view (the_Geometry)]; end to_GL_Geometries; end openGL.Model.sphere.textured;
AdaCore/libadalang
Ada
207
ads
package Pack is type Some_Task; type Some_Task is limited private; private package T is procedure Foo; end T; task type Some_Task is entry Start; end Some_Task; end Pack;
mfkiwl/ewok-kernel-security-OS
Ada
19,444
adb
-- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with m4.cpu; with m4.cpu.instructions; with ewok.debug; with ewok.layout; use ewok.layout; with ewok.ipc; use ewok.ipc; with ewok.rng; with ewok.softirq; with ewok.memory; with types.c; use type types.c.t_retval; with config.tasks; with config.applications; -- Automatically generated with config.memlayout; -- Automatically generated package body ewok.tasks with spark_mode => off is procedure idle_task is begin pragma DEBUG (debug.log (debug.INFO, "IDLE thread")); m4.cpu.enable_irq; loop m4.cpu.instructions.wait_for_interrupt; end loop; end idle_task; procedure finished_task is begin loop null; end loop; end finished_task; procedure create_stack (sp : in system_address; pc : in system_address; params : in ewok.t_parameters; frame_a : out ewok.t_stack_frame_access) is begin frame_a := to_stack_frame_access (sp - (t_stack_frame'size / 8)); frame_a.all.R0 := params(1); frame_a.all.R1 := params(2); frame_a.all.R2 := params(3); frame_a.all.R3 := params(4); frame_a.all.R4 := 0; frame_a.all.R5 := 0; frame_a.all.R6 := 0; frame_a.all.R7 := 0; frame_a.all.R8 := 0; frame_a.all.R9 := 0; frame_a.all.R10 := 0; frame_a.all.R11 := 0; frame_a.all.R12 := 0; frame_a.all.exc_return := m4.cpu.EXC_THREAD_MODE; frame_a.all.LR := to_system_address (finished_task'address); frame_a.all.PC := pc; frame_a.all.PSR := m4.cpu.t_PSR_register' (ISR_NUMBER => 0, ICI_IT_lo => 0, GE => 0, Thumb => 1, ICI_IT_hi => 0, DSP_overflow => 0, Overflow => 0, Carry => 0, Zero => 0, Negative => 0); end create_stack; procedure set_default_values (tsk : out t_task) is begin tsk.name := " "; tsk.entry_point := 0; tsk.ttype := TASK_TYPE_USER; tsk.mode := TASK_MODE_MAINTHREAD; tsk.id := ID_UNUSED; tsk.prio := 0; #if CONFIG_KERNEL_DOMAIN tsk.domain := 0; #end if; #if CONFIG_KERNEL_SCHED_DEBUG tsk.count := 0; tsk.force_count := 0; tsk.isr_count := 0; #end if; tsk.num_dma_shms := 0; tsk.dma_shm := (others => ewok.exported.dma.t_dma_shm_info' (granted_id => ID_UNUSED, accessed_id => ID_UNUSED, base => 0, size => 0, access_type => ewok.exported.dma.SHM_ACCESS_READ)); tsk.num_dma_id := 0; tsk.dma_id := (others => ewok.dma_shared.ID_DMA_UNUSED); tsk.num_devs := 0; tsk.devices := (others => (ewok.devices_shared.ID_DEV_UNUSED, false)); tsk.init_done := false; tsk.data_start := 0; tsk.data_end := 0; tsk.txt_start := 0; tsk.txt_end := 0; tsk.stack_size := 0; tsk.state := TASK_STATE_EMPTY; tsk.isr_state := TASK_STATE_EMPTY; tsk.ipc_endpoint_id := (others => ID_ENDPOINT_UNUSED); tsk.ctx.frame_a := NULL; tsk.isr_ctx := t_isr_context'(0, ID_DEV_UNUSED, ISR_STANDARD, NULL); end set_default_values; procedure init_softirq_task is params : constant t_parameters := (others => 0); begin -- Setting default values set_default_values (tasks_list(ID_SOFTIRQ)); tasks_list(ID_SOFTIRQ).name := softirq_task_name; tasks_list(ID_SOFTIRQ).entry_point := to_system_address (ewok.softirq.main_task'address); if tasks_list(ID_SOFTIRQ).entry_point mod 2 = 0 then tasks_list(ID_SOFTIRQ).entry_point := tasks_list(ID_SOFTIRQ).entry_point + 1; end if; tasks_list(ID_SOFTIRQ).ttype := TASK_TYPE_KERNEL; tasks_list(ID_SOFTIRQ).id := ID_SOFTIRQ; -- Zeroing the stack declare stack : byte_array(1 .. STACK_SIZE_SOFTIRQ) with address => to_address (STACK_TOP_SOFTIRQ - STACK_SIZE_SOFTIRQ); begin stack := (others => 0); end; -- Create the initial stack frame and set the stack pointer create_stack (STACK_TOP_SOFTIRQ, tasks_list(ID_SOFTIRQ).entry_point, params, tasks_list(ID_SOFTIRQ).ctx.frame_a); tasks_list(ID_SOFTIRQ).stack_size := STACK_SIZE_SOFTIRQ; tasks_list(ID_SOFTIRQ).state := TASK_STATE_IDLE; tasks_list(ID_SOFTIRQ).isr_state := TASK_STATE_IDLE; for i in tasks_list(ID_SOFTIRQ).ipc_endpoint_id'range loop tasks_list(ID_SOFTIRQ).ipc_endpoint_id(i) := ID_ENDPOINT_UNUSED; end loop; pragma DEBUG (debug.log (debug.INFO, "Created SOFTIRQ context (pc: " & system_address'image (tasks_list(ID_SOFTIRQ).entry_point) & ") sp: " & system_address'image (to_system_address (tasks_list(ID_SOFTIRQ).ctx.frame_a)))); end init_softirq_task; procedure init_idle_task is params : constant t_parameters := (others => 0); begin -- Setting default values set_default_values (tasks_list(ID_KERNEL)); tasks_list(ID_KERNEL).name := idle_task_name; tasks_list(ID_KERNEL).entry_point := to_system_address (idle_task'address); if tasks_list(ID_KERNEL).entry_point mod 2 = 0 then tasks_list(ID_KERNEL).entry_point := tasks_list(ID_KERNEL).entry_point + 1; end if; tasks_list(ID_KERNEL).ttype := TASK_TYPE_KERNEL; tasks_list(ID_KERNEL).mode := TASK_MODE_MAINTHREAD; tasks_list(ID_KERNEL).id := ID_KERNEL; -- Zeroing the stack declare stack : byte_array(1 .. STACK_SIZE_IDLE) with address => to_address (STACK_TOP_IDLE - STACK_SIZE_IDLE); begin stack := (others => 0); end; -- Create the initial stack frame and set the stack pointer create_stack (STACK_TOP_IDLE, tasks_list(ID_KERNEL).entry_point, params, tasks_list(ID_KERNEL).ctx.frame_a); tasks_list(ID_KERNEL).stack_size := STACK_SIZE_IDLE; tasks_list(ID_KERNEL).state := TASK_STATE_RUNNABLE; tasks_list(ID_KERNEL).isr_state := TASK_STATE_IDLE; for i in tasks_list(ID_KERNEL).ipc_endpoint_id'range loop tasks_list(ID_KERNEL).ipc_endpoint_id(i) := ID_ENDPOINT_UNUSED; end loop; pragma DEBUG (debug.log (debug.INFO, "Created context for IDLE task (pc: " & system_address'image (tasks_list(ID_KERNEL).entry_point) & ") sp: " & system_address'image (to_system_address (tasks_list(ID_KERNEL).ctx.frame_a)))); end init_idle_task; procedure init_apps is user_base : system_address; params : t_parameters; random : unsigned_32; ok : boolean; begin if config.applications.t_real_task_id'last > ID_APP7 then debug.panic ("Too many apps"); end if; user_base := config.memlayout.apps_region.flash_memory_addr; for id in config.applications.list'range loop set_default_values (tasks_list(id)); tasks_list(id).name := config.applications.list(id).name; tasks_list(id).entry_point := user_base + config.applications.list(id).text_offset + config.applications.list(id).entrypoint_offset; if tasks_list(id).entry_point mod 2 = 0 then tasks_list(id).entry_point := tasks_list(id).entry_point + 1; end if; tasks_list(id).ttype := TASK_TYPE_USER; tasks_list(id).id := id; tasks_list(id).prio := config.applications.list(id).priority; #if CONFIG_KERNEL_DOMAIN tasks_list(id).domain := config.applications.list(id).domain; #end if; tasks_list(id).data_start := config.memlayout.apps_region.ram_memory_addr + config.applications.list(id).data_offset; tasks_list(id).data_end := config.memlayout.apps_region.ram_memory_addr + config.applications.list(id).data_offset + to_unsigned_32(config.applications.list(id).stack_size) + to_unsigned_32(config.applications.list(id).data_size) + to_unsigned_32(config.applications.list(id).bss_size) + to_unsigned_32(config.applications.list(id).heap_size) + config.memlayout.list(id).ram_free_space; tasks_list(id).txt_start := user_base + config.applications.list(id).text_offset; tasks_list(id).txt_end := user_base + config.applications.list(id).text_offset + config.applications.list(id).text_size + to_unsigned_32(config.applications.list(id).data_size); tasks_list(id).stack_bottom := config.memlayout.apps_region.ram_memory_addr + config.applications.list(id).data_offset; tasks_list(id).stack_top := config.memlayout.apps_region.ram_memory_addr + config.applications.list(id).data_offset + to_unsigned_32(config.applications.list(id).stack_size); tasks_list(id).stack_size := config.applications.list(id).stack_size; tasks_list(id).state := TASK_STATE_RUNNABLE; tasks_list(id).isr_state := TASK_STATE_IDLE; for i in tasks_list(id).ipc_endpoint_id'range loop tasks_list(id).ipc_endpoint_id(i) := ID_ENDPOINT_UNUSED; end loop; -- Zeroing the stack declare stack : byte_array(1 .. to_unsigned_32(tasks_list(id).stack_size)) with address => to_address (tasks_list(id).data_end - to_unsigned_32(tasks_list(id).stack_size)); begin stack := (others => 0); end; -- -- Create the initial stack frame and set the stack pointer -- -- Getting the stack "canary" ewok.rng.random (random, ok); if not ok then pragma DEBUG (debug.log (debug.ERROR, "Unable to get random from TRNG source")); end if; params := t_parameters'(to_unsigned_32 (id), random, 0, 0); create_stack (tasks_list(id).stack_top, tasks_list(id).entry_point, params, tasks_list(id).ctx.frame_a); tasks_list(id).isr_ctx.entry_point := user_base + config.applications.list(id).text_offset + config.applications.list(id).isr_entrypoint_offset; pragma DEBUG (debug.log (debug.INFO, "Created task " & tasks_list(id).name & " (pc: " & system_address'image (tasks_list(id).entry_point) & ", data: " & system_address'image (tasks_list(id).data_start) & " - " & system_address'image (tasks_list(id).data_end) & ", sp: " & system_address'image (to_system_address (tasks_list(id).ctx.frame_a)) & ", ID" & t_task_id'image (id) & ")")); end loop; end init_apps; function get_task_id (name : t_task_name) return ewok.tasks_shared.t_task_id is -- String comparison is a bit tricky here because: -- - We want it case-unsensitive ('a' and 'A' are the same) -- - The nul character and space ' ' are consider the same -- -- The following inner functions are needed to effect comparisons: -- Convert a character to uppercase function to_upper (c : character) return character is val : constant natural := character'pos (c); begin return (if c in 'a' .. 'z' then character'val (val - 16#20#) else c); end; -- Test if a character is 'nul' function is_nul (c : character) return boolean is begin return c = ASCII.NUL or c = ' '; end; -- Test if the 2 strings are the same function is_same (s1: t_task_name; s2 : t_task_name) return boolean is begin for i in t_task_name'range loop if is_nul (s1(i)) and is_nul (s2(i)) then return true; end if; if to_upper (s1(i)) /= to_upper (s2(i)) then return false; end if; end loop; return true; end; begin for id in config.applications.list'range loop if is_same (tasks_list(id).name, name) then return id; end if; end loop; return ID_UNUSED; end get_task_id; #if CONFIG_KERNEL_DOMAIN function get_domain (id : in ewok.tasks_shared.t_task_id) return unsigned_8 is begin return tasks_list(id).domain; end get_domain; #end if; function get_state (id : ewok.tasks_shared.t_task_id; mode : t_task_mode) return t_task_state is begin if mode = TASK_MODE_MAINTHREAD then return tasks_list(id).state; else return tasks_list(id).isr_state; end if; end get_state; procedure set_state (id : ewok.tasks_shared.t_task_id; mode : t_task_mode; state : t_task_state) is begin if mode = TASK_MODE_MAINTHREAD then tasks_list(id).state := state; else tasks_list(id).isr_state := state; end if; end set_state; function get_mode (id : in ewok.tasks_shared.t_task_id) return t_task_mode is begin return tasks_list(id).mode; end get_mode; procedure set_mode (id : in ewok.tasks_shared.t_task_id; mode : in ewok.tasks_shared.t_task_mode) is begin tasks_list(id).mode := mode; end set_mode; function is_ipc_waiting (id : in ewok.tasks_shared.t_task_id) return boolean is begin for i in tasks_list(id).ipc_endpoint_id'range loop if tasks_list(id).ipc_endpoint_id(i) /= ID_ENDPOINT_UNUSED and then ewok.ipc.ipc_endpoints(tasks_list(id).ipc_endpoint_id(i)).state = ewok.ipc.WAIT_FOR_RECEIVER and then ewok.ipc.to_task_id (ewok.ipc.ipc_endpoints(tasks_list(id).ipc_endpoint_id(i)).to) = id then return true; end if; end loop; return false; end; procedure append_device (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id; descriptor : out unsigned_8; success : out boolean) is begin if tasks_list(id).num_devs = MAX_DEVS_PER_TASK then descriptor := 0; success := false; return; end if; for i in tasks_list(id).devices'range loop if tasks_list(id).devices(i).device_id = ID_DEV_UNUSED then tasks_list(id).devices(i).device_id := dev_id; tasks_list(id).devices(i).mounted := false; tasks_list(id).num_devs := tasks_list(id).num_devs + 1; descriptor := i; success := true; return; end if; end loop; raise program_error; end append_device; procedure remove_device (id : in ewok.tasks_shared.t_task_id; dev_descriptor : in unsigned_8) is begin tasks_list(id).devices(dev_descriptor).device_id := ID_DEV_UNUSED; tasks_list(id).devices(dev_descriptor).mounted := false; tasks_list(id).num_devs := tasks_list(id).num_devs - 1; end remove_device; function is_mounted (id : in ewok.tasks_shared.t_task_id; dev_descriptor : in unsigned_8) return boolean is begin -- FIXME: defensive programming, should be removed if tasks_list(id).devices(dev_descriptor).device_id = ID_DEV_UNUSED then raise program_error; end if; return tasks_list(id).devices(dev_descriptor).mounted; end is_mounted; procedure mount_device (id : in ewok.tasks_shared.t_task_id; dev_descriptor : in unsigned_8; success : out boolean) is begin -- FIXME: defensive programming, should be removed if is_mounted (id, dev_descriptor) then raise program_error; end if; -- Mapping the device ewok.memory.map_device (tasks_list(id).devices(dev_descriptor).device_id, success); if success then tasks_list(id).devices(dev_descriptor).mounted := true; end if; end mount_device; procedure unmount_device (id : in ewok.tasks_shared.t_task_id; dev_descriptor : in unsigned_8; success : out boolean) is begin -- FIXME: defensive programming, should be removed if not is_mounted (id, dev_descriptor) then raise program_error; end if; -- Unmapping the device ewok.memory.unmap_device (tasks_list(id).devices(dev_descriptor).device_id); tasks_list(id).devices(dev_descriptor).mounted := false; success := true; end unmount_device; function is_real_user (id : ewok.tasks_shared.t_task_id) return boolean is begin return (id in config.applications.t_real_task_id); end is_real_user; procedure set_return_value (id : in ewok.tasks_shared.t_task_id; mode : in t_task_mode; val : in unsigned_32) is begin case mode is when TASK_MODE_MAINTHREAD => tasks_list(id).ctx.frame_a.all.R0 := val; when TASK_MODE_ISRTHREAD => tasks_list(id).isr_ctx.frame_a.all.R0 := val; end case; end set_return_value; procedure task_init is begin for id in tasks_list'range loop set_default_values (tasks_list(id)); end loop; init_idle_task; init_softirq_task; init_apps; for id in config.applications.list'range loop config.tasks.copy_data_to_ram(id); config.tasks.zeroify_bss(id); end loop; end task_init; function is_init_done (id : ewok.tasks_shared.t_task_id) return boolean is begin return tasks_list(id).init_done; end is_init_done; end ewok.tasks;
annexi-strayline/ASAP-Unicode
Ada
3,661
ads
------------------------------------------------------------------------------ -- -- -- Unicode Utilities -- -- -- -- Normalization Form Utilities -- -- Quick Check Query Facilities -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- Normalization Form KC quick check function Unicode.Normalization.Quick_Check.KC (C: Wide_Wide_Character) return Quick_Check_Result;
gusthoff/ada_wavefiles_gtk_app
Ada
4,519
adb
------------------------------------------------------------------------------- -- -- WAVEFILES GTK APPLICATION -- -- Wavefile Manager -- -- The MIT License (MIT) -- -- Copyright (c) 2017 Gustavo A. Hoffmann -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and / -- or sell copies of the Software, and to permit persons to whom the Software -- is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -- IN THE SOFTWARE. ------------------------------------------------------------------------------- with Interfaces; with Ada.Characters.Latin_1; with Audio.Wavefiles; with Audio.RIFF.Wav.Formats; with Audio.RIFF.Wav.GUIDs; package body WaveFiles_Gtk.Wavefile_Manager is -------------- -- Get_Info -- -------------- function Get_Info (Wavefile : String) return String is WF_In : Audio.Wavefiles.Wavefile; RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible; function Get_RIFF_GUID_String (Sub_Format : Audio.RIFF.Wav.Formats.GUID) return String; function Get_RIFF_Extended (RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible) return String; package Wav_Read renames Audio.Wavefiles; use Interfaces; function Get_RIFF_GUID_String (Sub_Format : Audio.RIFF.Wav.Formats.GUID) return String is use type Audio.RIFF.Wav.Formats.GUID; begin if Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_Undefined then return "Subformat: undefined"; elsif Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_PCM then return "Subformat: KSDATAFORMAT_SUBTYPE_PCM (IEC 60958 PCM)"; elsif Sub_Format = Audio.RIFF.Wav.GUIDs.GUID_IEEE_Float then return "Subformat: KSDATAFORMAT_SUBTYPE_IEEE_FLOAT " & "(IEEE Floating-Point PCM)"; else return "Subformat: unknown"; end if; end Get_RIFF_GUID_String; function Get_RIFF_Extended (RIFF_Data : Audio.RIFF.Wav.Formats.Wave_Format_Extensible) return String is S : constant String := ("Valid bits per sample: " & Unsigned_16'Image (RIFF_Data.Valid_Bits_Per_Sample)); begin if RIFF_Data.Size > 0 then return (S & Ada.Characters.Latin_1.LF & Get_RIFF_GUID_String (RIFF_Data.Sub_Format)); else return ""; end if; end Get_RIFF_Extended; begin Wav_Read.Open (WF_In, Wav_Read.In_File, Wavefile); RIFF_Data := Wav_Read.Format_Of_Wavefile (WF_In); Wav_Read.Close (WF_In); declare S_Wav_1 : constant String := ("Bits per sample: " & Audio.RIFF.Wav.Formats.Wav_Bit_Depth'Image (RIFF_Data.Bits_Per_Sample) & Ada.Characters.Latin_1.LF & "Channels: " & Unsigned_16'Image (RIFF_Data.Channels) & Ada.Characters.Latin_1.LF & "Samples per second: " & Audio.RIFF.Wav.Formats.Wav_Sample_Rate'Image (RIFF_Data.Samples_Per_Sec) & Ada.Characters.Latin_1.LF & "Extended size: " & Unsigned_16'Image (RIFF_Data.Size) & Ada.Characters.Latin_1.LF); S_Wav_2 : constant String := Get_RIFF_Extended (RIFF_Data); begin return "File: " & Wavefile & Ada.Characters.Latin_1.LF & S_Wav_1 & S_Wav_2; end; end Get_Info; end WaveFiles_Gtk.Wavefile_Manager;
reznikmm/matreshka
Ada
1,462
ads
with Styx.Messages.Attaches; with Styx.Messages.Authes; with Styx.Messages.Clunks; with Styx.Messages.Opens; with Styx.Messages.Reads; with Styx.Messages.Stats; with Styx.Messages.Versions; with Styx.Messages.Walks; with Styx.Request_Visiters; package Styx.Debug is type Request_Debuger is new Styx.Request_Visiters.Request_Visiter with private; private type Request_Debuger is new Styx.Request_Visiters.Request_Visiter with null record; overriding procedure Attach (Self : in out Request_Debuger; Message : Styx.Messages.Attaches.Attach_Request); overriding procedure Auth (Self : in out Request_Debuger; Message : Styx.Messages.Authes.Auth_Request); overriding procedure Clunk (Self : in out Request_Debuger; Message : Styx.Messages.Clunks.Clunk_Request); overriding procedure Open (Self : in out Request_Debuger; Message : Styx.Messages.Opens.Open_Request); overriding procedure Read (Self : in out Request_Debuger; Message : Styx.Messages.Reads.Read_Request); overriding procedure Stat (Self : in out Request_Debuger; Message : Styx.Messages.Stats.Stat_Request); overriding procedure Version (Self : in out Request_Debuger; Message : Styx.Messages.Versions.Version_Request); overriding procedure Walk (Self : in out Request_Debuger; Message : Styx.Messages.WalkS.Walk_Request); end Styx.Debug;
io7m/coreland-symbex
Ada
4,123
ads
with Ada.Containers.Vectors; with Ada.Strings.Wide_Unbounded; with Symbex.Lex; with Stack; pragma Elaborate_All (Stack); package Symbex.Parse is type Tree_t is private; -- -- Tree status value. -- type Tree_Status_t is (Tree_OK, Tree_Error_Excess_Closing_Parentheses, Tree_Error_Unterminated_List); -- Status values corresponding to error conditions. subtype Tree_Error_Status_t is Tree_Status_t range Tree_Error_Excess_Closing_Parentheses .. Tree_Status_t'Last; -- -- Tree node types. -- -- Kind of list element. type Node_Kind_t is (Node_String, Node_Symbol, Node_List); -- Element of list. type Node_t is private; subtype Node_Symbol_Name_t is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; subtype Node_String_Data_t is Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; -- Return kind of node. function Node_Kind (Node : in Node_t) return Node_Kind_t; -- -- Tree list types. -- -- List, containing nodes. type List_t is private; -- Unique list identifier. type List_ID_t is new Positive; type List_Length_t is new Natural; type List_Position_t is new Positive; type List_Depth_t is new Natural; -- Retrieve number of nodes in list. function List_Length (List : in List_t) return List_Length_t; -- -- Tree is initialized? -- function Initialized (Tree : in Tree_t) return Boolean; -- -- Tree parsing is completed? -- function Completed (Tree : in Tree_t) return Boolean; -- -- Initialize parser state. -- procedure Initialize_Tree (Tree : in out Tree_t; Status : out Tree_Status_t); -- pragma Postcondition -- (((Status = Tree_OK) and Initialized (Tree)) or -- ((Status /= Tree_OK) and not Initialized (Tree))); -- -- Process token. -- procedure Process_Token (Tree : in out Tree_t; Token : in Lex.Token_t; Status : out Tree_Status_t); pragma Precondition (Initialized (Tree) and Token.Is_Valid and not Completed (Tree)); -- -- Subprograms only of practical use to the rest of Symbex. -- package Internal is -- -- Fetch node data (only valid for strings and symbols). -- function Get_Data (Node : in Node_t) return Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; pragma Precondition (Node_Kind (Node) /= Node_List); -- -- Fetch node list ID (only valid for lists). -- function Get_List_ID (Node : in Node_t) return List_ID_t; pragma Precondition (Node_Kind (Node) = Node_List); -- -- Retrieve list. -- function Get_List (Tree : in Tree_t; List_ID : in List_ID_t) return List_t; pragma Precondition (Completed (Tree)); -- -- Iterate over nodes in list. -- procedure List_Iterate (List : in List_t; Process : access procedure (Node : in Node_t)); end Internal; private package UBW_Strings renames Ada.Strings.Wide_Unbounded; -- Node type, element of list. type Node_t (Kind : Node_Kind_t := Node_Symbol) is record case Kind is when Node_Symbol => Name : Node_Symbol_Name_t; when Node_String => Data : Node_String_Data_t; when Node_List => List : List_ID_t; end case; end record; -- -- Node list. -- package Lists is new Ada.Containers.Vectors (Index_Type => List_Position_t, Element_Type => Node_t); subtype List_Nodes_t is Lists.Vector; type List_t is record Parent : List_ID_t; Nodes : List_Nodes_t; end record; -- -- Array of node lists. -- package List_Arrays is new Ada.Containers.Vectors (Index_Type => List_ID_t, Element_Type => List_t); subtype List_Array_t is List_Arrays.Vector; -- -- List ID stack. -- package List_ID_Stack is new Stack (Element_Type => List_ID_t); -- -- Tree type. -- type Tree_t is record Inited : Boolean; Completed : Boolean; List_Stack : List_ID_Stack.Stack_t; Lists : List_Array_t; Current_List : List_ID_t; end record; end Symbex.Parse;
stcarrez/dynamo
Ada
1,372
adb
-- part of ParserTools, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package body Lexer.Source.File is overriding procedure Read_Data (S : in out Instance; Buffer : out String; Length : out Natural) is use type Ada.Directories.File_Size; begin Length := Natural'Min (Buffer'Length, Natural (S.Input_Length - S.Input_At)); declare subtype Read_Blob is String (1 .. Length); begin Read_Blob'Read (S.Stream, Buffer (Buffer'First .. Buffer'First + Length - 1)); S.Input_At := S.Input_At + Ada.Directories.File_Size (Length); end; end Read_Data; overriding procedure Finalize (Object : in out Instance) is begin Ada.Streams.Stream_IO.Close (Object.File); end Finalize; function As_Source (File_Path : String) return Pointer is Ret : constant Instance_Access := new Instance'(Source.Instance with Input_At => 0, Input_Length => Ada.Directories.Size (File_Path), others => <>); begin Ada.Streams.Stream_IO.Open (Ret.File, Ada.Streams.Stream_IO.In_File, File_Path); Ret.Stream := Ada.Streams.Stream_IO.Stream (Ret.File); return Pointer (Ret); end As_Source; end Lexer.Source.File;
reznikmm/matreshka
Ada
3,769
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Db_Append_Table_Alias_Name_Attributes is pragma Preelaborate; type ODF_Db_Append_Table_Alias_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Db_Append_Table_Alias_Name_Attribute_Access is access all ODF_Db_Append_Table_Alias_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Db_Append_Table_Alias_Name_Attributes;
AdaCore/langkit
Ada
3,479
ads
with Ada.Containers; use Ada.Containers; with Ada.Exceptions; use Ada.Exceptions; with Ada.Unchecked_Deallocation; with Langkit_Support.Lexical_Envs; use Langkit_Support.Lexical_Envs; with Langkit_Support.Lexical_Envs_Impl; with Langkit_Support.Symbols; with Langkit_Support.Text; use Langkit_Support.Text; with Langkit_Support.Types; use Langkit_Support.Types; package Support is type Metadata is null record; Default_MD : constant Metadata := (null record); function Get_Context_Version (Dummy_C : Character) return Version_Number is (0); function Node_Hash (Dummy_C : Character) return Hash_Type is (0); function Node_Unit (Dummy_C : Character) return Generic_Unit_Ptr is (No_Generic_Unit); function Metadata_Hash (Dummy_MD : Metadata) return Hash_Type is (0); function Combine (Dummy_L, Dummy_R : Metadata) return Metadata is ((null record)); function Parent (Dummy_Node : Character) return Character is (' '); function Can_Reach (Dummy_Node, Dummy_From : Character) return Boolean is (True); function Is_Rebindable (Dummy_Node : Character) return Boolean is (True); function Node_Image (Node : Character; Dummy_Short : Boolean := True) return Text_Type is (To_Text ("'" & Node & "'")); function Acquire_Rebinding (Dummy : Character; Parent : Env_Rebindings; Old_Env, New_Env : Lexical_Env) return Env_Rebindings is (new Env_Rebindings_Type'(0, Parent, Old_Env, New_Env, Children => <>)); procedure Register_Rebinding (Dummy_Node : Character; Dummy_Rebinding : Env_Rebindings) is null; function Get_Unit_Version (Dummy : Generic_Unit_Ptr) return Version_Number is (0); type Ref_Category is (No_Cat); type Ref_Categories is array (Ref_Category) of Boolean; type Inner_Env_Assoc is null record; function Get_Key (Dummy : Inner_Env_Assoc) return Langkit_Support.Symbols.Symbol_Type is (null); function Get_Node (Dummy : Inner_Env_Assoc) return Character is (' '); function Get_Metadata (Dummy : Inner_Env_Assoc) return Metadata is (Default_MD); type Inner_Env_Assoc_Array is null record; function Length (Dummy : Inner_Env_Assoc_Array) return Natural is (0); function Get (Dummy_Self : Inner_Env_Assoc_Array; Dummy_Index : Positive) return Inner_ENv_Assoc is (raise Program_Error); procedure Dec_Ref (Self : in out Inner_Env_Assoc_Array) is null; function Properties_May_Raise (Dummy : Exception_Occurrence) return Boolean is (False); package Envs is new Langkit_Support.Lexical_Envs_Impl (Get_Unit_Version => Get_Unit_Version, Node_Type => Character, Node_Metadata => Metadata, No_Node => ' ', Empty_Metadata => Default_MD, Node_Hash => Node_Hash, Metadata_Hash => Metadata_Hash, Combine => Combine, Can_Reach => Can_Reach, Is_Rebindable => Is_Rebindable, Node_Text_Image => Node_Image, Register_Rebinding => Register_Rebinding, Ref_Category => Ref_Category, Ref_Categories => Ref_Categories, Inner_Env_Assoc => Inner_Env_Assoc, Inner_Env_Assoc_Array => Inner_Env_Assoc_Array); procedure Put_Line (Elements : Envs.Entity_Array); procedure Destroy is new Ada.Unchecked_Deallocation (Env_Rebindings_Type, Env_Rebindings); end Support;
reznikmm/matreshka
Ada
6,390
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; with ODF.DOM.Elements.Style.Table_Column_Properties.Internals; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Elements.Style.Table_Column_Properties is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access Style_Table_Column_Properties_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.ODF_Visitor'Class then ODF.DOM.Visitors.ODF_Visitor'Class (Visitor).Enter_Style_Table_Column_Properties (ODF.DOM.Elements.Style.Table_Column_Properties.Internals.Create (Style_Table_Column_Properties_Access (Self)), Control); else Matreshka.DOM_Nodes.Elements.Abstract_Element (Self.all).Enter_Element (Visitor, Control); end if; end Enter_Element; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Table_Column_Properties_Node) return League.Strings.Universal_String is begin return ODF.Constants.Table_Column_Properties_Name; end Get_Local_Name; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access Style_Table_Column_Properties_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.ODF_Visitor'Class then ODF.DOM.Visitors.ODF_Visitor'Class (Visitor).Leave_Style_Table_Column_Properties (ODF.DOM.Elements.Style.Table_Column_Properties.Internals.Create (Style_Table_Column_Properties_Access (Self)), Control); else Matreshka.DOM_Nodes.Elements.Abstract_Element (Self.all).Leave_Element (Visitor, Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access Style_Table_Column_Properties_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.ODF_Iterator'Class then ODF.DOM.Iterators.ODF_Iterator'Class (Iterator).Visit_Style_Table_Column_Properties (Visitor, ODF.DOM.Elements.Style.Table_Column_Properties.Internals.Create (Style_Table_Column_Properties_Access (Self)), Control); else Matreshka.DOM_Nodes.Elements.Abstract_Element (Self.all).Visit_Element (Iterator, Visitor, Control); end if; end Visit_Element; end Matreshka.ODF_Elements.Style.Table_Column_Properties;
faelys/ada-syslog
Ada
1,626
ads
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Syslog.Guess is an empty package, parent of procedures that set some -- -- configuration variables to "guessed" values (i.e. extracted from -- -- the run-time environment). -- ------------------------------------------------------------------------------ package Syslog.Guess is end Syslog.Guess;
charlie5/cBound
Ada
1,787
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_color_table_parameteriv_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; context_tag : aliased xcb.xcb_glx_context_tag_t; target : aliased Interfaces.Unsigned_32; pname : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_color_table_parameteriv_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_color_table_parameteriv_request_t.Item, Element_Array => xcb.xcb_glx_get_color_table_parameteriv_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_color_table_parameteriv_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_color_table_parameteriv_request_t.Pointer, Element_Array => xcb.xcb_glx_get_color_table_parameteriv_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_color_table_parameteriv_request_t;
stcarrez/sql-benchmark
Ada
61,915
adb
-- Version 01 is derived from ExcelOut by Frank Schoonjans in Modula-2 - thanks! -- Modula-2 code has been translated with Mod2Pas and P2Ada. -- -- References to documentation are to: http://www.openoffice.org/sc/excelfileformat.pdf -- -- To do: -- ===== -- - Unicode (for binary Excel: requires BIFF8, but BIFF8 is pretty difficult) -- - border line styles (5.115 XF - Extended Format) -- - XML-based formats support -- - ... with Ada.Unchecked_Deallocation, Ada.Unchecked_Conversion; with Ada.Strings.Fixed; with Interfaces; use Interfaces; -- Package IEEE_754 is from: Simple components for Ada by Dmitry A. Kazakov -- http://www.dmitry-kazakov.de/ada/components.htm with IEEE_754.Generic_Double_Precision; package body Excel_Out is use Ada.Streams.Stream_IO, Ada.Streams; -- Very low level part which deals with transferring data in an endian-neutral way, -- and floats in the IEEE format. This is needed for having Excel Writer -- totally portable on all systems and processor architectures. type Byte_buffer is array (Integer range <>) of Unsigned_8; empty_buffer: constant Byte_buffer:= (1..0 => 0); -- Put numbers with correct endianess as bytes: generic type Number is mod <>; size: Positive; function Intel_x86_buffer( n: Number ) return Byte_buffer; pragma Inline(Intel_x86_buffer); function Intel_x86_buffer( n: Number ) return Byte_buffer is b: Byte_buffer(1..size); m: Number:= n; begin for i in b'Range loop b(i):= Unsigned_8(m and 255); m:= m / 256; end loop; return b; end Intel_x86_buffer; function Intel_32 is new Intel_x86_buffer( Unsigned_32, 4 ); function Intel_16( n: Unsigned_16 ) return Byte_buffer is pragma Inline(Intel_16); begin return (Unsigned_8(n and 255), Unsigned_8(Shift_Right(n, 8))); end Intel_16; -- 2.5.2 Byte Strings, 8-bit string length (BIFF2-BIFF5), p. 187 function To_buf_8_bit_length(s: String) return Byte_buffer is b: Byte_buffer(s'Range); begin if s'Length > 255 then -- length doesn't fit in a byte raise Constraint_Error; end if; for i in b'Range loop b(i):= Character'Pos(s(i)); end loop; return Unsigned_8(s'Length) & b; end To_buf_8_bit_length; -- 2.5.2 Byte Strings, 16-bit string length (BIFF2-BIFF5), p. 187 function To_buf_16_bit_length(s: String) return Byte_buffer is b: Byte_buffer(s'Range); begin if s'Length > 2**16-1 then -- length doesn't fit in a 16-bit number raise Constraint_Error; end if; for i in b'Range loop b(i):= Character'Pos(s(i)); end loop; return Intel_16(s'Length) & b; end To_buf_16_bit_length; -- -- 2.5.3 Unicode Strings, 16-bit string length (BIFF2-BIFF5), p. 17 -- function To_buf_16_bit_length(s: Wide_String) return Byte_buffer is -- b: Byte_buffer(1 .. 2 * s'Length); -- j: Integer:= 1; -- begin -- if s'Length > 2**16-1 then -- length doesn't fit in a 16-bit number -- raise Constraint_Error; -- end if; -- for i in s'Range loop -- b(j) := Unsigned_8(Unsigned_32'(Wide_Character'Pos(s(i))) and 255); -- b(j+1):= Unsigned_8(Shift_Right(Unsigned_32'(Wide_Character'Pos(s(i))), 8)); -- j:= j + 2; -- end loop; -- return -- Intel_16(s'Length) & -- (1 => 1) & -- Character compression (ccompr): 1 = Uncompressed (16-bit characters) -- b; -- end To_buf_16_bit_length; -- Gives a byte sequence of an IEEE 64-bit number as if taken -- from an Intel machine (i.e. with the same endianess). -- -- http://en.wikipedia.org/wiki/IEEE_754-1985#Double-precision_64_bit -- package IEEE_LF is new IEEE_754.Generic_Double_Precision (Long_Float); function IEEE_Double_Intel_Portable(x: Long_Float) return Byte_buffer is pragma Inline(IEEE_Double_Intel_Portable); d : Byte_buffer(1..8); -- f64: constant IEEE_LF.Float_64:= IEEE_LF.To_IEEE(x); begin for i in d'Range loop d(i):= f64(9-i); -- Order is reversed end loop; -- Fully tested in Test_IEEE.adb return d; end IEEE_Double_Intel_Portable; -- Just spit the bytes of the long float - fast way. -- Of course this will work only on an Intel(-like) machine. We check this later. subtype Byte_buffer_8 is Byte_buffer(0..7); function IEEE_Double_Intel_Native is new Ada.Unchecked_Conversion(Long_Float, Byte_buffer_8); x_test: constant Long_Float:= -12345.0e-67; Can_use_native_IEEE: constant Boolean:= IEEE_Double_Intel_Portable(x_test) = IEEE_Double_Intel_Native(x_test); function IEEE_Double_Intel(x: Long_Float) return Byte_buffer is pragma Inline(IEEE_Double_Intel); begin if Can_use_native_IEEE then return IEEE_Double_Intel_Native(x); -- Fast, non-portable else return IEEE_Double_Intel_Portable(x); -- Slower but portable end if; end IEEE_Double_Intel; -- Workaround for the severe xxx'Read xxx'Write performance -- problems in the GNAT and ObjectAda compilers (as in 2009) -- This is possible if and only if Byte = Stream_Element and -- arrays types are both packed and aligned the same way. -- subtype Size_test_a is Byte_buffer(1..19); subtype Size_test_b is Ada.Streams.Stream_Element_Array(1..19); workaround_possible: constant Boolean:= Size_test_a'Size = Size_test_b'Size and Size_test_a'Alignment = Size_test_b'Alignment; procedure Block_Write( stream : in out Ada.Streams.Root_Stream_Type'Class; buffer : in Byte_buffer ) is pragma Inline(Block_Write); SE_Buffer : Stream_Element_Array (1 .. buffer'Length); for SE_Buffer'Address use buffer'Address; pragma Import (Ada, SE_Buffer); begin if workaround_possible then Ada.Streams.Write(stream, SE_Buffer); else Byte_buffer'Write(stream'Access, buffer); -- ^ This was 30x to 70x slower on GNAT 2009 -- Test in the Zip-Ada project. end if; end Block_Write; ---------------- -- Excel BIFF -- ---------------- -- The original Modula-2 code counted on certain assumptions about -- record packing & endianess. We write data without these assumptions. procedure WriteBiff( xl : Excel_Out_Stream'Class; biff_id: Unsigned_16; data : Byte_buffer ) is pragma Inline(WriteBiff); begin Block_Write(xl.xl_stream.all, Intel_16(biff_id)); Block_Write(xl.xl_stream.all, Intel_16(Unsigned_16(data'Length))); Block_Write(xl.xl_stream.all, data); end WriteBiff; -- 5.8 BOF: Beginning of File, p.135 procedure Write_BOF(xl : Excel_Out_Stream'Class) is function BOF_suffix return Byte_buffer is -- 5.8.1 Record BOF begin case xl.format is when BIFF2 => return empty_buffer; when BIFF3 | BIFF4 => return (0,0); -- Not used -- when BIFF8 => -- return (1,1,1,1); end case; end BOF_suffix; -- 0005H = Workbook globals -- 0006H = Visual Basic module -- 0010H = Sheet or dialogue (see SHEETPR, S5.97) Sheet_or_dialogue: constant:= 16#10#; -- 0020H = Chart -- 0040H = Macro sheet biff_record_identifier: constant array(Excel_type) of Unsigned_16:= (BIFF2 => 16#0009#, BIFF3 => 16#0209#, BIFF4 => 16#0409# -- BIFF8 => 16#0809# ); biff_version: constant array(Excel_type) of Unsigned_16:= (BIFF2 => 16#0200#, BIFF3 => 16#0300#, BIFF4 => 16#0400# -- BIFF8 => 16#0600# ); begin WriteBiff(xl, biff_record_identifier(xl.format), Intel_16(biff_version(xl.format)) & Intel_16(Sheet_or_dialogue) & BOF_suffix ); end Write_BOF; -- 5.49 FORMAT (number format) procedure WriteFmtStr (xl : Excel_Out_Stream'Class; s : String) is begin case xl.format is when BIFF2 | BIFF3 => WriteBiff(xl, 16#001E#, To_buf_8_bit_length(s)); when BIFF4 => WriteBiff(xl, 16#041E#, (0, 0) & To_buf_8_bit_length(s)); -- when BIFF8 => -- WriteBiff(xl, 16#041E#, (0, 0) & -- should be: format index used in other records -- To_buf_8_bit_length(s)); end case; end WriteFmtStr; -- Write built-in number formats (internal) procedure WriteFmtRecords (xl : Excel_Out_Stream'Class) is sep_1000: constant Character:= ','; -- US format sep_deci: constant Character:= '.'; -- US format -- ^ If there is any evidence of an issue with those built-in separators, -- we may make them configurable. NB: MS Excel 2002 and 2007 use only -- the index of built-in formats and discards the strings for BIFF2, but not for BIFF3... begin -- 5.12 BUILTINFMTCOUNT case xl.format is when BIFF2 => WriteBiff(xl, 16#001F#, Intel_16(Unsigned_16(last_built_in - 5))); when BIFF3 => WriteBiff(xl, 16#0056#, Intel_16(Unsigned_16(last_built_in - 3))); when BIFF4 => WriteBiff(xl, 16#0056#, Intel_16(Unsigned_16(last_built_in + 1))); -- when BIFF8 => -- null; end case; -- loop & case avoid omitting any choice for n in Number_format_type'First .. last_custom loop case n is when general => WriteFmtStr(xl, "General"); when decimal_0 => WriteFmtStr(xl, "0"); when decimal_2 => WriteFmtStr(xl, "0" & sep_deci & "00"); -- 'Comma' built-in style when decimal_0_thousands_separator => WriteFmtStr(xl, "#" & sep_1000 & "##0"); when decimal_2_thousands_separator => WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00"); when no_currency_0 => if xl.format >= BIFF4 then WriteFmtStr(xl, "#" & sep_1000 & "##0;-#" & sep_1000 & "##0"); end if; when no_currency_red_0 => if xl.format >= BIFF4 then WriteFmtStr(xl, "#" & sep_1000 & "##0;-#" & sep_1000 & "##0"); -- [Red] doesn't go with non-English versions of Excel !! end if; when no_currency_2 => if xl.format >= BIFF4 then WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00;" & "-#" & sep_1000 & "##0" & sep_deci & "00"); end if; when no_currency_red_2 => if xl.format >= BIFF4 then WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00;" & "-#" & sep_1000 & "##0" & sep_deci & "00"); end if; when currency_0 => WriteFmtStr(xl, "$ #" & sep_1000 & "##0;$ -#" & sep_1000 & "##0"); when currency_red_0 => WriteFmtStr(xl, "$ #" & sep_1000 & "##0;$ -#" & sep_1000 & "##0"); -- [Red] doesn't go with non-English versions of Excel !! when currency_2 => WriteFmtStr(xl, "$ #" & sep_1000 & "##0" & sep_deci & "00;" & "$ -#" & sep_1000 & "##0" & sep_deci & "00"); when currency_red_2 => WriteFmtStr(xl, "$ #" & sep_1000 & "##0" & sep_deci & "00;" & "$ -#" & sep_1000 & "##0" & sep_deci & "00"); when percent_0 => WriteFmtStr(xl, "0%"); -- 'Percent' built-in style when percent_2 => WriteFmtStr(xl, "0" & sep_deci & "00%"); when scientific => WriteFmtStr(xl, "0" & sep_deci & "00E+00"); when fraction_1 => if xl.format >= BIFF3 then WriteFmtStr(xl, "#\ ?/?"); end if; when fraction_2 => if xl.format >= BIFF3 then WriteFmtStr(xl, "#\ ??/??"); end if; when dd_mm_yyyy => WriteFmtStr(xl, "dd/mm/yyyy"); when dd_mmm_yy => WriteFmtStr(xl, "dd/mmm/yy"); when dd_mmm => WriteFmtStr(xl, "dd/mmm"); when mmm_yy => WriteFmtStr(xl, "mmm/yy"); when h_mm_AM_PM => WriteFmtStr(xl, "h:mm\ AM/PM"); when h_mm_ss_AM_PM => WriteFmtStr(xl, "h:mm:ss\ AM/PM"); when hh_mm => WriteFmtStr(xl, "hh:mm"); when hh_mm_ss => WriteFmtStr(xl, "hh:mm:ss"); when dd_mm_yyyy_hh_mm => WriteFmtStr(xl, "dd/mm/yyyy\ hh:mm"); when percent_0_plus => WriteFmtStr(xl, "+0%;-0%;0%"); when percent_2_plus => WriteFmtStr(xl, "+0" & sep_deci & "00%;-0" & sep_deci & "00%;0" & sep_deci & "00%"); when date_iso => WriteFmtStr(xl, "yyyy\-mm\-dd"); when date_h_m_iso => WriteFmtStr(xl, "yyyy\-mm\-dd\ hh:mm"); when date_h_m_s_iso => WriteFmtStr(xl, "yyyy\-mm\-dd\ hh:mm:ss"); -- !! Trouble: Excel (German Excel/French locale) writes yyyy, reads it, -- understands it and translates it into aaaa, but is unable to -- understand *our* yyyy -- Same issue as [Red] vs [Rot] above. end case; end loop; -- ^ Some formats in the original list caused problems, probably -- because of regional placeholder symbols case xl.format is when BIFF2 => for i in 1..6 loop WriteFmtStr(xl, "@"); end loop; when BIFF3 => for i in 1..4 loop WriteFmtStr(xl, "@"); end loop; when BIFF4 => null; end case; -- ^ Stuffing for having the same number of built-in and EW custom end WriteFmtRecords; -- 5.35 DIMENSION procedure Write_Dimensions(xl: Excel_Out_Stream'Class) is -- sheet bounds: 0 2 Index to first used row -- 2 2 Index to last used row, increased by 1 -- 4 2 Index to first used column -- 6 2 Index to last used column, increased by 1 -- -- Since our row / column counts are 1-based, no need to increase by 1. sheet_bounds: constant Byte_buffer:= Intel_16(0) & Intel_16(Unsigned_16(xl.maxrow)) & Intel_16(0) & Intel_16(Unsigned_16(xl.maxcolumn)); -- sheet_bounds_32_16: constant Byte_buffer:= -- Intel_32(0) & -- Intel_32(Unsigned_32(xl.maxrow)) & -- Intel_16(0) & -- Intel_16(Unsigned_16(xl.maxcolumn)); begin case xl.format is when BIFF2 => WriteBiff(xl, 16#0000#, sheet_bounds); when BIFF3 | BIFF4 => WriteBiff(xl, 16#0200#, sheet_bounds & (0,0)); -- when BIFF8 => -- WriteBiff(xl, 16#0200#, sheet_bounds_32_16 & (0,0)); end case; end Write_Dimensions; procedure Define_number_format( xl : in out Excel_Out_Stream; format : out Number_format_type; format_string: in String ) is begin xl.number_fmt:= xl.number_fmt + 1; format:= xl.number_fmt; WriteFmtStr(xl, format_string); end Define_number_format; procedure Write_Worksheet_header(xl : in out Excel_Out_Stream'Class) is procedure Define_style(fmt: Format_type; style_id: Unsigned_8) is Base_Level: constant:= 255; begin WriteBiff(xl, 16#0293#, Intel_16(Unsigned_16(fmt) + 16#8000#) & style_id & Base_Level ); end Define_style; -- Comma_Style : constant:= 3; Currency_Style : constant:= 4; Percent_Style : constant:= 5; font_for_styles, font_2, font_3 : Font_type; -- function Encoding_code return Unsigned_16 is -- 5.17 CODEPAGE, p. 145 begin case xl.encoding is when Windows_CP_874 => return 874; when Windows_CP_932 => return 932; when Windows_CP_936 => return 936; when Windows_CP_949 => return 949; when Windows_CP_950 => return 950; when Windows_CP_1250 => return 1250; when Windows_CP_1251 => return 1251; when Windows_CP_1252 => case xl.format is when BIFF2 .. BIFF3 => return 16#8001#; when BIFF4 => return 1252; end case; when Windows_CP_1253 => return 1253; when Windows_CP_1254 => return 1254; when Windows_CP_1255 => return 1255; when Windows_CP_1256 => return 1256; when Windows_CP_1257 => return 1257; when Windows_CP_1258 => return 1258; when Windows_CP_1361 => return 1361; when Apple_Roman => return 10000; end case; end Encoding_code; -- begin Write_BOF(xl); -- 5.17 CODEPAGE, p. 145 case xl.format is -- when BIFF8 => -- UTF-16 -- WriteBiff(xl, 16#0042#, Intel_16(16#04B0#)); when others => WriteBiff(xl, 16#0042#, Intel_16(Encoding_code)); end case; -- 5.14 CALCMODE WriteBiff(xl, 16#000D#, Intel_16(1)); -- 1 => automatic -- 5.85 REFMODE WriteBiff(xl, 16#000F#, Intel_16(1)); -- 1 => A1 mode -- 5.28 DATEMODE WriteBiff(xl, 16#0022#, Intel_16(0)); -- 0 => 1900; 1 => 1904 Date system -- NB: the 1904 variant (Mac) is ignored by LibreOffice (<= 3.5), then wrong dates ! -- Define_font(xl,"Arial", 10, xl.def_font); Define_font(xl,"Arial", 10, font_for_styles); -- Used by BIFF3+'s styles Define_font(xl,"Calibri", 10, font_2); -- Defined in BIFF3 files written by Excel 2002 Define_font(xl,"Calibri", 10, font_3); -- Defined in BIFF3 files written by Excel 2002 WriteFmtRecords(xl); -- 5.111 WINDOWPROTECT WriteBiff(xl, 16#0019#, Intel_16(0)); -- Define default format Define_format(xl, xl.def_font, general, xl.def_fmt); if xl.format >= BIFF3 then -- Don't ask why we need the following useless formats, but it is as Excel 2002 -- write formats. Additionally, the default format is turned into decimal_2 -- when a file without those useless formats is opened in Excel (2002) ! Define_format(xl, font_for_styles, general, xl.def_fmt); Define_format(xl, font_for_styles, general, xl.def_fmt); Define_format(xl, font_2, general, xl.def_fmt); Define_format(xl, font_2, general, xl.def_fmt); for i in 5..15 loop Define_format(xl, xl.def_font, general, xl.def_fmt); end loop; -- Final default format index is the last changed xl.def_fmt end if; Use_default_format(xl); -- Define formats for the BIFF3+ "styles": Define_format(xl, font_for_styles, decimal_2, xl.cma_fmt); Define_format(xl, font_for_styles, currency_0, xl.ccy_fmt); Define_format(xl, font_for_styles, percent_0, xl.pct_fmt); -- Define styles - 5.103 STYLE p. 212 -- NB: - it is BIFF3+ (we cheat a bit if selected format is BIFF2). -- - these "styles" seem to be a zombie feature of Excel 3 -- - the whole purpose of including this is because format -- buttons (%)(,) in Excel 95 through 2007 are using these styles; -- if the styles are not defined, those buttons are not working -- when an Excel Writer sheet is open in MS Excel. Define_style(xl.cma_fmt, Comma_Style); Define_style(xl.ccy_fmt, Currency_Style); Define_style(xl.pct_fmt, Percent_Style); xl.dimrecpos:= Index(xl); Write_Dimensions(xl); xl.is_created:= True; end Write_Worksheet_header; type Font_or_Background is (for_font, for_background); type Color_pair is array(Font_or_Background) of Unsigned_16; auto_color: constant Color_pair:= (16#7FFF#, -- system window text colour 16#0019# -- system window background colour ); color_code: constant array(Excel_type, Color_type) of Color_pair := ( BIFF2 => ( black => (0, 0), white => (1, 1), red => (2, 2), green => (3, 3), blue => (4, 4), yellow => (5, 5), magenta => (6, 6), cyan => (7, 7), others => auto_color ), BIFF3 | BIFF4 => (black => (8, 8), white => (9, 9), red => (10, 10), green => (11, 11), blue => (12, 12), yellow => (13, 13), magenta => (14, 14), cyan => (15, 15), dark_red => (16, 16), dark_green => (17, 17), dark_blue => (18, 18), olive => (19, 19), purple => (20, 20), teal => (21, 21), silver => (22, 22), grey => (23, 23), automatic => auto_color ) ); -- *** Exported procedures ********************************************** -- 5.115 XF - Extended Format procedure Define_format( xl : in out Excel_Out_Stream; font : in Font_type; -- Default_font(xl), or given by Define_font number_format : in Number_format_type; -- built-in, or given by Define_number_format cell_format : out Format_type; -- Optional parameters -- horizontal_align : in Horizontal_alignment:= general_alignment; border : in Cell_border:= no_border; shaded : in Boolean:= False; -- Add a dotted background pattern background_color : in Color_type:= automatic; wrap_text : in Boolean:= False; vertical_align : in Vertical_alignment:= bottom_alignment; text_orient : in Text_orientation:= normal ) is actual_number_format: Number_format_type:= number_format; cell_is_locked: constant:= 1; -- ^ Means actually: cell formula protection is possible, and enabled when sheet is protected. procedure Define_BIFF2_XF is border_bits, mask: Unsigned_8; begin border_bits:= 0; mask:= 8; for s in Cell_border_single loop if border(s) then border_bits:= border_bits + mask; end if; mask:= mask * 2; end loop; -- 5.115.2 XF Record Contents, p. 221 for BIFF3 WriteBiff( xl, 16#0043#, -- XF code in BIFF2 (Unsigned_8(font), -- ^ Index to FONT record 0, -- ^ Not used Number_format_type'Pos(actual_number_format) + 16#40# * cell_is_locked, -- ^ Number format and cell flags Horizontal_alignment'Pos(horizontal_align) + border_bits + Boolean'Pos(shaded) * 128 -- ^ Horizontal alignment, border style, and background ) ); end Define_BIFF2_XF; area_code: Unsigned_16; procedure Define_BIFF3_XF is begin -- 5.115.2 XF Record Contents, p. 221 for BIFF3 WriteBiff( xl, 16#0243#, -- XF code in BIFF3 (Unsigned_8(font), -- ^ 0 - Index to FONT record Number_format_type'Pos(actual_number_format), -- ^ 1 - Number format and cell flags cell_is_locked, -- ^ 2 - XF_TYPE_PROT (5.115.1) 16#FF# -- ^ 3 - XF_USED_ATTRIB ) & Intel_16( Horizontal_alignment'Pos(horizontal_align) + Boolean'Pos(wrap_text) * 8 ) & -- ^ 4 - Horizontal alignment, text break, parent style XF Intel_16(area_code) & -- ^ 6 - XF_AREA_34 ( Boolean'Pos(border(top_single)), Boolean'Pos(border(left_single)), Boolean'Pos(border(bottom_single)), Boolean'Pos(border(right_single)) ) -- ^ 8 - XF_BORDER_34 - thin (=1) line; we could have other line styles: -- Thin, Medium, Dashed, Dotted, Thick, Double, Hair ); end Define_BIFF3_XF; procedure Define_BIFF4_XF is begin -- 5.115.2 XF Record Contents, p. 222 for BIFF4 WriteBiff( xl, 16#0443#, -- XF code in BIFF4 (Unsigned_8(font), -- ^ 0 - Index to FONT record Number_format_type'Pos(actual_number_format), -- ^ 1 - Number format and cell flags cell_is_locked, 0, -- ^ 2 - XF type, cell protection, and parent style XF Horizontal_alignment'Pos(horizontal_align) + Boolean'Pos(wrap_text) * 8 + (Vertical_alignment'Pos(vertical_align) and 3) * 16 + Text_orientation'Pos(text_orient) * 64, -- ^ 4 - Alignment (hor & ver), text break, and text orientation 16#FF# -- ^ 3 - XF_USED_ATTRIB ) & -- ^ 4 - Horizontal alignment, text break, parent style XF Intel_16(area_code) & -- ^ 6 - XF_AREA_34 ( Boolean'Pos(border(top_single)), Boolean'Pos(border(left_single)), Boolean'Pos(border(bottom_single)), Boolean'Pos(border(right_single)) ) -- ^ 8 - XF_BORDER_34 - thin (=1) line; we could have other line styles: -- Thin, Medium, Dashed, Dotted, Thick, Double, Hair ); end Define_BIFF4_XF; begin -- 2.5.12 Patterns for Cell and Chart Background Area -- This is for BIFF3+ if shaded then area_code:= Boolean'Pos(shaded) * 17 + -- Sparse pattern, like BIFF2 "shade" 16#40# * color_code(BIFF3, black)(for_background) + -- pattern colour 16#800# * color_code(BIFF3, background_color)(for_background); -- pattern background elsif background_color = automatic then area_code:= 0; else area_code:= 1 + -- Full pattern 16#40# * color_code(BIFF3, background_color)(for_background) + -- pattern colour 16#800# * color_code(BIFF3, background_color)(for_background); -- pattern background end if; case xl.format is when BIFF2 => case actual_number_format is when general .. no_currency_2 => null; when currency_0 .. fraction_2 => actual_number_format:= actual_number_format - 4; when dd_mm_yyyy .. last_custom => actual_number_format:= actual_number_format - 6; when others => null; end case; Define_BIFF2_XF; when BIFF3 => if actual_number_format in currency_0 .. last_custom then actual_number_format:= actual_number_format - 4; end if; Define_BIFF3_XF; when BIFF4 => Define_BIFF4_XF; -- when BIFF8 => -- Define_BIFF8_XF; -- BIFF8: 16#00E0#, p. 224 end case; xl.xfs:= xl.xfs + 1; cell_format:= Format_type(xl.xfs); xl.xf_def(xl.xfs):= (font => font, numb => number_format); end Define_format; procedure Header(xl : Excel_Out_Stream; page_header_string: String) is begin WriteBiff(xl, 16#0014#, To_buf_8_bit_length(page_header_string)); -- 5.55 p.180 end Header; procedure Footer(xl : Excel_Out_Stream; page_footer_string: String) is begin WriteBiff(xl, 16#0015#, To_buf_8_bit_length(page_footer_string)); -- 5.48 p.173 end Footer; procedure Left_Margin(xl : Excel_Out_Stream; inches: Long_Float) is begin WriteBiff(xl, 16#0026#, IEEE_Double_Intel(inches)); end Left_Margin; procedure Right_Margin(xl : Excel_Out_Stream; inches: Long_Float) is begin WriteBiff(xl, 16#0027#, IEEE_Double_Intel(inches)); end Right_Margin; procedure Top_Margin(xl : Excel_Out_Stream; inches: Long_Float) is begin WriteBiff(xl, 16#0028#, IEEE_Double_Intel(inches)); end Top_Margin; procedure Bottom_Margin(xl : Excel_Out_Stream; inches: Long_Float) is begin WriteBiff(xl, 16#0029#, IEEE_Double_Intel(inches)); end Bottom_Margin; procedure Margins(xl : Excel_Out_Stream; left, right, top, bottom: Long_Float) is begin Left_Margin(xl, left); Right_Margin(xl, right); Top_Margin(xl, top); Bottom_Margin(xl, bottom); end Margins; procedure Print_Row_Column_Headers(xl : Excel_Out_Stream) is begin WriteBiff(xl, 16#002A#, Intel_16(1)); -- 5.81 PRINTHEADERS p.199 end Print_Row_Column_Headers; procedure Print_Gridlines(xl : Excel_Out_Stream) is begin WriteBiff(xl, 16#002B#, Intel_16(1)); -- 5.80 PRINTGRIDLINES p.199 end Print_Gridlines; procedure Page_Setup( xl : Excel_Out_Stream; scaling_percents : Positive:= 100; fit_width_with_n_pages : Natural:= 1; -- 0: as many as possible fit_height_with_n_pages: Natural:= 1; -- 0: as many as possible orientation : Orientation_choice:= portrait; scale_or_fit : Scale_or_fit_choice:= scale ) is begin -- 5.73 PAGESETUP p.192 - this is BIFF4+ (cheat if xl.format below)! WriteBiff(xl, 16#00A1#, Intel_16(0) & -- paper type undefined Intel_16(Unsigned_16(scaling_percents)) & Intel_16(1) & -- start page number Intel_16(Unsigned_16(fit_width_with_n_pages)) & Intel_16(Unsigned_16(fit_height_with_n_pages)) & Intel_16(2 * Orientation_choice'Pos(orientation)) ); -- 5.97 SHEETPR p.207 - this is BIFF3+ (cheat if xl.format below) ! -- NB: this field contains other informations, should be delayed -- in case other preferences are to be set WriteBiff(xl, 16#0081#, Intel_16(256 * Scale_or_fit_choice'Pos(scale_or_fit)) ); end Page_Setup; y_scale: constant:= 20; -- scaling to obtain character point (pt) units -- 5.31 DEFAULTROWHEIGHT procedure Write_default_row_height ( xl : Excel_Out_Stream; height : Positive ) is default_twips: constant Byte_buffer:= Intel_16(Unsigned_16(height * y_scale)); options_flags: constant Byte_buffer:= (1,0); -- 1 = Row height and default font height do not match begin case xl.format is when BIFF2 => WriteBiff(xl, 16#0025#, default_twips); when BIFF3 | BIFF4 => WriteBiff(xl, 16#0225#, options_flags & default_twips); end case; end Write_default_row_height; -- 5.32 DEFCOLWIDTH procedure Write_default_column_width ( xl : in out Excel_Out_Stream; width : Positive) is begin WriteBiff(xl, 16#0055#, Intel_16(Unsigned_16(width))); xl.defcolwdth:= 256 * width; end Write_default_column_width; procedure Write_column_width ( xl : in out Excel_Out_Stream; column : Positive; width : Natural) is begin Write_column_width(xl, column, column, width); end Write_column_width; procedure Write_column_width( xl : in out Excel_Out_Stream; first_column, last_column : Positive; width : Natural ) is begin case xl.format is when BIFF2 => -- 5.20 COLWIDTH (BIFF2 only) WriteBiff(xl, 16#0024#, Unsigned_8(first_column-1) & Unsigned_8(last_column-1) & Intel_16(Unsigned_16(width * 256))); when BIFF3 | BIFF4 => -- 5.18 COLINFO (BIFF3+) WriteBiff(xl, 16#007D#, Intel_16(Unsigned_16(first_column-1)) & Intel_16(Unsigned_16(last_column-1)) & Intel_16(Unsigned_16(width * 256)) & Intel_16(0) & -- Index to XF record (5.115) for default column formatting Intel_16(0) & -- Option flags (0,0) -- Not used ); for j in first_column .. last_column loop xl.std_col_width(j):= False; end loop; end case; end Write_column_width; -- 5.88 ROW -- The OpenOffice documentation tells nice stories about row blocks, -- but single ROW commands can also be put before in the data stream, -- where the column widths are set. Excel saves with blocks of ROW -- commands, most of them useless. procedure Write_row_height( xl : Excel_Out_Stream; row : Positive; height : Natural ) is row_info_base: Byte_buffer:= Intel_16(Unsigned_16(row - 1)) & Intel_16(0) & -- col. min. Intel_16(255) & -- col. max. Intel_16(Unsigned_16(height * y_scale)); fDyZero: Unsigned_8:= 0; begin case xl.format is when BIFF2 => WriteBiff(xl, 16#0008#, row_info_base & (1..3 => 0) & Intel_16(0) -- offset to data ); when BIFF3 | BIFF4 => if height = 0 then -- proper hiding (needed with LibreOffice) fDyZero:= 1; row_info_base(row_info_base'Last - 1 .. row_info_base'Last):= Intel_16(16#8000#); end if; WriteBiff(xl, 16#0208#, row_info_base & -- http://msdn.microsoft.com/en-us/library/dd906757(v=office.12).aspx (0, 0, -- reserved1 (2 bytes): MUST be zero, and MUST be ignored. 0, 0, -- unused1 (2 bytes): Undefined and MUST be ignored. fDyZero * 32 + -- D - fDyZero (1 bit): row is hidden 1 * 64 + -- E - fUnsynced (1 bit): row height was manually set 0 * 128, -- F - fGhostDirty (1 bit): the row was formatted 1) & -- reserved3 (1 byte): MUST be 1, and MUST be ignored Intel_16(15) -- ^ ixfe_val, then 4 bits. -- If fGhostDirty is 0, ixfe_val is undefined and MUST be ignored. ); end case; end Write_row_height; -- 5.45 FONT, p.171 procedure Define_font( xl : in out Excel_Out_Stream; font_name : String; height : Positive; font : out Font_type; style : Font_style:= regular; color : Color_type:= automatic ) is style_bits, mask: Unsigned_16; begin style_bits:= 0; mask:= 1; for s in Font_style_single loop if style(s) then style_bits:= style_bits + mask; end if; mask:= mask * 2; end loop; xl.fonts:= xl.fonts + 1; if xl.fonts = 4 then xl.fonts:= 5; -- Anomaly! The font with index 4 is omitted in all BIFF versions. -- Numbering is 0, 1, 2, 3, *5*, 6,... end if; case xl.format is when BIFF2 => WriteBiff(xl, 16#0031#, Intel_16(Unsigned_16(height * y_scale)) & Intel_16(style_bits) & To_buf_8_bit_length(font_name) ); if color /= automatic then -- 5.47 FONTCOLOR WriteBiff(xl, 16#0045#, Intel_16(color_code(BIFF2, color)(for_font))); end if; when BIFF3 | BIFF4 => -- BIFF8 has 16#0031#, p. 171 WriteBiff(xl, 16#0231#, Intel_16(Unsigned_16(height * y_scale)) & Intel_16(style_bits) & Intel_16(color_code(BIFF3, color)(for_font)) & To_buf_8_bit_length(font_name) ); end case; font:= Font_type(xl.fonts); end Define_font; procedure Jump_to_and_store_max(xl: in out Excel_Out_Stream; r, c: Integer) is pragma Inline(Jump_to_and_store_max); begin if not xl.is_created then raise Excel_stream_not_created; end if; Jump_to(xl, r, c); -- Store and check current position if r > xl.maxrow then xl.maxrow := r; end if; if c > xl.maxcolumn then xl.maxcolumn := c; end if; end Jump_to_and_store_max; -- 2.5.13 Cell Attributes (BIFF2 only) function Cell_attributes(xl: Excel_Out_Stream) return Byte_buffer is begin return (Unsigned_8(xl.xf_in_use), Unsigned_8(xl.xf_def(xl.xf_in_use).numb) + 16#40# * Unsigned_8(xl.xf_def(xl.xf_in_use).font), 0 ); end Cell_attributes; function Almost_zero(x: Long_Float) return Boolean is begin return abs x <= Long_Float'Model_Small; end Almost_zero; -- Internal -- -- 5.71 NUMBER procedure Write_as_double ( xl : in out Excel_Out_Stream; r, c : Positive; num : Long_Float ) is pragma Inline(Write_as_double); begin Jump_to_and_store_max(xl, r, c); case xl.format is when BIFF2 => WriteBiff(xl, 16#0003#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Cell_attributes(xl) & IEEE_Double_Intel(num) ); when BIFF3 | BIFF4 => WriteBiff(xl, 16#0203#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Intel_16(Unsigned_16(xl.xf_in_use)) & IEEE_Double_Intel(num) ); end case; Jump_to(xl, r, c+1); -- Store and check new position end Write_as_double; -- Internal. This is BIFF2 only. BIFF format choice unchecked here. -- procedure Write_as_16_bit_unsigned ( xl : in out Excel_Out_Stream; r, c : Positive; num : Unsigned_16) is pragma Inline(Write_as_16_bit_unsigned); begin Jump_to_and_store_max(xl, r, c); -- 5.60 INTEGER WriteBiff(xl, 16#0002#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Cell_attributes(xl) & Intel_16(num) ); Jump_to(xl, r, c+1); -- Store and check new position end Write_as_16_bit_unsigned; -- Internal. This is BIFF3+. BIFF format choice unchecked here. -- procedure Write_as_30_bit_signed ( xl : in out Excel_Out_Stream; r, c : Positive; num : Integer_32) is pragma Inline(Write_as_30_bit_signed); RK_val: Unsigned_32; RK_code: constant:= 2; -- Code for signed integer. See 2.5.5 RK Values begin if num >= 0 then RK_val:= Unsigned_32(num) * 4 + RK_code; else RK_val:= (-Unsigned_32(-num)) * 4 + RK_code; end if; Jump_to_and_store_max(xl, r, c); -- 5.87 RK WriteBiff(xl, 16#027E#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Intel_16(Unsigned_16(xl.xf_in_use)) & Intel_32(RK_val) ); Jump_to(xl, r, c+1); -- Store and check new position end Write_as_30_bit_signed; -- -- Profile with floating-point number -- procedure Write ( xl : in out Excel_Out_Stream; r, c : Positive; num : Long_Float ) is max_16_u: constant:= 2.0 ** 16 - 1.0; min_30_s: constant:= -(2.0 ** 29); max_30_s: constant:= 2.0 ** 29 - 1.0; begin case xl.format is when BIFF2 => if num >= 0.0 and then num <= max_16_u and then Almost_zero(num - Long_Float'Floor(num)) then Write_as_16_bit_unsigned(xl, r, c, Unsigned_16(Long_Float'Floor(num))); else Write_as_double(xl, r, c, num); end if; when BIFF3 | BIFF4 => if num >= min_30_s and then num <= max_30_s and then Almost_zero(num - Long_Float'Floor(num)) then Write_as_30_bit_signed(xl, r, c, Integer_32(Long_Float'Floor(num))); else Write_as_double(xl, r, c, num); end if; end case; end Write; -- -- Profile with integer number -- procedure Write ( xl : in out Excel_Out_Stream; r, c : Positive; num : Integer) is begin -- We use an integer representation (and small storage) if possible; -- we need to use a floating-point in all other cases case xl.format is when BIFF2 => if num in 0..2**16-1 then Write_as_16_bit_unsigned(xl, r, c, Unsigned_16(num)); else Write_as_double(xl, r, c, Long_Float(num)); end if; when BIFF3 | BIFF4 => if num in -2**29..2**29-1 then Write_as_30_bit_signed(xl, r, c, Integer_32(num)); else Write_as_double(xl, r, c, Long_Float(num)); end if; end case; end Write; -- -- Function taken from Wasabee.Encoding. -- function ISO_8859_1_to_UTF_16(s: String) return Wide_String is -- -- This conversion is a trivial 8-bit to 16-bit copy. -- r: Wide_String(s'Range); -- begin -- for i in s'Range loop -- r(i):= Wide_Character'Val(Character'Pos(s(i))); -- end loop; -- return r; -- end ISO_8859_1_to_UTF_16; -- 5.63 LABEL procedure Write ( xl : in out Excel_Out_Stream; r, c : Positive; str : String) is begin Jump_to_and_store_max(xl, r, c); if str'Length > 0 then case xl.format is when BIFF2 => WriteBiff(xl, 16#0004#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Cell_attributes(xl) & To_buf_8_bit_length(str) ); when BIFF3 | BIFF4 => WriteBiff(xl, 16#0204#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Intel_16(Unsigned_16(xl.xf_in_use)) & To_buf_16_bit_length(str) ); -- when BIFF8 => -- WriteBiff(xl, 16#0204#, -- Intel_16(Unsigned_16(r-1)) & -- Intel_16(Unsigned_16(c-1)) & -- Intel_16(Unsigned_16(xl.xf_in_use)) & -- To_buf_16_bit_length(ISO_8859_1_to_UTF_16(str)) -- ); end case; end if; Jump_to(xl, r, c+1); -- Store and check new position end Write; procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; str : Unbounded_String) is begin Write(xl, r,c, To_String(str)); end Write; -- Excel uses a floating-point type for time - ouch! -- function To_Number(date: Time) return Long_Float is -- 1901 is the lowest year supported by Ada.Calendar. -- 1900 is not a leap year, but Lotus 1-2-3, then Excel, consider it -- as a leap year. So, with 1901, we skip that issue anyway... -- function Days_since_1901 (y, m, d : Integer) return Integer is function Is_leap (y: Integer) return Boolean is begin if y mod 4 = 0 then if y mod 100 = 0 then if y mod 400 = 0 then return True; else return False; end if; else return True; end if; else return False; end if; end Is_leap; days_of_previous_months : Integer; days_of_previous_years : Integer; y_diff, y_diff_4, y_diff_100, y_diff_400 : Integer; begin case m is when 02 => days_of_previous_months := 31; when 03 => days_of_previous_months := 59; when 04 => days_of_previous_months := 90; when 05 => days_of_previous_months := 120; when 06 => days_of_previous_months := 151; when 07 => days_of_previous_months := 181; when 08 => days_of_previous_months := 212; when 09 => days_of_previous_months := 243; when 10 => days_of_previous_months := 273; when 11 => days_of_previous_months := 304; when 12 => days_of_previous_months := 334; when others => days_of_previous_months := 0; end case; if m > 2 and then Is_leap (y) then -- February has 29 days in leap years. days_of_previous_months := days_of_previous_months + 1; end if; -- y_diff := (y - 1) - 1900; y_diff_4 := (y - 1) / 4 - 1900 / 4; y_diff_100 := (y - 1) / 100 - 1900 / 100; y_diff_400 := (y - 1) / 400 - 1900 / 400; -- Add extra days of leap years from 1901 (included) to year y (excluded). days_of_previous_years := 365 * y_diff + y_diff_4 - y_diff_100 + y_diff_400; -- return days_of_previous_years + days_of_previous_months + d - 1; end Days_since_1901; -- sec : constant Day_Duration := Seconds (date); begin -- With GNAT and perhaps other systems, Duration's range allows the following: -- return Long_Float(date - Time_Of(1901, 01, 01, 0.0)) / 86_400.0 + 367.0; -- With ObjectAda and perhaps other systems, we need to count days since 1900 ourselves. return Long_Float (sec) / 86_400.0 + Long_Float (Days_since_1901 (Year (date), Month (date), Day (date))) + 367.0; -- Days from 1899-12-31 to 1901-01-01. -- Lotus 1-2-3, then Excel, are based on 1899-12-31 (and believe it is 1900-01-01). end To_Number; procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; date: Time) is begin Write(xl, r,c, To_Number(date)); end Write; -- Ada.Text_IO - like. No need to specify row & column each time procedure Put(xl: in out Excel_Out_Stream; num : Long_Float) is begin Write(xl, xl.curr_row, xl.curr_col, num); end Put; procedure Put(xl : in out Excel_Out_Stream; num : in Integer; width : in Ada.Text_IO.Field := 0; -- ignored base : in Ada.Text_IO.Number_Base := 10 ) is begin if base = 10 then Write(xl, xl.curr_row, xl.curr_col, num); else declare use Ada.Strings.Fixed; s: String(1..50 + 0*width); -- 0*width is just to skip a warning of width being unused package IIO is new Ada.Text_IO.Integer_IO(Integer); begin IIO.Put(s, num, Base => base); Put(xl, Trim(s, Ada.Strings.Left)); end; end if; end Put; procedure Put(xl: in out Excel_Out_Stream; str : String) is begin Write(xl, xl.curr_row, xl.curr_col, str); end Put; procedure Put(xl: in out Excel_Out_Stream; str : Unbounded_String) is begin Put(xl, To_String(str)); end Put; procedure Put(xl: in out Excel_Out_Stream; date: Time) is begin Put(xl, To_Number(date)); end Put; procedure Merge(xl: in out Excel_Out_Stream; cells : Positive) is -- 5.7 BLANK procedure Blank (r, c: Positive) is begin Jump_to_and_store_max(xl, r, c); case xl.format is -- NB: Only with BIFF4, and only OpenOffice -- considers the cells really merged. when BIFF2 => WriteBiff(xl, 16#0001#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Cell_attributes(xl) ); when BIFF3 | BIFF4 => WriteBiff(xl, 16#0201#, Intel_16(Unsigned_16(r-1)) & Intel_16(Unsigned_16(c-1)) & Intel_16(Unsigned_16(xl.xf_in_use)) ); end case; Jump_to(xl, r, c+1); -- Store and check new position end Blank; begin for i in 1..cells loop Blank(xl.curr_row, xl.curr_col); end loop; end Merge; procedure Write_cell_comment(xl: Excel_Out_Stream; row, column: Positive; text: String) is begin if text'Length >= 2048 then raise Constraint_Error; end if; -- 5.70 Note case xl.format is -- when BIFF8 => -- https://msdn.microsoft.com/en-us/library/dd945371(v=office.12).aspx -- WriteBiff(xl, 16#001C#, -- Intel_16(Unsigned_16(row-1)) & -- Intel_16(Unsigned_16(column-1)) & -- (0, 0) & -- Show / hide options -- (0, 0) -- idObj - it begins to be tough there... -- ); when others => WriteBiff(xl, 16#001C#, Intel_16(Unsigned_16(row-1)) & Intel_16(Unsigned_16(column-1)) & To_buf_16_bit_length(text) ); end case; end Write_cell_comment; procedure Write_cell_comment_at_cursor(xl: Excel_Out_Stream; text: String) is begin Write_cell_comment(xl, Row(xl), Column(xl), text); end Write_cell_comment_at_cursor; procedure Put_Line(xl: in out Excel_Out_Stream; num : Long_Float) is begin Put(xl, num); New_Line(xl); end Put_Line; procedure Put_Line(xl: in out Excel_Out_Stream; num : Integer) is begin Put(xl, num); New_Line(xl); end Put_Line; procedure Put_Line(xl: in out Excel_Out_Stream; str : String) is begin Put(xl, str); New_Line(xl); end Put_Line; procedure Put_Line(xl: in out Excel_Out_Stream; str : Unbounded_String) is begin Put_Line(xl, To_String(str)); end Put_Line; procedure Put_Line(xl: in out Excel_Out_Stream; date: Time) is begin Put(xl, date); New_Line(xl); end Put_Line; procedure New_Line(xl: in out Excel_Out_Stream; Spacing : Positive := 1) is begin Jump_to(xl, xl.curr_row + Spacing, 1); end New_Line; function Col(xl: in Excel_Out_Stream) return Positive is begin return xl.curr_col; end Col; function Column(xl: in Excel_Out_Stream) return Positive renames Col; function Line(xl: in Excel_Out_Stream) return Positive is begin return xl.curr_row; end Line; function Row(xl: in Excel_Out_Stream) return Positive renames Line; -- Relative / absolute jumps procedure Jump(xl: in out Excel_Out_Stream; rows, columns: Natural) is begin Jump_to(xl, xl.curr_row + rows, xl.curr_col + columns); end Jump; procedure Jump_to(xl: in out Excel_Out_Stream; row, column: Positive) is begin if row < xl.curr_row then -- trying to overwrite cells ?... raise Decreasing_row_index; end if; if row = xl.curr_row and then column < xl.curr_col then -- trying to overwrite cells on same row ?... raise Decreasing_column_index; end if; if row > 65536 then raise Row_out_of_range; elsif column > 256 then raise Column_out_of_range; end if; xl.curr_row:= row; xl.curr_col:= column; end Jump_to; procedure Next (xl: in out Excel_Out_Stream; columns: Natural:= 1) is begin Jump(xl, rows => 0, columns => columns); end Next; procedure Next_Row (xl: in out Excel_Out_Stream; rows: Natural:= 1) is begin Jump(xl, rows => rows, columns => 0); end Next_Row; procedure Use_format( xl : in out Excel_Out_Stream; format : in Format_type ) is begin xl.xf_in_use:= XF_Range(format); end Use_format; procedure Use_default_format(xl: in out Excel_Out_Stream) is begin Use_format(xl, xl.def_fmt); end Use_default_format; function Default_font(xl: Excel_Out_Stream) return Font_type is begin return xl.def_font; end Default_font; function Default_format(xl: Excel_Out_Stream) return Format_type is begin return xl.def_fmt; end Default_format; procedure Freeze_Panes(xl: in out Excel_Out_Stream; row, column: Positive) is begin xl.frz_panes:= True; xl.freeze_row:= row; xl.freeze_col:= column; end Freeze_Panes; procedure Freeze_Panes_at_cursor(xl: in out Excel_Out_Stream) is begin Freeze_Panes(xl, xl.curr_row, xl.curr_col); end Freeze_Panes_at_cursor; procedure Freeze_Top_Row(xl: in out Excel_Out_Stream) is begin Freeze_Panes(xl, 2, 1); end Freeze_Top_Row; procedure Freeze_First_Column(xl: in out Excel_Out_Stream) is begin Freeze_Panes(xl, 1, 2); end Freeze_First_Column; procedure Zoom_level(xl: in out Excel_Out_Stream; numerator, denominator: Positive) is begin xl.zoom_num:= numerator; xl.zoom_den:= denominator; end Zoom_level; procedure Reset( xl : in out Excel_Out_Stream'Class; excel_format : Excel_type; encoding : Encoding_type ) is dummy_xl_with_defaults: Excel_Out_Pre_Root_Type; begin -- Check if we are trying to re-use a half-finished object (ouch!): if xl.is_created and not xl.is_closed then raise Excel_stream_not_closed; end if; -- We will reset everything with defaults, except this: dummy_xl_with_defaults.format := excel_format; dummy_xl_with_defaults.encoding := encoding; -- Now we reset xl: Excel_Out_Pre_Root_Type(xl):= dummy_xl_with_defaults; end Reset; procedure Finish(xl : in out Excel_Out_Stream'Class) is procedure Write_Window1 is begin -- 5.109 WINDOW1, p. 215 case xl.format is when BIFF2 | BIFF3 | BIFF4 => -- NB: more options in BIFF8 WriteBiff(xl, 16#003D#, Intel_16(120) & -- Window x Intel_16(120) & -- Window y Intel_16(21900) & -- Window w Intel_16(13425) & -- Window h Intel_16(0) -- Hidden ); end case; end Write_Window1; procedure Write_Window2 is begin -- 5.110 WINDOW2 case xl.format is when BIFF2 => WriteBiff(xl, 16#003E#, (0, -- Display formulas, not results 1, -- Show grid lines 1, -- Show sheet headers Boolean'Pos(xl.frz_panes), 1 -- Show zero values as zeros, not empty cells ) & Intel_16(0) & -- First visible row Intel_16(0) & -- First visible column (1, -- Use automatic grid line colour 0,0,0,0) -- Grid line RGB colour ); when BIFF3 | BIFF4 => -- NB: more options in BIFF8 WriteBiff(xl, 16#023E#, -- http://msdn.microsoft.com/en-us/library/dd947893(v=office.12).aspx Intel_16( -- Option flags: 0 * 1 + -- Display formulas, not results 1 * 2 + -- Show grid lines 1 * 4 + -- Show sheet headers Boolean'Pos(xl.frz_panes) * 8 + -- Panes are frozen 1 * 16 + -- Show zero values as zeros, not empty cells 1 * 32 + -- Gridlines of the window drawn in the default window foreground color 0 * 64 + -- Right-to-left mode 1 * 128 + -- Show outlines (guts ?!) 0 * 256 -- Frozen, not split ) & Intel_16(0) & -- First visible row Intel_16(0) & -- First visible column Intel_32(0) -- Grid line colour ); end case; end Write_Window2; procedure Write_Pane is active_pane: Unsigned_8; begin if xl.freeze_col = 1 then if xl.freeze_row = 1 then active_pane:= 3; else active_pane:= 2; end if; else if xl.freeze_row = 1 then active_pane:= 1; else active_pane:= 0; end if; end if; -- 5.75 PANE WriteBiff(xl, 16#0041#, Intel_16(Unsigned_16(xl.freeze_col) - 1) & Intel_16(Unsigned_16(xl.freeze_row) - 1) & Intel_16(Unsigned_16(xl.freeze_row) - 1) & Intel_16(Unsigned_16(xl.freeze_col) - 1) & ( 1 => active_pane ) ); end Write_Pane; col_bits: Byte_buffer(1..32):= (others => 0); byte_idx, bit_idx: Positive:= 1; begin -- Calling Window1 and Window2 is not necessary for default settings, but without these calls, -- a Write_row_height call with a positive height results, on all MS Excel versions, in a -- completely blank row, including the header letters - clearly an Excel bug ! Write_Window1; Write_Window2; -- 5.92 SCL = Zoom, Magnification. Defined for BIFF4+ only, but works with BIFF2, BIFF3. WriteBiff(xl, 16#00A0#, Intel_16(Unsigned_16(xl.zoom_num)) & Intel_16(Unsigned_16(xl.zoom_den)) ); if xl.frz_panes and xl.format > BIFF2 then -- Enabling PANE for BIFF2 causes a very strange behaviour on MS Excel 2002. Write_Pane; end if; -- 5.93 SELECTION here !! if xl.format >= BIFF4 then for i in 1..256 loop col_bits(byte_idx):= col_bits(byte_idx) + Boolean'Pos(xl.std_col_width(i)) * (2**(bit_idx-1)); bit_idx:= bit_idx + 1; if bit_idx = 9 then bit_idx:= 1; byte_idx:= byte_idx + 1; end if; end loop; -- 5.51 GCW: Global Column Width - trying to get a correct display by LibreOffice -- Result: OK but useless on MS Excel, not working on LibreOffice :-( WriteBiff(xl, 16#00AB#, Intel_16(32) & col_bits); -- if xl.defcolwdth > 0 then -- -- 5.101 STANDARDWIDTH -- this confuses MS Excel... -- WriteBiff(xl, 16#0099#, Intel_16(Unsigned_16(xl.defcolwdth))); -- end if; end if; -- 5.37 EOF: End of File: WriteBiff(xl, 16#000A#, empty_buffer); Set_Index(xl, xl.dimrecpos); -- Go back to overwrite the DIMENSION record with correct data Write_Dimensions(xl); xl.is_closed:= True; end Finish; ---------------------- -- Output to a file -- ---------------------- procedure Create( xl : in out Excel_Out_File; file_name : String; excel_format : Excel_type := Default_Excel_type; encoding : Encoding_type := Default_encoding ) is begin Reset(xl, excel_format, encoding); xl.xl_file:= new Ada.Streams.Stream_IO.File_Type; Create(xl.xl_file.all, Out_File, file_name); xl.xl_stream:= XL_Raw_Stream_Class(Stream(xl.xl_file.all)); Write_Worksheet_header(xl); end Create; procedure Close(xl : in out Excel_Out_File) is procedure Dispose is new Ada.Unchecked_Deallocation(Ada.Streams.Stream_IO.File_Type, XL_file_acc); begin Finish(xl); Close(xl.xl_file.all); Dispose(xl.xl_file); end Close; -- Set the index on the file procedure Set_Index (xl: in out Excel_Out_File; To: Ada.Streams.Stream_IO.Positive_Count) is begin Ada.Streams.Stream_IO.Set_Index(xl.xl_file.all, To); end Set_Index; -- Return the index of the file function Index (xl: Excel_Out_File) return Ada.Streams.Stream_IO.Count is begin return Ada.Streams.Stream_IO.Index(xl.xl_file.all); end Index; function Is_Open(xl : in Excel_Out_File) return Boolean is begin if xl.xl_file = null then return False; end if; return Ada.Streams.Stream_IO.Is_Open(xl.xl_file.all); end Is_Open; ------------------------ -- Output to a string -- ------------------------ -- Code reused from Zip_Streams procedure Read (Stream : in out Unbounded_Stream; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin -- Item is read from the stream. If (and only if) the stream is -- exhausted, Last will be < Item'Last. In that case, T'Read will -- raise an End_Error exception. -- -- Cf: RM 13.13.1(8), RM 13.13.1(11), RM 13.13.2(37) and -- explanations by Tucker Taft -- Last:= Item'First - 1; -- if Item is empty, the following loop is skipped; if Stream.Loc -- is already indexing out of Stream.Unb, that value is also appropriate for i in Item'Range loop Item(i) := Character'Pos (Element(Stream.Unb, Stream.Loc)); Stream.Loc := Stream.Loc + 1; Last := i; end loop; exception when Ada.Strings.Index_Error => null; -- what could be read has been read; T'Read will raise End_Error end Read; procedure Write (Stream : in out Unbounded_Stream; Item : Stream_Element_Array) is begin for I in Item'Range loop if Length(Stream.Unb) < Stream.Loc then Append(Stream.Unb, Character'Val(Item(I))); else Replace_Element(Stream.Unb, Stream.Loc, Character'Val(Item(I))); end if; Stream.Loc := Stream.Loc + 1; end loop; end Write; procedure Set_Index (S : access Unbounded_Stream; To : Positive) is begin if Length(S.Unb) < To then for I in Length(S.Unb) .. To loop Append(S.Unb, ASCII.NUL); end loop; end if; S.Loc := To; end Set_Index; function Index (S : access Unbounded_Stream) return Integer is begin return S.Loc; end Index; --- *** procedure Create( xl : in out Excel_Out_String; excel_format : Excel_type := Default_Excel_type; encoding : Encoding_type := Default_encoding ) is begin Reset(xl, excel_format, encoding); xl.xl_memory:= new Unbounded_Stream; xl.xl_memory.Unb:= Null_Unbounded_String; xl.xl_memory.Loc:= 1; xl.xl_stream:= XL_Raw_Stream_Class(xl.xl_memory); Write_Worksheet_header(xl); end Create; procedure Close(xl : in out Excel_Out_String) is begin Finish(xl); end Close; function Contents(xl: Excel_Out_String) return String is begin if not xl.is_closed then raise Excel_stream_not_closed; end if; return To_String(xl.xl_memory.Unb); end Contents; -- Set the index on the Excel string stream procedure Set_Index (xl: in out Excel_Out_String; To: Ada.Streams.Stream_IO.Positive_Count) is begin Set_Index(xl.xl_memory, Integer(To)); end Set_Index; -- Return the index of the Excel string stream function Index (xl: Excel_Out_String) return Ada.Streams.Stream_IO.Count is begin return Ada.Streams.Stream_IO.Count(Index(xl.xl_memory)); end Index; function "&"(a,b: Font_style) return Font_style is begin return a or b; -- "or" is predefined for sets (=array of Boolean) end "&"; function "&"(a,b: Cell_border) return Cell_border is begin return a or b; -- "or" is predefined for sets (=array of Boolean) end "&"; end Excel_Out;
zhmu/ananas
Ada
4,548
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ U N B O U N D E D . A U X -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This child package of Ada.Strings.Wide_Unbounded provides some specialized -- access functions which are intended to allow more efficient use of the -- facilities of Ada.Strings.Wide_Unbounded, particularly by other layered -- utilities. package Ada.Strings.Wide_Unbounded.Aux is pragma Preelaborate; subtype Big_Wide_String is Wide_String (Positive'Range); type Big_Wide_String_Access is access all Big_Wide_String; procedure Get_Wide_String (U : Unbounded_Wide_String; S : out Big_Wide_String_Access; L : out Natural); pragma Inline (Get_Wide_String); -- This procedure returns the internal string pointer used in the -- representation of an unbounded string as well as the actual current -- length (which may be less than S.all'Length because in general there -- can be extra space assigned). The characters of this string may be -- not be modified via the returned pointer, and are valid only as -- long as the original unbounded string is not accessed or modified. -- -- This procedure is much more efficient than the use of To_Wide_String -- since it avoids the need to copy the string. The lower bound of the -- referenced string returned by this call is always one, so the actual -- string data is always accessible as S (1 .. L). procedure Set_Wide_String (UP : out Unbounded_Wide_String; S : Wide_String) renames Set_Unbounded_Wide_String; -- This function sets the string contents of the referenced unbounded -- string to the given string value. It is significantly more efficient -- than the use of To_Unbounded_Wide_String with an assignment, since it -- avoids the necessity of messing with finalization chains. The lower -- bound of the string S is not required to be one. procedure Set_Wide_String (UP : in out Unbounded_Wide_String; S : Wide_String_Access); pragma Inline (Set_Wide_String); -- This version of Set_Wide_String takes a string access value, rather -- than string. The lower bound of the string value is required to be one, -- and this requirement is not checked. end Ada.Strings.Wide_Unbounded.Aux;
reznikmm/matreshka
Ada
3,657
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UMLDI.UML_State_Machine_Diagrams.Hash is new AMF.Elements.Generic_Hash (UMLDI_UML_State_Machine_Diagram, UMLDI_UML_State_Machine_Diagram_Access);
zhmu/ananas
Ada
9,072
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 1 1 6 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_116 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_116; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; -- The following declarations are for the case where the address -- passed to GetU_116 or SetU_116 is not guaranteed to be aligned. -- These routines are used when the packed array is itself a -- component of a packed record, and therefore may not be aligned. type ClusterU is new Cluster; for ClusterU'Alignment use 1; type ClusterU_Ref is access ClusterU; type Rev_ClusterU is new ClusterU with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_ClusterU_Ref is access Rev_ClusterU; ------------ -- Get_116 -- ------------ function Get_116 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_116 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_116; ------------- -- GetU_116 -- ------------- function GetU_116 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_116 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end GetU_116; ------------ -- Set_116 -- ------------ procedure Set_116 (Arr : System.Address; N : Natural; E : Bits_116; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_116; ------------- -- SetU_116 -- ------------- procedure SetU_116 (Arr : System.Address; N : Natural; E : Bits_116; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end SetU_116; end System.Pack_116;
reznikmm/matreshka
Ada
4,075
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Containers.Vectors; with OPM.Generic_References; with Forum.Topics.Objects.Stores; package Forum.Topics.References is -- pragma Preelaborate; package Topic_References is new OPM.Generic_References (Topic_Identifier, Forum.Topics.Objects.Topic_Object, Forum.Topics.Objects.Stores.Topic_Access, Forum.Topics.Objects.Stores.Topic_Store, Forum.Topics.Objects.Stores.Get, Forum.Topics.Objects.Stores.Release); type Topic is new Topic_References.Reference with null record; package Topic_Vectors is new Ada.Containers.Vectors (Positive, Topic); type Topic_Vector is new Topic_Vectors.Vector with null record; end Forum.Topics.References;
onox/opus-ada
Ada
6,108
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2014 - 2022 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Opus.Decoders is subtype Opus_Decoder is Opus.API.Opus_Decoder; use all type Opus.API.Get_Request_Type_Decoder; use all type Opus.API.Set_Request_Type_Decoder; generic Request : Opus.API.Get_Request_Type_Decoder; type Return_Type is (<>); function Get_Request (Decoder : Decoder_Data) return Return_Type; function Get_Request (Decoder : Decoder_Data) return Return_Type is Result : Return_Type; function Opus_Decoder_Ctl (State : Opus_Decoder; Request : Opus.API.Get_Request_Type_Decoder; Result : out Return_Type) return Interfaces.C.int with Import, Convention => C, External_Name => "opus_decoder_ctl"; Error : constant Interfaces.C.int := Opus_Decoder_Ctl (Decoder.Decoder, Request, Result); begin Check_Error (Error); if not Result'Valid then raise Invalid_Result; end if; return Result; end Get_Request; generic Request : Opus.API.Set_Request_Type_Decoder; type Argument_Type is (<>); procedure Set_Request (Decoder : Decoder_Data; Argument : Argument_Type); procedure Set_Request (Decoder : Decoder_Data; Argument : Argument_Type) is function Opus_Decoder_Ctl (State : Opus_Decoder; Request : Opus.API.Set_Request_Type_Decoder; Argument : Argument_Type) return Interfaces.C.int with Import, Convention => C, External_Name => "opus_decoder_ctl"; Error : constant Interfaces.C.int := Opus_Decoder_Ctl (Decoder.Decoder, Request, Argument); begin Check_Error (Error); end Set_Request; ---------------------------------------------------------------------------- function Create (Frequency : Sampling_Rate; Channels : Channel_Type) return Decoder_Data is Error : Interfaces.C.int; Decoder : Decoder_Data; begin Decoder.Decoder := Opus.API.Decoder_Create (Frequency, Channels, Error); Decoder.Channels := Channels; Check_Error (Error); return Decoder; end Create; procedure Destroy (Decoder : Decoder_Data) is begin Opus.API.Decoder_Destroy (Decoder.Decoder); end Destroy; function Decode (Decoder : Decoder_Data; Data : Byte_Array; Max_Samples_Per_Channel : Positive; Decode_FEC : Boolean) return PCM_Buffer is Length_Audio : Interfaces.C.int; Channels : constant Integer := (if Get_Channels (Decoder) = Mono then 1 else 2); Result : PCM_Buffer (0 .. Max_Samples_Per_Channel * Channels); begin -- TODO if Data = null or Decode_Fec then assert Max_Samples = multiple of 2.5 ms Length_Audio := Opus.API.Decode (Decoder.Decoder, Data, Data'Length, Result, Max_Samples_Per_Channel, (if Decode_FEC then 1 else 0)); Check_Error (Length_Audio); return Result (0 .. Integer (Length_Audio) * Channels); -- TODO Assuming docs mean samples per channel end Decode; procedure Reset_State (Decoder : Decoder_Data) is function Opus_Decoder_Ctl (State : Opus_Decoder; Request : Interfaces.C.int) return Interfaces.C.int with Import, Convention => C, External_Name => "opus_decoder_ctl"; Reset_State_Request : constant := 4028; Error : constant Interfaces.C.int := Opus_Decoder_Ctl (Decoder.Decoder, Reset_State_Request); begin Check_Error (Error); end Reset_State; ---------------------------------------------------------------------------- package Internal is function Get_Bandwidth is new Get_Request (Get_Bandwidth_Request, Bandwidth); function Get_Gain is new Get_Request (Get_Gain_Request, Q8_dB); function Get_Pitch is new Get_Request (Get_Pitch_Request, Interfaces.C.int); function Get_Sample_Rate is new Get_Request (Get_Final_Range_Request, Interfaces.C.int); function Get_Sample_Rate is new Get_Request (Get_Sample_Rate_Request, Sampling_Rate); function Get_Last_Packet_Duration is new Get_Request (Get_Last_Packet_Duration_Request, Interfaces.C.int); procedure Set_Gain is new Set_Request (Set_Gain_Request, Q8_dB); end Internal; ---------------------------------------------------------------------------- function Get_Bandwidth (Decoder : Decoder_Data) return Bandwidth is begin return Internal.Get_Bandwidth (Decoder); exception when Invalid_Result => raise No_Packets_Decoded; end Get_Bandwidth; function Get_Channels (Decoder : Decoder_Data) return Channel_Type is (Decoder.Channels); procedure Set_Gain (Decoder : Decoder_Data; Factor : Q8_dB) renames Internal.Set_Gain; function Get_Gain (Decoder : Decoder_Data) return Q8_dB renames Internal.Get_Gain; function Get_Pitch (Decoder : Decoder_Data) return Integer is begin return Integer (Internal.Get_Pitch (Decoder)); end Get_Pitch; function Get_Final_Range (Decoder : Decoder_Data) return Integer is begin return Integer (Interfaces.C.int'(Internal.Get_Sample_Rate (Decoder))); end Get_Final_Range; function Get_Sample_Rate (Decoder : Decoder_Data) return Sampling_Rate renames Internal.Get_Sample_Rate; function Get_Last_Packet_Duration (Decoder : Decoder_Data) return Natural is begin return Natural (Internal.Get_Last_Packet_Duration (Decoder)); end Get_Last_Packet_Duration; end Opus.Decoders;
OhYea777/Minix
Ada
5,994
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.adb,v 1.1 2005/09/23 22:39:01 beng Exp $ with Ada.Unchecked_Deallocation; package body ZLib.Streams is ----------- -- Close -- ----------- procedure Close (Stream : in out Stream_Type) is procedure Free is new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access); begin if Stream.Mode = Out_Stream or Stream.Mode = Duplex then -- We should flush the data written by the writer. Flush (Stream, Finish); Close (Stream.Writer); end if; if Stream.Mode = In_Stream or Stream.Mode = Duplex then Close (Stream.Reader); Free (Stream.Buffer); end if; end Close; ------------ -- Create -- ------------ procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size) is subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean); ----------------- -- Init_Filter -- ----------------- procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean) is begin if Compress then Deflate_Init (Filter, Level, Strategy, Header => Header); else Inflate_Init (Filter, Header => Header); end if; end Init_Filter; begin Stream.Back := Back; Stream.Mode := Mode; if Mode = Out_Stream or Mode = Duplex then Init_Filter (Stream.Writer, Back_Compressed); Stream.Buffer_Size := Write_Buffer_Size; else Stream.Buffer_Size := 0; end if; if Mode = In_Stream or Mode = Duplex then Init_Filter (Stream.Reader, not Back_Compressed); Stream.Buffer := new Buffer_Subtype; Stream.Rest_First := Stream.Buffer'Last + 1; Stream.Rest_Last := Stream.Buffer'Last; end if; end Create; ----------- -- Flush -- ----------- procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush) is Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); Last : Stream_Element_Offset; begin loop Flush (Stream.Writer, Buffer, Last, Mode); Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Flush; ------------- -- Is_Open -- ------------- function Is_Open (Stream : Stream_Type) return Boolean is begin return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); end Is_Open; ---------- -- Read -- ---------- procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Ada.Streams.Read (Stream.Back.all, Item, Last); end Read; procedure Read is new ZLib.Read (Read => Read, Buffer => Stream.Buffer.all, Rest_First => Stream.Rest_First, Rest_Last => Stream.Rest_Last); begin Read (Stream.Reader, Item, Last); end Read; ------------------- -- Read_Total_In -- ------------------- function Read_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Reader); end Read_Total_In; -------------------- -- Read_Total_Out -- -------------------- function Read_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Reader); end Read_Total_Out; ----------- -- Write -- ----------- procedure Write (Stream : in out Stream_Type; Item : in Stream_Element_Array) is procedure Write (Item : in Stream_Element_Array); ----------- -- Write -- ----------- procedure Write (Item : in Stream_Element_Array) is begin Ada.Streams.Write (Stream.Back.all, Item); end Write; procedure Write is new ZLib.Write (Write => Write, Buffer_Size => Stream.Buffer_Size); begin Write (Stream.Writer, Item, No_Flush); end Write; -------------------- -- Write_Total_In -- -------------------- function Write_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Writer); end Write_Total_In; --------------------- -- Write_Total_Out -- --------------------- function Write_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Writer); end Write_Total_Out; end ZLib.Streams;
Ximalas/synth
Ada
7,694
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt private with Replicant.Platform; package PortScan.Packages is -- This routine first removes all invalid packages (package from removed -- port or older version) and inserts the origins of the remaining packages -- into the port list for a limited tree scan. procedure preclean_repository (repository : String); -- If performing a limited build run (likely 99% of the use cases), only -- the queued packages will be checked. The checks are limited to finding -- options changes and dependency changes. Obsolete packages (related or -- unrelated to upcoming build) are not removed; this would occur in -- clean_repository(). These old packages will not interfere at this step. procedure limited_sanity_check (repository : String; dry_run : Boolean; suppress_remote : Boolean); -- Iterate through the final build queue to remove any packages that -- match the current package names (currently unused) procedure remove_queue_packages (repository : String); -- This procedure empties the given repository without discrimination. -- (Well, it's limited to "*.txz" matches, but normally that's everything) -- (currently unused) procedure wipe_out_repository (repository : String); -- Sometimes, especially with the single ports-mgmt/pkg check, there is -- nothing left to do after the sanity check. Let's provide a way to -- detect that case. function queue_is_empty return Boolean; -- Returns the size of the queue before it was pared down. function original_queue_size return Natural; -- After the initial queue is created, and before the limited sanity -- check, we go through each port and check if it has cached options. -- If it does, then it's checked for validity. If it has too many or -- too few options, or an option's name doesn't match, the port is -- printed to stdout. The rest of the ports are checked, but at that -- point the function has failed. function limited_cached_options_check return Boolean; -- Returns True on success; stores value in global external_repository function located_external_repository return Boolean; -- Returns the value of the stored external repository function top_external_repository return String; -- Given the full path of a package, query it for the port origin function query_origin (fullpath : String) return String; -- Given the full path of a package plus its port origin, return origin(@flavor) function query_full_origin (fullpath, origin : String) return String; -- Given the full path of a package, query it for the package base name function query_pkgbase (fullpath : String) return String; private type dim_packages is array (scanners) of string_crate.Vector; stored_packages : dim_packages; stored_origins : dim_packages; pkgscan_progress : dim_progress := (others => 0); pkgscan_total : Natural := 0; abi_formats : Replicant.package_abi; external_repository : JT.Text; original_queue_len : AC.Count_Type; obsolete_pkg_log : TIO.File_Type; obsolete_log_open : Boolean := False; -- Debugging purposes only, can be turned on by environment variable debug_dep_check : Boolean := False; debug_opt_check : Boolean := False; -- This function returns "True" if the scanned options exactly match -- the options in the already-built package. Usually it's already known -- that a package exists before the function is called, but an existence -- check will be performed just in case (failure returns "False") function passed_option_check (repository : String; id : port_id; skip_exist_check : Boolean := False) return Boolean; -- This function returns "True" if the scanned dependencies match exactly -- what the current ports tree has. function passed_dependency_check (query_result : JT.Text; id : port_id) return Boolean; -- This function returns "True" if the scanned package has the expected -- package ABI, e.g. dragonfly:4.6:x86:64, freebsd:10:amd64 function passed_abi_check (repository : String; id : port_id; skip_exist_check : Boolean := False) return Boolean; -- This calculates the ABI for the platform and stores it. The value is -- used by passed_abi_check() procedure establish_package_architecture; -- Scan directory that contains the packages (*.txz) and stores the -- file names in the container. Returns False if no packages are found. function scan_repository (repository : String) return Boolean; -- standard method to spawn commands in this package (and get output) function generic_system_command (command : String) return JT.Text; -- Evaluates the stored options. If none exists, return True -- If Exists and all the options match exactly what has already been -- scanned for the port (names, not values) then return True else False. function passed_options_cache_check (id : port_id) return Boolean; -- For each package in the query, check the ABI and options (this is the -- only time they are checked). If those pass, query the dependencies, -- store the result, and check them. Set the "deletion" flag as needed. -- The dependency check is NOT performed yet. procedure initial_package_scan (repository : String; id : port_id); -- Same as above, but for packages in the external repository procedure remote_package_scan (id : port_id); -- The result of the dependency query giving "id" port_id function result_of_dependency_query (repository : String; id : port_id) return JT.Text; -- Using the same make_queue as was used to scan the ports, use tasks -- (up to 32) to do the initial scanning of the ports, including getting -- the pkg dependency query. procedure parallel_package_scan (repository : String; remote_scan : Boolean; show_progress : Boolean); -- Prior to this procedure, the list of existing packages is split as -- a balanced array so this scan will query the package for its origin -- and package name. If the origin still exists, the port will be -- scanned for the current package name. If either check fails, the -- package will be deleted, otherwise the origin will be preserved for -- a further in-depth check. procedure parallel_preliminary_package_scan (repository : String; show_progress : Boolean); -- given a port_id, return the package name (no .txz extension!) function id2pkgname (id : port_id) return String; -- Turn on option and dependency debug checks programmatically procedure activate_debugging_code; -- Given an origin (already validated) and the name of the package in -- focus, return True if "make -V PKGFILE:T" matches the filename function current_package_name (origin, file_name : String) return Boolean; -- Dedicated progress meter for prescanning packages function package_scan_progress return String; -- Open log to document packages that get deleted and the reason why procedure start_obsolete_package_logging; -- Write to log if open and optionally output a copy to screen. procedure obsolete_notice (message : String; write_to_screen : Boolean); end PortScan.Packages;
sungyeon/drake
Ada
461
ads
pragma License (Unrestricted); -- implementation unit required by compiler with System.Exponentiations; with System.Unsigned_Types; package System.Exp_Uns is pragma Pure; -- required for "**" by compiler (s-expuns.ads) -- Modular types do not raise the exceptions. function Exp_Unsigned is new Exponentiations.Generic_Exp_Unsigned ( Unsigned_Types.Unsigned, Shift_Left => Unsigned_Types.Shift_Left); end System.Exp_Uns;
charlie5/cBound
Ada
1,494
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_free_cursor_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; cursor : aliased xcb.xcb_cursor_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_free_cursor_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_free_cursor_request_t.Item, Element_Array => xcb.xcb_free_cursor_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_free_cursor_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_free_cursor_request_t.Pointer, Element_Array => xcb.xcb_free_cursor_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_free_cursor_request_t;
reznikmm/matreshka
Ada
4,672
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.First_Page_Number_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_First_Page_Number_Attribute_Node is begin return Self : Style_First_Page_Number_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_First_Page_Number_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.First_Page_Number_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.First_Page_Number_Attribute, Style_First_Page_Number_Attribute_Node'Tag); end Matreshka.ODF_Style.First_Page_Number_Attributes;
reznikmm/ada-pretty
Ada
11,376
adb
with Ada.Characters.Wide_Wide_Latin_1; with Ada.Wide_Wide_Text_IO; with League.Strings; with Ada_Pretty; procedure Ada_Output_Test is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; procedure Print_API; procedure Print_Core_Spec_And_Body; F : aliased Ada_Pretty.Factory; Convention : constant Ada_Pretty.Node_Access := F.New_Aspect (F.New_Name (+"Convention"), F.New_Name (+"C")); Import : constant Ada_Pretty.Node_Access := F.New_Aspect (F.New_Name (+"Import"), F.New_Name (+"True")); LF : constant Wide_Wide_Character := Ada.Characters.Wide_Wide_Latin_1.LF; --------------- -- Print_API -- --------------- procedure Print_API is Name : constant Ada_Pretty.Node_Access := F.New_Selected_Name (+"Qt_Ada.API.Strings"); Clause : constant Ada_Pretty.Node_Access := F.New_With (F.New_Selected_Name (+"System.Storage_Elements")); Preelaborate : constant Ada_Pretty.Node_Access := F.New_Pragma (F.New_Name (+"Preelaborate")); QString : constant Ada_Pretty.Node_Access := F.New_Name (+"QString"); QString_Type : constant Ada_Pretty.Node_Access := F.New_Type (Name => QString, Definition => F.New_Record, Aspects => Convention); QString_Access : constant Ada_Pretty.Node_Access := F.New_Type (Name => F.New_Name (+"QString_Access"), Definition => F.New_Access (Ada_Pretty.Access_All, QString), Aspects => Convention); Link_Name : constant Ada_Pretty.Node_Access := F.New_Aspect (F.New_Name (+"Link_Name"), F.New_String_Literal (+"__qtada__QString__storage_size")); Aspect_List : constant Ada_Pretty.Node_Access := F.New_List (F.New_List (Import, Convention), Link_Name); QString_Storage_Size : constant Ada_Pretty.Node_Access := F.New_Variable (Name => F.New_Name (+"QString_Storage_Size"), Type_Definition => F.New_Selected_Name (+"System.Storage_Elements.Storage_Offset"), Is_Constant => True, Aspects => Aspect_List); Public : constant Ada_Pretty.Node_Access := F.New_List ((Preelaborate, QString_Type, QString_Access, QString_Storage_Size)); Root : constant Ada_Pretty.Node_Access := F.New_Package (Name, Public); Unit : constant Ada_Pretty.Node_Access := F.New_Compilation_Unit (Root, Clause); begin Ada.Wide_Wide_Text_IO.Put_Line (F.To_Text (Unit).Join (LF).To_Wide_Wide_String); end Print_API; ------------------------------ -- Print_Core_Spec_And_Body -- ------------------------------ procedure Print_Core_Spec_And_Body is Name : constant Ada_Pretty.Node_Access := F.New_Selected_Name (+"Qt5.Qt_Core.Strings"); With_1 : constant Ada_Pretty.Node_Access := F.New_With (F.New_Selected_Name (+"Ada.Finalization"), Is_Private => True); With_2 : constant Ada_Pretty.Node_Access := F.New_With (F.New_Selected_Name (+"System.Storage_Elements"), Is_Private => True); With_3 : constant Ada_Pretty.Node_Access := F.New_With (F.New_Selected_Name (+"Qt_Ada.API.Strings"), Is_Private => True); Clause : constant Ada_Pretty.Node_Access := F.New_List ((With_1, With_2, With_3)); Q_String : constant Ada_Pretty.Node_Access := F.New_Name (+"Q_String"); Q_String_Type : constant Ada_Pretty.Node_Access := F.New_Type (Name => Q_String, Definition => F.New_Private_Record (Is_Tagged => True)); QString_View : constant Ada_Pretty.Node_Access := F.New_Variable (Name => F.New_Name (+"QString_View"), Type_Definition => F.New_Selected_Name (+"Qt_Ada.API.Strings.QString_Access")); Is_Wrapper : constant Ada_Pretty.Node_Access := F.New_Variable (Name => F.New_Name (+"Is_Wrapper"), Type_Definition => F.New_Name (+"Boolean")); Storage : constant Ada_Pretty.Node_Access := F.New_Variable (Name => F.New_Name (+"Storage"), Type_Definition => F.New_Apply (F.New_Selected_Name (+"System.Storage_Elements.Storage_Array"), F.New_List (F.New_Literal (1), F.New_Infix (+"..", F.New_Selected_Name (+"Qt_Ada.API.Strings.QString_Storage_Size"))))); Q_String_Type_Full : constant Ada_Pretty.Node_Access := F.New_Type (Name => Q_String, Definition => F.New_Record (Parent => F.New_Selected_Name (+"Ada.Finalization.Controlled"), Components => F.New_List ((QString_View, Is_Wrapper, Storage)))); Self_Q_String : constant Ada_Pretty.Node_Access := F.New_Parameter (Name => F.New_Name (+"Self"), Is_In => True, Is_Out => True, Type_Definition => Q_String); Initialize : constant Ada_Pretty.Node_Access := F.New_Subprogram_Specification (Is_Overriding => Ada_Pretty.True, Name => F.New_Name (+"Initialize"), Parameters => Self_Q_String); Adjust : constant Ada_Pretty.Node_Access := F.New_Subprogram_Specification (Is_Overriding => Ada_Pretty.True, Name => F.New_Name (+"Adjust"), Parameters => Self_Q_String); Finalize : constant Ada_Pretty.Node_Access := F.New_Subprogram_Specification (Is_Overriding => Ada_Pretty.True, Name => F.New_Name (+"Finalize"), Parameters => Self_Q_String); Private_Part : constant Ada_Pretty.Node_Access := F.New_List ((Q_String_Type_Full, F.New_Subprogram_Declaration (Initialize), F.New_Subprogram_Declaration (Adjust), F.New_Subprogram_Declaration (Finalize))); Spec_Root : constant Ada_Pretty.Node_Access := F.New_Package (Name, Q_String_Type, Private_Part); Spec_Unit : constant Ada_Pretty.Node_Access := F.New_Compilation_Unit (Spec_Root, Clause); QString_Access : constant Ada_Pretty.Node_Access := F.New_Selected_Name (+"Qt_Ada.API.Strings.QString_Access"); Self_QString_Access : constant Ada_Pretty.Node_Access := F.New_Parameter (Name => F.New_Name (+"Self"), Is_In => True, Is_Out => True, Type_Definition => QString_Access); Address : constant Ada_Pretty.Node_Access := F.New_Selected_Name (+"System.Address"); Storage_Param : constant Ada_Pretty.Node_Access := F.New_Parameter (Name => F.New_Name (+"Storage"), Type_Definition => Address); QString_initialize : constant Ada_Pretty.Node_Access := F.New_Subprogram_Declaration (F.New_Subprogram_Specification (Name => F.New_Name (+"QString_initialize"), Parameters => F.New_List (Self_QString_Access, Storage_Param)), Aspects => F.New_List ((Import, Convention, F.New_Aspect (F.New_Name (+"Link_Name"), F.New_String_Literal (+"QString___initialize"))))); QString_finalize : constant Ada_Pretty.Node_Access := F.New_Subprogram_Declaration (F.New_Subprogram_Specification (Name => F.New_Name (+"QString_finalize"), Parameters => Self_QString_Access), Aspects => F.New_List ((Import, Convention, F.New_Aspect (F.New_Name (+"Link_Name"), F.New_String_Literal (+"QString__finalize"))))); QString_adjust : constant Ada_Pretty.Node_Access := F.New_Subprogram_Declaration (F.New_Subprogram_Specification (Name => F.New_Name (+"QString_adjust"), Parameters => F.New_List (Self_QString_Access, Storage_Param)), Aspects => F.New_List ((Import, Convention, F.New_Aspect (F.New_Name (+"Link_Name"), F.New_String_Literal (+"QString__adjust"))))); Self_QString_View : constant Ada_Pretty.Node_Access := F.New_Selected_Name (+"Self.QString_View"); Adjust_Stmt_1 : constant Ada_Pretty.Node_Access := F.New_Statement (F.New_Apply (F.New_Name (+"QString_adjust"), F.New_List (Self_QString_View, F.New_Selected_Name (+"Self.Storage'Address")))); Adjust_Stmt_2 : constant Ada_Pretty.Node_Access := F.New_Assignment (F.New_Selected_Name (+"Self.Is_Wrapper"), F.New_Name (+"False")); Adjust_Body : constant Ada_Pretty.Node_Access := F.New_Subprogram_Body (Adjust, Statements => F.New_List (Adjust_Stmt_1, Adjust_Stmt_2)); Finalize_Stmt : constant Ada_Pretty.Node_Access := F.New_If (Condition => F.New_Selected_Name (+"Self.Is_Wrapper"), Then_Path => F.New_Assignment (Self_QString_View, F.New_Name (+"null")), Elsif_List => F.New_Elsif (Condition => F.New_List (Self_QString_View, F.New_Infix (+"/=", F.New_Name (+"null"))), List => F.New_Statement (F.New_Apply (F.New_Name (+"QString_finalize"), Self_QString_View)))); Finalize_Body : constant Ada_Pretty.Node_Access := F.New_Subprogram_Body (Finalize, Declarations => F.New_Use (F.New_Selected_Name (+"Qt_Ada.API.Strings.QString_Access"), Use_Type => True), Statements => Finalize_Stmt); Initialize_Stmt_1 : constant Ada_Pretty.Node_Access := F.New_Statement (F.New_Apply (F.New_Name (+"QString_initialize"), F.New_List (Self_QString_View, F.New_Selected_Name (+"Self.Storage'Address")))); Initialize_Body : constant Ada_Pretty.Node_Access := F.New_Subprogram_Body (Initialize, Statements => F.New_List (Initialize_Stmt_1, Adjust_Stmt_2)); Body_Root : constant Ada_Pretty.Node_Access := F.New_Package_Body (Name, F.New_List ((QString_initialize, QString_finalize, QString_adjust, Adjust_Body, Finalize_Body, Initialize_Body))); Body_Unit : constant Ada_Pretty.Node_Access := F.New_Compilation_Unit (Body_Root); begin Ada.Wide_Wide_Text_IO.Put_Line (F.To_Text (Spec_Unit).Join (LF).To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put_Line (F.To_Text (Body_Unit).Join (LF).To_Wide_Wide_String); end Print_Core_Spec_And_Body; begin Print_API; Print_Core_Spec_And_Body; end Ada_Output_Test;
riccardo-bernardini/eugen
Ada
428
ads
package Eu_Projects.Event_Names is Begin_Name : constant Dotted_Identifier := To_Bounded_String ("begin"); End_Name : constant Dotted_Identifier := To_Bounded_String ("end"); Duration_Name : constant Dotted_Identifier := To_Bounded_String ("duration"); Event_Time_Name : constant Dotted_Identifier := To_Bounded_String ("when"); Default_Time : constant String := "default"; end Eu_Projects.Event_Names;
stcarrez/ada-util
Ada
1,394
adb
----------------------------------------------------------------------- -- util-commands-parsers -- Support to parse command line options -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Commands.Parsers is -- ------------------------------ -- Execute the command with its arguments (no parsing). -- ------------------------------ procedure Execute (Config : in out No_Config_Type; Args : in Argument_List'Class; Process : not null access procedure (Cmd_Args : in Argument_List'Class)) is pragma Unreferenced (Config); begin Process (Args); end Execute; end Util.Commands.Parsers;
faelys/natools
Ada
5,532
adb
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Natools.S_Expressions.Lockable is ---------------- -- Lock Stack -- ---------------- procedure Push_Level (Stack : in out Lock_Stack; Level : in Natural; State : out Lock_State) is begin State := (Depth => Stack.Depth, Level => Stack.Level); Stack := (Depth => Stack.Depth + 1, Level => Level); end Push_Level; procedure Pop_Level (Stack : in out Lock_Stack; State : in Lock_State; Allow_Gap : in Boolean := False) is begin if State.Depth = 0 then raise Constraint_Error with "Invalid stack state"; elsif State.Depth >= Stack.Depth then raise Constraint_Error with "Trying to Pop a state outside of Stack"; elsif not Allow_Gap and then State.Depth < Stack.Depth - 1 then raise Constraint_Error with "Trying to Pop several items without Allow_Gap"; end if; Stack := (Depth => State.Depth, Level => State.Level); end Pop_Level; function Current_Level (Stack : Lock_Stack) return Natural is begin return Stack.Level; end Current_Level; function Null_State return Lock_State is begin return (0, 0); end Null_State; ------------------------------------- -- Lockable Wrapper Implementation -- ------------------------------------- function Current_Event (Object : in Wrapper) return Events.Event is begin if Object.Finished then return Events.End_Of_Input; else return Object.Backend.Current_Event; end if; end Current_Event; function Current_Atom (Object : in Wrapper) return Atom is begin if Object.Finished then raise Program_Error with "Current_Atom on finished wrapper"; else return Object.Backend.Current_Atom; end if; end Current_Atom; function Current_Level (Object : in Wrapper) return Natural is begin if Object.Finished then return 0; else return Object.Backend.Current_Level - Current_Level (Object.Stack); end if; end Current_Level; procedure Query_Atom (Object : in Wrapper; Process : not null access procedure (Data : in Atom)) is begin if Object.Finished then raise Program_Error with "Query_Atom on finished wrapper"; else Object.Backend.Query_Atom (Process); end if; end Query_Atom; procedure Read_Atom (Object : in Wrapper; Data : out Atom; Length : out Count) is begin if Object.Finished then raise Program_Error with "Read_Atom on finished wrapper"; else Object.Backend.Read_Atom (Data, Length); end if; end Read_Atom; procedure Next (Object : in out Wrapper; Event : out Events.Event) is begin if Object.Finished then Event := Events.Error; return; end if; Object.Backend.Next (Event); if Event = Events.Close_List and then Object.Backend.Current_Level < Current_Level (Object.Stack) then Object.Finished := True; Event := Events.End_Of_Input; end if; end Next; procedure Lock (Object : in out Wrapper; State : out Lock_State) is begin Push_Level (Object.Stack, Object.Backend.Current_Level, State); end Lock; procedure Unlock (Object : in out Wrapper; State : in out Lock_State; Finish : in Boolean := True) is Previous_Level : constant Natural := Current_Level (Object.Stack); begin Pop_Level (Object.Stack, State); State := (0, 0); if Finish then declare Event : Events.Event; begin Event := Object.Backend.Current_Event; loop case Event is when Events.Open_List | Events.Add_Atom => null; when Events.Close_List => exit when Object.Backend.Current_Level < Previous_Level; when Events.Error | Events.End_Of_Input => exit; end case; Object.Backend.Next (Event); end loop; end; end if; Object.Finished := Object.Backend.Current_Level < Current_Level (Object.Stack); end Unlock; end Natools.S_Expressions.Lockable;
AdaCore/training_material
Ada
562
ads
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Simple_Io is function Get_String (Prompt : String) return String; function Get_Number (Prompt : String) return Integer; function Get_Character (Prompt : String) return Character; procedure Print_String (Str : String); procedure Print_Number (Num : Integer); procedure Print_Character (Char : Character); function Get_String (Prompt : String) return Unbounded_String; procedure Print_String (Str : Unbounded_String); end Simple_Io;
charlesdaniels/libagar
Ada
30,881
adb
------------------------------------------------------------------------------ -- AGAR GUI LIBRARY -- -- A G A R . S U R F A C E -- -- B o d y -- -- -- -- Copyright (c) 2018-2019 Julien Nadeau Carriere ([email protected]) -- -- -- -- 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. -- ------------------------------------------------------------------------------ with Agar.Error; with Ada.Text_IO; package body Agar.Surface is procedure Pixel_Format_RGB (Format : in Pixel_Format_not_null_Access; #if AG_MODEL = AG_LARGE Bits_per_Pixel : in Positive := 64; R_Mask : in AG_Pixel := 16#000000000000ffff#; G_Mask : in AG_Pixel := 16#00000000ffff0000#; B_Mask : in AG_Pixel := 16#0000ffff00000000#) is #else Bits_per_Pixel : in Positive := 32; R_Mask : in AG_Pixel := 16#000000ff#; G_Mask : in AG_Pixel := 16#0000ff00#; B_Mask : in AG_Pixel := 16#00ff0000#) is #end if; begin AG_PixelFormatRGB (Format => Format, Bits_per_Pixel => C.int(Bits_per_Pixel), R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask); end; procedure Pixel_Format_RGBA (Format : Pixel_Format_not_null_Access; #if AG_MODEL = AG_LARGE Bits_per_Pixel : in Positive := 64; R_Mask : in AG_Pixel := 16#000000000000ffff#; G_Mask : in AG_Pixel := 16#00000000ffff0000#; B_Mask : in AG_Pixel := 16#0000ffff00000000#; A_Mask : in AG_Pixel := 16#ffff000000000000#) is #else Bits_per_Pixel : in Positive := 32; R_Mask : in AG_Pixel := 16#000000ff#; G_Mask : in AG_Pixel := 16#0000ff00#; B_Mask : in AG_Pixel := 16#00ff0000#; A_Mask : in AG_Pixel := 16#ff000000#) is #end if; begin AG_PixelFormatRGBA (Format => Format, Bits_per_Pixel => C.int(Bits_per_Pixel), R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask, A_Mask => A_Mask); end; procedure Pixel_Format_Indexed (Format : Pixel_Format_not_null_Access; Bits_per_Pixel : Positive := 8) is begin AG_PixelFormatIndexed (Format => Format, Bits_per_Pixel => C.int(Bits_per_Pixel)); end; procedure Pixel_Format_Grayscale (Format : Pixel_Format_not_null_Access; Bits_per_Pixel : Positive := 32) is begin AG_PixelFormatGrayscale (Format => Format, Bits_per_Pixel => C.int(Bits_per_Pixel)); end; -- -- Compare the contents of two Pixel formats (if both are indexed, -- then compare their palettes as well). -- --function "=" (Left, Right : Pixel_Format_Access) return Boolean is --begin -- if Left = null and Right = null then -- return True; -- end if; -- if Left = null or Right = null then -- return False; -- end if; -- return 0 = AG_PixelFormatCompare (Left, Right); --end; -- -- Create a new surface in PACKED, INDEXED or GRAYSCALE pixel format. -- -- With PACKED mode, masks can be specified optionally in the Format -- argument (if Format is null then the default RGBA masks are used). -- -- Src_Colorkey enables colorkey transparency and Src_Alpha enables -- overall per-surface alpha in blits where Surface is the source. -- GL_Texture advises that the surface is a valid OpenGL texture. -- function New_Surface (Mode : in Surface_Mode := PACKED; W,H : in Natural := 0; Bits_per_Pixel : in Positive := 32; Format : in Pixel_Format_Access := null; Src_Colorkey : in Boolean := false; Src_Alpha : in Boolean := false; GL_Texture : in Boolean := false) return Surface_Access is Flags : C.unsigned := 0; begin if Src_Colorkey then Flags := Flags or SURFACE_COLORKEY; end if; if Src_Alpha then Flags := Flags or SURFACE_ALPHA; end if; if GL_Texture then Flags := Flags or SURFACE_GL_TEXTURE; end if; if Format = null then Ada.Text_IO.Put_Line("Format is null, auto-selecting"); case (Mode) is when PACKED => #if AG_MODEL = AG_LARGE case (Bits_per_Pixel) is when 64 => Ada.Text_IO.Put_Line("64-bit RGBA"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000000000000ffff#, G_Mask => 16#00000000ffff0000#, B_Mask => 16#0000ffff00000000#, A_Mask => 16#ffff000000000000#); when 48 => Ada.Text_IO.Put_Line("48-bit RGB"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000000000000ffff#, G_Mask => 16#00000000ffff0000#, B_Mask => 16#0000ffff00000000#, A_Mask => 0); when others => null; end case; #end if; case (Bits_per_Pixel) is when 32 => Ada.Text_IO.Put_Line("32-bit RGBA"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000000ff#, G_Mask => 16#0000ff00#, B_Mask => 16#00ff0000#, A_Mask => 16#ff000000#); when 24 => Ada.Text_IO.Put_Line("24-bit RGB"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000000ff#, G_Mask => 16#0000ff00#, B_Mask => 16#00ff0000#, A_Mask => 0); when 16 => Ada.Text_IO.Put_Line("16-bit RGBA"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000f#, G_Mask => 16#00f0#, B_Mask => 16#0f00#, A_Mask => 16#f000#); when 12 => Ada.Text_IO.Put_Line("12-bit RGB"); return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => 16#000f#, G_Mask => 16#00f0#, B_Mask => 16#0f00#, A_Mask => 0); when others => null; end case; when INDEXED => Ada.Text_IO.Put_Line(Integer'Image(Bits_per_Pixel) & "-bit Indexed"); return AG_SurfaceIndexed (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags); when GRAYSCALE => Ada.Text_IO.Put_Line(Integer'Image(Bits_per_Pixel) & "-bit Grayscale"); return AG_SurfaceGrayscale (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags); end case; -- Mode end if; -- Format = null return AG_SurfaceNew (Format => Format, W => C.unsigned(W), H => C.unsigned(H), Flags => Flags); end; -- -- Create a new surface in PACKED pixel format with RGBA masks. -- function New_Surface (W,H : in Natural := 0; #if AG_MODEL = AG_LARGE Bits_per_Pixel : in Positive := 64; R_Mask : in AG_Pixel := 16#000000000000ffff#; G_Mask : in AG_Pixel := 16#00000000ffff0000#; B_Mask : in AG_Pixel := 16#0000ffff00000000#; A_Mask : in AG_Pixel := 16#ffff000000000000#; #else Bits_per_Pixel : in Positive := 32; R_Mask : in AG_Pixel := 16#000000ff#; G_Mask : in AG_Pixel := 16#0000ff00#; B_Mask : in AG_Pixel := 16#00ff0000#; A_Mask : in AG_Pixel := 16#ff000000#; #end if; Src_Colorkey : in Boolean := false; Src_Alpha : in Boolean := false; GL_Texture : in Boolean := false) return Surface_Access is Flags : C.unsigned := 0; begin if Src_Colorkey then Flags := Flags or SURFACE_COLORKEY; end if; if Src_Alpha then Flags := Flags or SURFACE_ALPHA; end if; if GL_Texture then Flags := Flags or SURFACE_GL_TEXTURE; end if; if A_Mask /= 0 then return AG_SurfaceRGBA (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask, A_Mask => A_Mask); else return AG_SurfaceRGB (W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.unsigned(Bits_per_Pixel), Flags => Flags, R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask); end if; end New_Surface; -- -- Create a new PACKED surface (with given RGBA masks), -- and initialize its contents from existing pixel data. -- function New_Surface (Pixels : in Pixel_not_null_Access; W,H : in Natural; #if AG_MODEL = AG_LARGE Bits_per_Pixel : in Positive := 64; R_Mask : in AG_Pixel := 16#000000000000ffff#; G_Mask : in AG_Pixel := 16#00000000ffff0000#; B_Mask : in AG_Pixel := 16#0000ffff00000000#; A_Mask : in AG_Pixel := 16#ffff000000000000#; #else Bits_per_Pixel : in Positive := 32; R_Mask : in AG_Pixel := 16#000000ff#; G_Mask : in AG_Pixel := 16#0000ff00#; B_Mask : in AG_Pixel := 16#00ff0000#; A_Mask : in AG_Pixel := 16#ff000000#; #end if; Src_Colorkey : in Boolean := false; Src_Alpha : in Boolean := false; GL_Texture : in Boolean := false) return Surface_Access is S : Surface_Access; begin if A_Mask /= 0 then S := AG_SurfaceFromPixelsRGBA (Pixels => Pixels, W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.int(Bits_per_Pixel), R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask, A_Mask => A_Mask); else S := AG_SurfaceFromPixelsRGB (Pixels => Pixels, W => C.unsigned(W), H => C.unsigned(H), Bits_per_Pixel => C.int(Bits_per_Pixel), R_Mask => R_Mask, G_Mask => G_Mask, B_Mask => B_Mask); end if; if S = null then return null; end if; if Src_Colorkey then S.Flags := S.Flags or SURFACE_COLORKEY; end if; if Src_Alpha then S.Flags := S.Flags or SURFACE_ALPHA; end if; if GL_Texture then S.Flags := S.Flags or SURFACE_GL_TEXTURE; end if; return S; end New_Surface; -- -- Create a new surface by loading a BMP, PNG or JPEG image file. -- function New_Surface (File : in String; Src_Colorkey : in Boolean := false; Src_Alpha : in Boolean := false; GL_Texture : in Boolean := false) return Surface_Access is Ch_File : aliased C.char_array := C.To_C(File); S : Surface_Access; begin S := AG_SurfaceFromFile (File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)); if S = null then return null; end if; if Src_Colorkey then S.Flags := S.Flags or SURFACE_COLORKEY; end if; if Src_Alpha then S.Flags := S.Flags or SURFACE_ALPHA; end if; if GL_Texture then S.Flags := S.Flags or SURFACE_GL_TEXTURE; end if; return S; end; -- -- Create a surface in the "best" format suitable for OpenGL textures. -- function New_Surface_GL (W,H : in Natural) return Surface_Access is begin return AG_SurfaceStdGL (W => C.unsigned(W), H => C.unsigned(H)); end; -- -- Return a Color from 8-bit RGBA components. -- function Color_8 (R,G,B : in Unsigned_8; A : in Unsigned_8 := 255) return AG_Color is #if AG_MODEL = AG_LARGE Color : constant AG_Color := (Unsigned_16(Float(R) / 255.0 * 65535.0), Unsigned_16(Float(G) / 255.0 * 65535.0), Unsigned_16(Float(B) / 255.0 * 65535.0), Unsigned_16(Float(A) / 255.0 * 65535.0)); #else Color : constant AG_Color := (R,G,B,A); #end if; begin return Color; end; -- -- Return an AG_Color from 16-bit RGBA components. -- function Color_16 (R,G,B : in Unsigned_16; A : in Unsigned_16 := 65535) return AG_Color is #if AG_MODEL = AG_LARGE Color : constant AG_Color := (R,G,B,A); #else Color : constant AG_Color := (Unsigned_8(Float(R) / 65535.0 * 255.0), Unsigned_8(Float(G) / 65535.0 * 255.0), Unsigned_8(Float(B) / 65535.0 * 255.0), Unsigned_8(Float(A) / 65535.0 * 255.0)); #end if; begin return Color; end; -- -- Return a Color from Hue, Saturation, Value and Alpha components. -- function Color_HSV (H,S,V : in Intensity; A : in Intensity := 1.0) return AG_Color is Color : aliased AG_Color; begin AG_HSV2Color (H => C.c_float(H), S => C.c_float(S), V => C.c_float(V), Color => Color'Unchecked_Access); #if AG_MODEL = AG_LARGE Color.A := AG_Component(A * 65535.0); #else Color.A := AG_Component(A * 255.0); #end if; return Color; end; -- -- Return a native component offset amount for a given 8-bit component. -- function Component_Offset_8 (X : in Unsigned_8) return AG_Component is begin #if AG_MODEL = AG_LARGE return AG_Component(Float(X) / 255.0 * 65535.0); #else return AG_Component(X); #end if; end; -- -- Return a native component offset amount for a given 16-bit component. -- function Component_Offset_16 (X : in Unsigned_16) return AG_Component is begin #if AG_MODEL = AG_LARGE return AG_Component(X); #else return AG_Component(Float(X) / 65535.0 * 255.0); #end if; end; -- -- Set a color palette entry of an Indexed surface (AG_Color argument) -- procedure Set_Color (Surface : in Surface_not_null_Access; Index : in Natural; Color : in AG_Color) is C_Color : aliased AG_Color := Color; begin AG_SurfaceSetColors (Surface => Surface, Color => C_Color'Unchecked_Access, Offset => C.unsigned(Index), Count => 1); end; -- -- Set a color palette entry of an Indexed surface (AG_Color access argument) -- procedure Set_Color (Surface : in Surface_not_null_Access; Index : in Natural; Color : in Color_not_null_Access) is begin AG_SurfaceSetColors (Surface => Surface, Color => Color, Offset => C.unsigned(Index), Count => 1); end; -- -- Copy a Source surface (or a region of its pixels) to a Target surface -- which can be of a different format. Handle format conversion, clipping -- and blending according to the pixel formats of the surfaces (and their -- Colorkey and Src_Alpha settings). -- procedure Blit_Surface (Source : in Surface_not_null_Access; Src_Rect : in Rect_access := null; Target : in Surface_not_null_Access; Dst_X : in Natural := 0; Dst_Y : in Natural := 0) is begin AG_SurfaceBlit (Source => Source, Src_Rect => Src_Rect, Target => Target, X => C.int(Dst_X), Y => C.int(Dst_Y)); end; -- -- Change the dimensions of a surface without scaling its contents. Pixel -- data is reallocated (if growing the surface, then then new pixels are -- left uninitialized). -- function Resize_Surface (Surface : in Surface_not_null_Access; W,H : in Natural) return Boolean is begin return 0 = AG_SurfaceResize (Surface => Surface, W => C.unsigned(W), H => C.unsigned(H)); end; procedure Resize_Surface (Surface : in Surface_not_null_Access; W,H : in Natural) is Result : C.int; begin Result := AG_SurfaceResize (Surface => Surface, W => C.unsigned(W), H => C.unsigned(H)); if Result /= 0 then raise Program_Error with Agar.Error.Get_Error; end if; end; -- -- Export the surface to a BMP, PNG or JPEG image file. -- function Export_Surface (Surface : in Surface_not_null_Access; File : in String) return Boolean is Ch_File : aliased C.char_array := C.To_C(File); begin return 0 = AG_SurfaceExportFile (Surface => Surface, File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)); end; -- -- Export the surface to a Windows bitmap image file. -- function Export_BMP (Surface : in Surface_not_null_Access; File : in String := "output.bmp") return Boolean is Ch_File : aliased C.char_array := C.To_C(File); begin return 0 = AG_SurfaceExportBMP (Surface => Surface, File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)); end; -- -- Export the surface to a PNG image file. -- function Export_PNG (Surface : in Surface_not_null_Access; File : in String := "output.png"; Adam7 : in Boolean := false) return Boolean is Ch_File : aliased C.char_array := C.To_C(File); Flags : C.unsigned := 0; begin if Adam7 then Flags := EXPORT_PNG_ADAM7; end if; return 0 = AG_SurfaceExportPNG (Surface => Surface, File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access), Flags => Flags); end; -- -- Export the surface to a JPEG image file. -- function Export_JPEG (Surface : in Surface_not_null_Access; File : in String := "output.jpg"; Quality : in JPEG_Quality := 100; Method : in JPEG_Method := JDCT_ISLOW) return Boolean is Ch_File : aliased C.char_array := C.To_C(File); Flags : C.unsigned := 0; begin case (Method) is when JDCT_ISLOW => Flags := EXPORT_JPEG_JDCT_ISLOW; when JDCT_IFAST => Flags := EXPORT_JPEG_JDCT_IFAST; when JDCT_FLOAT => Flags := EXPORT_JPEG_JDCT_FLOAT; end case; return 0 = AG_SurfaceExportJPEG (Surface => Surface, File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access), Quality => C.unsigned(Quality), Flags => Flags); end; -- -- Return a string describing a blending function. -- function Alpha_Func_Name (Func : Alpha_Func) return String is begin case Func is when ALPHA_OVERLAY => return "src+dst"; when ALPHA_ZERO => return "zero"; when ALPHA_ONE => return "one"; when ALPHA_SRC => return "src"; when ALPHA_DST => return "dst"; when ALPHA_ONE_MINUS_DST => return "1-dst"; when ALPHA_ONE_MINUS_SRC => return "1-src"; end case; end; -- -- Blend a target pixel against a specified color. The target pixel's -- alpha component is computed according to Func (by pixel address). -- procedure Blend_Pixel (Surface : in Surface_not_null_Access; Pixel : in Pixel_not_null_Access; Color : in Color_not_null_Access; Func : in Alpha_Func := ALPHA_OVERLAY) is begin AG_SurfaceBlend_At (Surface => Surface, Pixel => Pixel, Color => Color, Func => Alpha_Func'Pos(Func)); end; -- -- Blend a target pixel against a specified color. The target pixel's -- alpha component is computed according to Func (by X,Y coordinates). -- procedure Blend_Pixel (Surface : in Surface_not_null_Access; X,Y : in Natural; Color : in Color_not_null_Access; Func : in Alpha_Func := ALPHA_OVERLAY) is begin AG_SurfaceBlend (Surface => Surface, X => C.int(X), Y => C.int(Y), Color => Color, Func => Alpha_Func'Pos(Func)); end; -- -- Return the native-width packed pixel corresponding to an AG_Color -- (under the pixel format of Surface). -- function Map_Pixel (Surface : in Surface_not_null_Access; Color : in AG_Color) return AG_Pixel is C_Color : aliased AG_Color := Color; begin #if AG_MODEL = AG_LARGE return AG_MapPixel64 (Format => Surface.Format'Access, Color => C_Color'Unchecked_Access); #else return AG_MapPixel32 (Format => Surface.Format'Access, Color => C_Color'Unchecked_Access); #end if; end; -- -- Return the native-width packed pixel corresponding to an AG_Color -- (under the specified pixel format). -- function Map_Pixel (Format : in Pixel_Format_not_null_Access; Color : in AG_Color) return AG_Pixel is C_Color : aliased AG_Color := Color; begin #if AG_MODEL = AG_LARGE return AG_MapPixel64 (Format => Format, Color => C_Color'Unchecked_Access); #else return AG_MapPixel32 (Format => Format, Color => C_Color'Unchecked_Access); #end if; end; -- -- Return the native-width packed pixel corresponding to an AG_Color -- (under the pixel format of Surface). -- function Map_Pixel (Surface : in Surface_not_null_Access; Color : in Color_not_null_access) return AG_Pixel is begin #if AG_MODEL = AG_LARGE return AG_MapPixel64 (Format => Surface.Format'Access, Color => Color); #else return AG_MapPixel32 (Format => Surface.Format'Access, Color => Color); #end if; end; -- -- Return a new surface generated by scaling an Input surface to specified -- dimensions. Function form may fail and return null. -- function Scale_Surface (Surface : in Surface_not_null_Access; W,H : in Natural) return Surface_Access is begin return AG_SurfaceScale (Surface => Surface, W => C.unsigned(W), H => C.unsigned(H), Flags => C.unsigned(0)); end; -- -- Return a new surface generated by scaling an Input surface to specified -- dimensions. Procedure form raises fatal exception on failure. -- procedure Scale_Surface (Original : in Surface_not_null_Access; W,H : in Natural; Scaled : out Surface_not_null_Access) is Result : Surface_Access; begin Result := AG_SurfaceScale (Surface => Original, W => C.unsigned(W), H => C.unsigned(H), Flags => C.unsigned(0)); if Result = null then raise Program_Error with Agar.Error.Get_Error; end if; Scaled := Result; end; -- -- Fill a rectangle of pixels with a specified color (AG_Color argument). -- procedure Fill_Rect (Surface : in Surface_not_null_Access; Rect : in Rect_Access := null; Color : in AG_Color) is C_Color : aliased AG_Color := Color; begin AG_FillRect (Surface => Surface, Rect => Rect, Color => C_Color'Unchecked_Access); end; -- -- Extract a native-width packed pixel from a surface (by coordinates). -- function Get_Pixel (Surface : in Surface_not_null_Access; X,Y : in Natural) return AG_Pixel is begin #if AG_MODEL = AG_LARGE return AG_SurfaceGet64 (Surface => Surface, X => C.int(X), Y => C.int(Y)); #else return AG_SurfaceGet32 (Surface => Surface, X => C.int(X), Y => C.int(Y)); #end if; end; -- -- Extract a 32-bit packed pixel from a surface (by coordinates). -- function Get_Pixel_32 (Surface : in Surface_not_null_Access; X,Y : in Natural) return Unsigned_32 is begin return AG_SurfaceGet32 (Surface => Surface, X => C.int(X), Y => C.int(Y)); end; #if AG_MODEL = AG_LARGE -- -- Extract a 64-bit packed pixel from a surface (by coordinates). -- function Get_Pixel_64 (Surface : in Surface_not_null_Access; X,Y : in Natural) return Unsigned_64 is begin return AG_SurfaceGet64 (Surface => Surface, X => C.int(X), Y => C.int(Y)); end; #end if; -- -- Set a native-width packed pixel in a surface (by coordinates). -- procedure Put_Pixel (Surface : in Surface_not_null_Access; X,Y : in Natural; Pixel : in AG_Pixel; Clipping : in Boolean := true) is begin if Clipping then if C.int(X) < Surface.Clip_Rect.X or C.int(Y) < Surface.Clip_Rect.Y or C.int(X) >= Surface.Clip_Rect.X+Surface.Clip_Rect.W or C.int(Y) >= Surface.Clip_Rect.Y+Surface.Clip_Rect.H then return; end if; end if; #if AG_MODEL = AG_LARGE AG_SurfacePut64 (Surface => Surface, X => C.int(X), Y => C.int(Y), Pixel => Pixel); #else AG_SurfacePut32 (Surface => Surface, X => C.int(X), Y => C.int(Y), Pixel => Pixel); #end if; end; -- -- Set a 32-bit packed pixel in a surface (by coordinates). -- procedure Put_Pixel_32 (Surface : in Surface_not_null_Access; X,Y : in Natural; Pixel : in Unsigned_32; Clipping : in Boolean := true) is begin if Clipping then if C.int(X) < Surface.Clip_Rect.X or C.int(Y) < Surface.Clip_Rect.Y or C.int(X) >= Surface.Clip_Rect.X+Surface.Clip_Rect.W or C.int(Y) >= Surface.Clip_Rect.Y+Surface.Clip_Rect.H then return; end if; end if; AG_SurfacePut32 (Surface => Surface, X => C.int(X), Y => C.int(Y), Pixel => Pixel); end; #if AG_MODEL = AG_LARGE -- -- Set a 64-bit packed pixel in a surface (by coordinates). -- procedure Put_Pixel_64 (Surface : in Surface_not_null_Access; X,Y : in Natural; Pixel : in Unsigned_64; Clipping : in Boolean := true) is begin if Clipping then if C.int(X) < Surface.Clip_Rect.X or C.int(Y) < Surface.Clip_Rect.Y or C.int(X) >= Surface.Clip_Rect.X+Surface.Clip_Rect.W or C.int(Y) >= Surface.Clip_Rect.Y+Surface.Clip_Rect.H then return; end if; end if; AG_SurfacePut64 (Surface => Surface, X => C.int(X), Y => C.int(Y), Pixel => Pixel); end; #end if; procedure Unpack_Pixel (Pixel : in AG_Pixel; Format : in Pixel_Format_not_null_Access; R,G,B,A : out AG_Component) is Color : aliased AG_Color; begin #if AG_MODEL = AG_LARGE AG_GetColor64 (Color => Color'Unchecked_Access, Pixel => Pixel, Format => Format); #else AG_GetColor32 (Color => Color'Unchecked_Access, Pixel => Pixel, Format => Format); #end if; R := Color.R; G := Color.G; B := Color.B; A := Color.A; end; -- -- Set source alpha flag and per-surface alpha value. -- procedure Set_Alpha (Surface : in Surface_not_null_Access; Enable : in Boolean := false; Alpha : in AG_Component := AG_OPAQUE) is begin if (Enable) then Surface.Flags := Surface.Flags or SURFACE_ALPHA; else Surface.Flags := Surface.Flags and not SURFACE_ALPHA; end if; Surface.Alpha := Alpha; end; -- -- Set source colorkey flag and surface colorkey value. -- procedure Set_Colorkey (Surface : in Surface_not_null_Access; Enable : in Boolean := false; Colorkey : in AG_Pixel := 0) is begin if (Enable) then Surface.Flags := Surface.Flags or SURFACE_COLORKEY; else Surface.Flags := Surface.Flags and not SURFACE_COLORKEY; end if; Surface.Colorkey := Colorkey; end; -- -- Get surface clipping rectangle. -- procedure Get_Clipping_Rect (Surface : in Surface_not_null_Access; X,Y,W,H : out Natural) is begin X := Natural(Surface.Clip_Rect.X); Y := Natural(Surface.Clip_Rect.Y); W := Natural(Surface.Clip_Rect.W); H := Natural(Surface.Clip_Rect.H); end; procedure Set_Clipping_Rect (Surface : in Surface_not_null_Access; X,Y,W,H : in Natural) is begin Surface.Clip_Rect.X := C.int(X); Surface.Clip_Rect.Y := C.int(Y); Surface.Clip_Rect.W := C.int(W); Surface.Clip_Rect.H := C.int(H); end; end Agar.Surface;
tum-ei-rcs/StratoX
Ada
10,289
ads
-- -- Copyright (C) 2016, AdaCore -- -- This spec has been automatically generated from STM32F429x.svd -- This is a version for the STM32F429x MCU package Ada.Interrupts.Names with SPARK_Mode => On is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; ---------------- -- Interrupts -- ---------------- -- The position of the interrupts are documented as starting at 0. -- Unfortunately, Interrupt_Id 0 is reserved and the SysTick interrupt (a -- core interrupt) is handled by the runtime like other interrupts. So IRQ -- 0 is numbered 2 while it is at position 0 in the manual. The offset of 2 -- is reflected in s-bbbosu.adb by the First_IRQ constant. Sys_Tick_Interrupt : constant Interrupt_ID := 1; -- Window Watchdog interrupt WWDG_Interrupt : constant Interrupt_ID := 2; -- PVD through EXTI line detection interrupt PVD_Interrupt : constant Interrupt_ID := 3; -- Tamper and TimeStamp interrupts through the EXTI line TAMP_STAMP_Interrupt : constant Interrupt_ID := 4; -- RTC Wakeup interrupt through the EXTI line RTC_WKUP_Interrupt : constant Interrupt_ID := 5; -- Flash global interrupt FLASH_Interrupt : constant Interrupt_ID := 6; -- RCC global interrupt RCC_Interrupt : constant Interrupt_ID := 7; -- EXTI Line0 interrupt EXTI0_Interrupt : constant Interrupt_ID := 8; -- EXTI Line1 interrupt EXTI1_Interrupt : constant Interrupt_ID := 9; -- EXTI Line2 interrupt EXTI2_Interrupt : constant Interrupt_ID := 10; -- EXTI Line3 interrupt EXTI3_Interrupt : constant Interrupt_ID := 11; -- EXTI Line4 interrupt EXTI4_Interrupt : constant Interrupt_ID := 12; -- DMA1 Stream0 global interrupt DMA1_Stream0_Interrupt : constant Interrupt_ID := 13; -- DMA1 Stream1 global interrupt DMA1_Stream1_Interrupt : constant Interrupt_ID := 14; -- DMA1 Stream2 global interrupt DMA1_Stream2_Interrupt : constant Interrupt_ID := 15; -- DMA1 Stream3 global interrupt DMA1_Stream3_Interrupt : constant Interrupt_ID := 16; -- DMA1 Stream4 global interrupt DMA1_Stream4_Interrupt : constant Interrupt_ID := 17; -- DMA1 Stream5 global interrupt DMA1_Stream5_Interrupt : constant Interrupt_ID := 18; -- DMA1 Stream6 global interrupt DMA1_Stream6_Interrupt : constant Interrupt_ID := 19; -- ADC1 global interrupt ADC_Interrupt : constant Interrupt_ID := 20; -- CAN1 TX interrupts CAN1_TX_Interrupt : constant Interrupt_ID := 21; -- CAN1 RX0 interrupts CAN1_RX0_Interrupt : constant Interrupt_ID := 22; -- CAN1 RX1 interrupts CAN1_RX1_Interrupt : constant Interrupt_ID := 23; -- CAN1 SCE interrupt CAN1_SCE_Interrupt : constant Interrupt_ID := 24; -- EXTI Line[9:5] interrupts EXTI9_5_Interrupt : constant Interrupt_ID := 25; -- TIM1 Break interrupt and TIM9 global interrupt TIM1_BRK_TIM9_Interrupt : constant Interrupt_ID := 26; -- TIM1 Update interrupt and TIM10 global interrupt TIM1_UP_TIM10_Interrupt : constant Interrupt_ID := 27; -- TIM1 Trigger and Commutation interrupts and TIM11 global interrupt TIM1_TRG_COM_TIM11_Interrupt : constant Interrupt_ID := 28; -- TIM1 Capture Compare interrupt TIM1_CC_Interrupt : constant Interrupt_ID := 29; -- TIM2 global interrupt TIM2_Interrupt : constant Interrupt_ID := 30; -- TIM3 global interrupt TIM3_Interrupt : constant Interrupt_ID := 31; -- TIM4 global interrupt TIM4_Interrupt : constant Interrupt_ID := 32; -- I2C1 event interrupt I2C1_EV_Interrupt : constant Interrupt_ID := 33; -- I2C1 error interrupt I2C1_ER_Interrupt : constant Interrupt_ID := 34; -- I2C2 event interrupt I2C2_EV_Interrupt : constant Interrupt_ID := 35; -- I2C2 error interrupt I2C2_ER_Interrupt : constant Interrupt_ID := 36; -- SPI1 global interrupt SPI1_Interrupt : constant Interrupt_ID := 37; -- SPI2 global interrupt SPI2_Interrupt : constant Interrupt_ID := 38; -- USART1 global interrupt USART1_Interrupt : constant Interrupt_ID := 39; -- USART2 global interrupt USART2_Interrupt : constant Interrupt_ID := 40; -- USART3 global interrupt USART3_Interrupt : constant Interrupt_ID := 41; -- EXTI Line[15:10] interrupts EXTI15_10_Interrupt : constant Interrupt_ID := 42; -- RTC Alarms (A and B) through EXTI line interrupt RTC_Alarm_Interrupt : constant Interrupt_ID := 43; -- USB On-The-Go FS Wakeup through EXTI line interrupt OTG_FS_WKUP_Interrupt : constant Interrupt_ID := 44; -- TIM8 Break interrupt and TIM12 global interrupt TIM8_BRK_TIM12_Interrupt : constant Interrupt_ID := 45; -- TIM8 Update interrupt and TIM13 global interrupt TIM8_UP_TIM13_Interrupt : constant Interrupt_ID := 46; -- TIM8 Trigger and Commutation interrupts and TIM14 global interrupt TIM8_TRG_COM_TIM14_Interrupt : constant Interrupt_ID := 47; -- TIM8 Capture Compare interrupt TIM8_CC_Interrupt : constant Interrupt_ID := 48; -- DMA1 Stream7 global interrupt DMA1_Stream7_Interrupt : constant Interrupt_ID := 49; -- FMC global interrupt FMC_Interrupt : constant Interrupt_ID := 50; -- SDIO global interrupt SDIO_Interrupt : constant Interrupt_ID := 51; -- TIM5 global interrupt TIM5_Interrupt : constant Interrupt_ID := 52; -- SPI3 global interrupt SPI3_Interrupt : constant Interrupt_ID := 53; -- UART4 global interrupt UART4_Interrupt : constant Interrupt_ID := 54; -- UART5 global interrupt UART5_Interrupt : constant Interrupt_ID := 55; -- TIM6 global interrupt, DAC1 and DAC2 underrun error interrupt TIM6_DAC_Interrupt : constant Interrupt_ID := 56; -- TIM7 global interrupt TIM7_Interrupt : constant Interrupt_ID := 57; -- DMA2 Stream0 global interrupt DMA2_Stream0_Interrupt : constant Interrupt_ID := 58; -- DMA2 Stream1 global interrupt DMA2_Stream1_Interrupt : constant Interrupt_ID := 59; -- DMA2 Stream2 global interrupt DMA2_Stream2_Interrupt : constant Interrupt_ID := 60; -- DMA2 Stream3 global interrupt DMA2_Stream3_Interrupt : constant Interrupt_ID := 61; -- DMA2 Stream4 global interrupt DMA2_Stream4_Interrupt : constant Interrupt_ID := 62; -- Ethernet global interrupt ETH_Interrupt : constant Interrupt_ID := 63; -- Ethernet Wakeup through EXTI line interrupt ETH_WKUP_Interrupt : constant Interrupt_ID := 64; -- CAN2 TX interrupts CAN2_TX_Interrupt : constant Interrupt_ID := 65; -- CAN2 RX0 interrupts CAN2_RX0_Interrupt : constant Interrupt_ID := 66; -- CAN2 RX1 interrupts CAN2_RX1_Interrupt : constant Interrupt_ID := 67; -- CAN2 SCE interrupt CAN2_SCE_Interrupt : constant Interrupt_ID := 68; -- USB On The Go FS global interrupt OTG_FS_Interrupt : constant Interrupt_ID := 69; -- DMA2 Stream5 global interrupt DMA2_Stream5_Interrupt : constant Interrupt_ID := 70; -- DMA2 Stream6 global interrupt DMA2_Stream6_Interrupt : constant Interrupt_ID := 71; -- DMA2 Stream7 global interrupt DMA2_Stream7_Interrupt : constant Interrupt_ID := 72; -- USART6 global interrupt USART6_Interrupt : constant Interrupt_ID := 73; -- I2C3 event interrupt I2C3_EV_Interrupt : constant Interrupt_ID := 74; -- I2C3 error interrupt I2C3_ER_Interrupt : constant Interrupt_ID := 75; -- USB On The Go HS End Point 1 Out global interrupt OTG_HS_EP1_OUT_Interrupt : constant Interrupt_ID := 76; -- USB On The Go HS End Point 1 In global interrupt OTG_HS_EP1_IN_Interrupt : constant Interrupt_ID := 77; -- USB On The Go HS Wakeup through EXTI interrupt OTG_HS_WKUP_Interrupt : constant Interrupt_ID := 78; -- USB On The Go HS global interrupt OTG_HS_Interrupt : constant Interrupt_ID := 79; -- DCMI global interrupt DCMI_Interrupt : constant Interrupt_ID := 80; -- Rng global interrupt HASH_RNG_Interrupt : constant Interrupt_ID := 82; -- FPU global interrupt FPU_Interrupt : constant Interrupt_ID := 83; -- UART 7 global interrupt UART7_Interrupt : constant Interrupt_ID := 84; -- UART 8 global interrupt UART8_Interrupt : constant Interrupt_ID := 85; -- SPI 4 global interrupt SPI4_Interrupt : constant Interrupt_ID := 86; -- SPI 5 global interrupt SPI5_Interrupt : constant Interrupt_ID := 87; -- SPI 6 global interrupt SPI6_Interrupt : constant Interrupt_ID := 88; -- SAI1 global interrupt SAI1_Interrupt : constant Interrupt_ID := 89; -- LTDC global interrupt LCD_TFT_Interrupt : constant Interrupt_ID := 90; -- LTDC global error interrupt LCD_TFT_1_Interrupt : constant Interrupt_ID := 91; -- DMA2D global interrupt DMA2D_Interrupt : constant Interrupt_ID := 92; end Ada.Interrupts.Names;
zhmu/ananas
Ada
16,685
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- X R _ T A B L S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Cross reference utilities used by gnatxref and gnatfind with GNAT.OS_Lib; package Xr_Tabls is ------------------- -- Project files -- ------------------- function ALI_File_Name (Ada_File_Name : String) return String; -- Returns the ali file name corresponding to Ada_File_Name procedure Create_Project_File (Name : String); -- Open and parse a new project file. If the file Name could not be -- opened or is not a valid project file, then a project file associated -- with the standard default directories is returned function Next_Obj_Dir return String; -- Returns the next directory to visit to find related ali files -- If there are no more such directories, returns a null string. function Current_Obj_Dir return String; -- Returns the obj_dir which was returned by the last Next_Obj_Dir call procedure Reset_Obj_Dir; -- Reset the iterator for Obj_Dir ------------ -- Tables -- ------------ type Declaration_Reference is private; Empty_Declaration : constant Declaration_Reference; type Declaration_Array is array (Natural range <>) of Declaration_Reference; type Declaration_Array_Access is access Declaration_Array; type File_Reference is private; Empty_File : constant File_Reference; type Reference is private; Empty_Reference : constant Reference; type Reference_Array is array (Natural range <>) of Reference; type Reference_Array_Access is access Reference_Array; procedure Free (Arr : in out Reference_Array_Access); function Add_Declaration (File_Ref : File_Reference; Symbol : String; Line : Natural; Column : Natural; Decl_Type : Character; Is_Parameter : Boolean := False; Remove_Only : Boolean := False; Symbol_Match : Boolean := True) return Declaration_Reference; -- Add a new declaration in the table and return the index to it. Decl_Type -- is the type of the entity Any previous instance of this entity in the -- htable is removed. If Remove_Only is True, then any previous instance is -- removed, but the new entity is never inserted. Symbol_Match should be -- set to False if the name of the symbol doesn't match the pattern from -- the command line. In that case, the entity will not be output by -- gnatfind. If Symbol_Match is True, the entity will only be output if -- the file name itself matches. Is_Parameter should be set to True if -- the entity is known to be a subprogram parameter. procedure Add_Parent (Declaration : in out Declaration_Reference; Symbol : String; Line : Natural; Column : Natural; File_Ref : File_Reference); -- The parent declaration (Symbol in file File_Ref at position Line and -- Column) information is added to Declaration. function Add_To_Xref_File (File_Name : String; Visited : Boolean := True; Emit_Warning : Boolean := False; Gnatchop_File : String := ""; Gnatchop_Offset : Integer := 0) return File_Reference; -- Add a new reference to a file in the table. Ref is used to return the -- index in the table where this file is stored. Visited is the value which -- will be used in the table (if True, the file will not be returned by -- Next_Unvisited_File). If Emit_Warning is True and the ali file does -- not exist or does not have cross-referencing information, then a -- warning will be emitted. Gnatchop_File is the name of the file that -- File_Name was extracted from through a call to "gnatchop -r" (using -- pragma Source_Reference). Gnatchop_Offset should be the index of the -- first line of File_Name within the Gnatchop_File. procedure Add_Line (File : File_Reference; Line : Natural; Column : Natural); -- Add a new reference in a file, which the user has provided on the -- command line. This is used for an optimized matching algorithm. procedure Add_Reference (Declaration : Declaration_Reference; File_Ref : File_Reference; Line : Natural; Column : Natural; Ref_Type : Character; Labels_As_Ref : Boolean); -- Add a new reference (Ref_Type = 'r'), body (Ref_Type = 'b') or -- modification (Ref_Type = 'm') to an entity. If Labels_As_Ref is True, -- then the references to the entity after the end statements ("end Foo") -- are counted as actual references. This means that the entity will never -- be reported as unreferenced (for instance in the case of gnatxref -u). function Get_Declarations (Sorted : Boolean := True) return Declaration_Array_Access; -- Return a sorted list of all the declarations in the application. -- Freeing this array is the responsibility of the caller, however it -- shouldn't free the actual contents of the array, which are pointers -- to internal data function References_Count (Decl : Declaration_Reference; Get_Reads : Boolean := False; Get_Writes : Boolean := False; Get_Bodies : Boolean := False) return Natural; -- Return the number of references in Decl for the categories specified -- by the Get_* parameters (read-only accesses, write accesses and bodies) function Get_References (Decl : Declaration_Reference; Get_Reads : Boolean := False; Get_Writes : Boolean := False; Get_Bodies : Boolean := False) return Reference_Array_Access; -- Return a sorted list of all references to the entity in decl. The -- parameters Get_* are used to specify what kind of references should be -- merged and returned (read-only accesses, write accesses and bodies). function Get_Column (Decl : Declaration_Reference) return String; function Get_Column (Ref : Reference) return String; function Get_Declaration (File_Ref : File_Reference; Line : Natural; Column : Natural) return Declaration_Reference; -- Returns reference to the declaration found in file File_Ref at the -- given Line and Column function Get_Parent (Decl : Declaration_Reference) return Declaration_Reference; -- Returns reference to Decl's parent declaration function Get_Emit_Warning (File : File_Reference) return Boolean; -- Returns the Emit_Warning field of the structure function Get_Gnatchop_File (File : File_Reference; With_Dir : Boolean := False) return String; function Get_Gnatchop_File (Ref : Reference; With_Dir : Boolean := False) return String; function Get_Gnatchop_File (Decl : Declaration_Reference; With_Dir : Boolean := False) return String; -- Return the name of the file that File was extracted from through a -- call to "gnatchop -r". The file name for File is returned if File -- was not extracted from such a file. The directory will be given only -- if With_Dir is True. function Get_File (Decl : Declaration_Reference; With_Dir : Boolean := False) return String; pragma Inline (Get_File); -- Extract column number or file name from reference function Get_File (Ref : Reference; With_Dir : Boolean := False) return String; pragma Inline (Get_File); function Get_File (File : File_Reference; With_Dir : Boolean := False; Strip : Natural := 0) return String; -- Returns the file name (and its directory if With_Dir is True or the user -- has used the -f switch on the command line. If Strip is not 0, then the -- last Strip-th "-..." substrings are removed first. For instance, with -- Strip=2, a file name "parent-child1-child2-child3.ali" would be returned -- as "parent-child1.ali". This is used when looking for the ALI file to -- use for a package, since for separates with have to use the parent's -- ALI. The null string is returned if there is no such parent unit. -- -- Note that this version of Get_File is not inlined function Get_File_Ref (Ref : Reference) return File_Reference; function Get_Line (Decl : Declaration_Reference) return String; function Get_Line (Ref : Reference) return String; function Get_Symbol (Decl : Declaration_Reference) return String; function Get_Type (Decl : Declaration_Reference) return Character; function Is_Parameter (Decl : Declaration_Reference) return Boolean; -- Functions that return the contents of a declaration function Get_Source_Line (Ref : Reference) return String; function Get_Source_Line (Decl : Declaration_Reference) return String; -- Return the source line associated with the reference procedure Grep_Source_Files; -- Parse all the source files which have at least one reference, and grep -- the appropriate source lines so that we'll be able to display them. This -- function should be called once all the .ali files have been parsed, and -- only if the appropriate user switch -- has been used (gnatfind -s). -- -- Note: To save memory, the strings for the source lines are shared. Thus -- it is no longer possible to free the references, or we would free the -- same chunk multiple times. It doesn't matter, though, since this is only -- called once, prior to exiting gnatfind. function Longest_File_Name return Natural; -- Returns the longest file name found function Match (Decl : Declaration_Reference) return Boolean; -- Return True if the declaration matches function Match (File : File_Reference; Line : Natural; Column : Natural) return Boolean; -- Returns True if File:Line:Column was given on the command line -- by the user function Next_Unvisited_File return File_Reference; -- Returns the next unvisited library file in the list If there is no more -- unvisited file, return Empty_File. Two calls to this subprogram will -- return different files. procedure Set_Default_Match (Value : Boolean); -- Set the default value for match in declarations. -- This is used so that if no file was provided in the -- command line, then every file match procedure Reset_Directory (File : File_Reference); -- Reset the cached directory for file. Next time Get_File is called, the -- directory will be recomputed. procedure Set_Unvisited (File_Ref : File_Reference); -- Set File_Ref as unvisited. So Next_Unvisited_File will return it procedure Read_File (File_Name : String; Contents : out GNAT.OS_Lib.String_Access); -- Reads File_Name into the newly allocated string Contents. Types.EOF -- character will be added to the returned Contents to simplify parsing. -- Name_Error is raised if the file was not found. End_Error is raised if -- the file could not be read correctly. For most systems correct reading -- means that the number of bytes read is equal to the file size. private type Project_File (Src_Dir_Length, Obj_Dir_Length : Natural) is record Src_Dir_Index : Integer; Obj_Dir_Index : Integer; Last_Obj_Dir_Start : Natural; Src_Dir : String (1 .. Src_Dir_Length); Obj_Dir : String (1 .. Obj_Dir_Length); end record; type Project_File_Ptr is access all Project_File; -- This is actually a list of all the directories to be searched, -- either for source files or for library files type Ref_In_File; type Ref_In_File_Ptr is access all Ref_In_File; type Ref_In_File is record Line : Natural; Column : Natural; Next : Ref_In_File_Ptr := null; end record; type File_Record; type File_Reference is access all File_Record; Empty_File : constant File_Reference := null; type Cst_String_Access is access constant String; procedure Free (Str : in out Cst_String_Access); type File_Record is record File : Cst_String_Access; Dir : GNAT.OS_Lib.String_Access; Lines : Ref_In_File_Ptr := null; Visited : Boolean := False; Emit_Warning : Boolean := False; Gnatchop_File : GNAT.OS_Lib.String_Access := null; Gnatchop_Offset : Integer := 0; Next : File_Reference := null; end record; -- Holds a reference to a source file, that was referenced in at least one -- ALI file. Gnatchop_File will contain the name of the file that File was -- extracted From. Gnatchop_Offset contains the index of the first line of -- File within Gnatchop_File. These two fields are used to properly support -- gnatchop files and pragma Source_Reference. -- -- Lines is used for files that were given on the command line, to -- memorize the lines and columns that the user specified. type Reference_Record; type Reference is access all Reference_Record; Empty_Reference : constant Reference := null; type Reference_Record is record File : File_Reference; Line : Natural; Column : Natural; Source_Line : Cst_String_Access; Next : Reference := null; end record; -- File is a reference to the Ada source file -- Source_Line is the Line as it appears in the source file. This -- field is only used when the switch is set on the command line of -- gnatfind. type Declaration_Record; type Declaration_Reference is access all Declaration_Record; Empty_Declaration : constant Declaration_Reference := null; type Declaration_Record (Symbol_Length : Natural) is record Key : Cst_String_Access; Decl : Reference; Is_Parameter : Boolean := False; -- True if entity is subprog param Decl_Type : Character; Body_Ref : Reference := null; Ref_Ref : Reference := null; Modif_Ref : Reference := null; Match : Boolean := False; Par_Symbol : Declaration_Reference := null; Next : Declaration_Reference := null; Symbol : String (1 .. Symbol_Length); end record; -- The lists of referenced (Body_Ref, Ref_Ref and Modif_Ref) are -- kept unsorted until the results needs to be printed. This saves -- lots of time while the internal tables are created. pragma Inline (Get_Column); pragma Inline (Get_Emit_Warning); pragma Inline (Get_File_Ref); pragma Inline (Get_Line); pragma Inline (Get_Symbol); pragma Inline (Get_Type); pragma Inline (Longest_File_Name); end Xr_Tabls;
LiberatorUSA/GUCEF
Ada
195
adb
package body agar.gui.widget.hsvpal is function widget (hsvpal : hsvpal_access_t) return widget_access_t is begin return hsvpal.widget'access; end widget; end agar.gui.widget.hsvpal;
AaronC98/PlaneSystem
Ada
2,973
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2013, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; function AWS.Hotplug.Get_Status (Filters : Filter_Set) return Templates_Parser.Translate_Set is use Templates_Parser; -- Avoid : may be referenced before it has a value Regexp : Vector_Tag with Warnings => Off; URL : Vector_Tag with Warnings => Off; Result : Translate_Set; begin for K in 1 .. Filter_Table.Length (Filters.Set) loop declare Item : constant Filter_Data := Filter_Table.Element (Filters.Set, Positive (K)); begin Regexp := Regexp & Item.Regexp_Str; URL := URL & Item.URL; end; end loop; Insert (Result, Assoc ("HP_REGEXP_V", Regexp)); Insert (Result, Assoc ("HP_URL_V", URL)); return Result; end AWS.Hotplug.Get_Status;
rogermc2/GA_Ada
Ada
5,089
adb
-- with Ada.Numerics; with Ada.Text_IO; use Ada.Text_IO; with GL.Buffers; with GL.Culling; with GL.Toggles; with GL.Objects.Programs; with GL.Objects.Vertex_Arrays; with GL.Types; with GL.Types.Colors; with Glfw; with Glfw.Input; with Glfw.Input.Keys; with GL.Window; with Glfw.Windows.Context; -- with Maths; with Program_Loader; with Utilities; with C3GA; with C3GA_Draw; with GA_Draw; with Multivectors; with Palet; with Points; with Shader_Manager; -- ------------------------------------------------------------------------ procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is Red : constant GL.Types.Singles.Vector4 := (1.0, 0.0, 0.0, 1.0); Green : constant GL.Types.Singles.Vector4 := (0.0, 0.5, 0.0, 1.0); Blue : constant GL.Types.Singles.Vector4 := (0.0, 0.0, 0.5, 1.0); Rendering_Program : GL.Objects.Programs.Program; Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object; procedure Test_Draw_Line is use GL.Types; use GL.Types.Singles; -- use Maths.Single_Math_Functions; use Multivectors; Back_Colour : constant GL.Types.Colors.Color := (0.7 , 0.7, 0.7, 1.0); Window_Width : Glfw.Size; Window_Height : Glfw.Size; -- View_Direction : Vector3; -- Right : Vector3; -- Up : Vector3; -- Half_Pi : constant Single := 0.5 * Ada.Numerics.Pi; -- Horizontal_Angle : constant Single := Ada.Numerics.Pi; -- Vertical_Angle : constant Single := 0.0; Point_Position : Normalized_Point := New_Normalized_Point; aLine : Multivectors.Line := New_MV_Line; MV_Matrix : constant Matrix4 := Identity4; Palet_Data : Palet.Colour_Palet; aPoint : constant C3GA.Vector_E3GA := (0.0 , 0.25, 0.0); -- 1.0 , 0.25, 0.0 Direction : constant C3GA.Vector_E3GA := (0.25 , 0.0, 0.0); -- 0.25 , 0.0, 0.0 -- aPoint : constant C3GA.Vector_E3GA := (0.0 , 0.0, -0.2); -- Direction : constant C3GA.Vector_E3GA := (0.1 , 0.1, 0.8); -- Weight : constant Float := 1.0; -- P1 : constant Normalized_Point := -- C3GA.Set_Normalized_Point (0.0 , 0.0, -0.2); -- P2 : constant Normalized_Point := -- C3GA.Set_Normalized_Point (0.9 , 0.9, -0.2); begin Main_Window.Get_Framebuffer_Size (Window_Width, Window_Height); -- View_Direction := (Cos (Vertical_Angle) * Sin (Horizontal_Angle), -- Sin (Vertical_Angle), -- Cos (Vertical_Angle) * Cos (Horizontal_Angle)); -- Right := (Sin (Horizontal_Angle - Half_Pi), 0.0, -- Cos (Horizontal_Angle - Half_Pi)); -- Up := Singles.Cross_Product (Right, Direction); GL.Window.Set_Viewport (0, 0, GL.Types.Int (Window_Width), GL.Types.Int (Window_Height)); Utilities.Clear_Background_Colour_And_Depth (Back_Colour); GL.Toggles.Enable (GL.Toggles.Depth_Test); GL.Toggles.Enable (GL.Toggles.Cull_Face); GL.Culling.Set_Cull_Face (GL.Culling.Back); -- GL.Objects.Programs.Use_Program (Rendering_Program); Shader_Manager.Set_Drawing_Colour (Red); Shader_Manager.Set_Ambient_Colour (Green); Shader_Manager.Set_Diffuse_Colour (BLue); for count in 1 .. Points.Num_Points loop Point_Position := Points.Normalized_Points (count); end loop; aLine := C3GA.Set_Line (Points.L1, Points.L2); -- aLine := C3GA.Set_Line (P1, P2); C3GA_Draw.Draw (Rendering_Program, MV_Matrix, aLine, Palet_Data); GA_Draw.Draw_Line (Rendering_Program, MV_Matrix, aPoint, Direction); exception when others => Put_Line ("An exceptiom occurred in Test_Draw_Line."); raise; end Test_Draw_Line; -- ---------------------------------------------------------------------------- procedure Setup_Graphic is begin Shader_Manager.Init (Rendering_Program); GL.Buffers.Set_Depth_Function (GL.Types.Less); Vertex_Array.Initialize_Id; Vertex_Array.Bind; -- Point size is set in the vertex shader -- GL.Toggles.Enable (GL.Toggles.Vertex_Program_Point_Size); end Setup_Graphic; -- ---------------------------------------------------------------------------- use Glfw.Input; Running : Boolean := True; begin Setup_Graphic; while Running loop Test_Draw_Line; Glfw.Windows.Context.Swap_Buffers (Main_Window'Access); Glfw.Input.Poll_Events; Running := Running and not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed); Running := Running and not Main_Window.Should_Close; end loop; exception when Program_Loader.Shader_Loading_Error => -- message was already written to stdout null; end Main_Loop;
docandrew/troodon
Ada
458
ads
private package GID.Decoding_TGA is -------------------- -- Image decoding -- -------------------- generic type Primary_color_range is mod <>; with procedure Set_X_Y (x, y: Natural); with procedure Put_Pixel ( red, green, blue : Primary_color_range; alpha : Primary_color_range ); with procedure Feedback (percents: Natural); -- procedure Load (image: in out Image_descriptor); end GID.Decoding_TGA;
AdaCore/gpr
Ada
1,601
adb
-- -- Copyright (C) 2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; use Ada.Text_IO; with GPR2.Context; with GPR2.Log; with GPR2.Path_Name; with GPR2.Project.Tree; procedure Main is Tree : GPR2.Project.Tree.Object; Context : GPR2.Context.Object; use GPR2; procedure Print_Messages is begin if Tree.Has_Messages then for C in Tree.Log_Messages.Iterate (False, True, True, False, True, True) loop Ada.Text_IO.Put_Line (GPR2.Log.Element (C).Format); end loop; end if; end Print_Messages; function Test (Project_Name : GPR2.Filename_Type) return String is begin Tree.Unload; Tree.Load_Autoconf (Filename => GPR2.Path_Name.Create_File (GPR2.Project.Ensure_Extension (Project_Name), GPR2.Path_Name.No_Resolution), Context => Context); return Tree.Root_Project.Variable ("Var").Value.Text; exception when Project_Error => Print_Messages; return ""; end Test; begin declare UTF8 : String := Test ("utf8.gpr"); CP1252 : String := Test ("cp1252.gpr"); begin -- check that Could not decode source as "UTF-8" reported when -- file is not using UTF-8 & CP-1252 encoding. Put (Test ("cp1252error.gpr")); if UTF8 = CP1252 then Put_Line ("OK"); else Put_Line ("utf8.gpr returned"); Put_Line (UTF8); Put_Line ("cp1252.gpr returned"); Put_Line (CP1252); end if; end; end Main;
zhmu/ananas
Ada
1,624
adb
-- The aim of this test is to check that Ada types appear in the proper -- context in the debug info. -- -- Checking this directly would be really tedious just scanning for assembly -- lines, so instead we rely on DWARFv4's .debug_types sections, which must be -- created only for global-scope types. Checking the number of .debug_types is -- some hackish way to check that types are output in the proper context (i.e. -- at global or local scope). -- -- { dg-skip-if "No dwarf-4 support" { hppa*-*-hpux* } } -- { dg-options "-cargs -gdwarf-4 -fdebug-types-section -dA -margs" } -- { dg-final { scan-assembler-times "\\(DIE \\(0x\[a-f0-9\]*\\) DW_TAG_type_unit\\)" 0 } } procedure Debug9 is type Array_Type is array (Natural range <>) of Integer; type Record_Type (L1, L2 : Natural) is record I1 : Integer; A1 : Array_Type (1 .. L1); I2 : Integer; A2 : Array_Type (1 .. L2); I3 : Integer; end record; function Get (L1, L2 : Natural) return Record_Type is Result : Record_Type (L1, L2); begin Result.I1 := 1; for I in Result.A1'Range loop Result.A1 (I) := I; end loop; Result.I2 := 2; for I in Result.A2'Range loop Result.A2 (I) := I; end loop; Result.I3 := 3; return Result; end Get; R1 : Record_Type := Get (0, 0); R2 : Record_Type := Get (1, 0); R3 : Record_Type := Get (0, 1); R4 : Record_Type := Get (2, 2); procedure Process (R : Record_Type) is begin null; end Process; begin Process (R1); Process (R2); Process (R3); Process (R4); end Debug9;
reznikmm/matreshka
Ada
4,361
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- File_System_Entry represents path and provides subprograms to parse/create -- paths and to convert them to native representation. ------------------------------------------------------------------------------ with League.String_Vectors; with League.Strings; package Matreshka.File_System_Entries is pragma Preelaborate; type File_System_Entry is record Segments : League.String_Vectors.Universal_String_Vector; Is_Absolute : Boolean := False; end record; function To_File_System_Entry (Path : League.Strings.Universal_String) return File_System_Entry; -- Creates File_System_Entry object from the specified path. Path can use -- native directory separator as well as internal one. function Path (Self : File_System_Entry) return League.Strings.Universal_String; -- Returns path using internal directory separator. function "=" (Left : File_System_Entry; Right : File_System_Entry) return Boolean is abstract; end Matreshka.File_System_Entries;
AdaDoom3/wayland_ada_binding
Ada
29,120
ads
with Dynamic_Pools; with Ada.Containers.Vectors; with Aida.Deepend_XML_DOM_Parser; with Conts.Vectors.Definite_Unbounded; package Wayland_XML is package Ac renames Ada.Containers; Default_Subpool : Dynamic_Pools.Dynamic_Pool renames Aida.Deepend_XML_DOM_Parser.Default_Subpool; type String_Ptr is access all String with Storage_Pool => Default_Subpool; Empty_String : aliased String := ""; type Version_Number is new Aida.Pos32_T; type Arg_Type_Attribute is (Type_Integer, Type_Unsigned_Integer, Type_String, Type_FD, Type_New_Id, Type_Object, Type_Fixed, Type_Array); TYPE_ATTRIBUTE_EXCEPTION : exception; type Arg_Tag is tagged limited private; procedure Set_Name (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Arg_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Arg_Tag) return Boolean with Global => null; -- raises TYPE_ATTRIBUTE_EXCEPTION if Value cannot be interpreted procedure Set_Type_Attribute (This : in out Arg_Tag; Value : String) with Global => null, Pre => not This.Exists_Type_Attribute, Post => This.Exists_Type_Attribute; function Type_Attribute (This : Arg_Tag) return Arg_Type_Attribute with Global => null, Pre => This.Exists_Type_Attribute; function Exists_Type_Attribute (This : Arg_Tag) return Boolean with Global => null; procedure Set_Interface_Attribute (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Interface_Attribute, Post => This.Exists_Interface_Attribute and This.Interface_Attribute = Value; function Interface_Attribute (This : Arg_Tag) return String with Global => null, Pre => This.Exists_Interface_Attribute; function Exists_Interface_Attribute (This : Arg_Tag) return Boolean with Global => null; procedure Set_Summary (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Summary, Post => This.Exists_Summary and This.Summary = Value; function Summary (This : Arg_Tag) return String with Global => null, Pre => This.Exists_Summary; function Exists_Summary (This : Arg_Tag) return Boolean with Global => null; procedure Set_Allow_Null (This : in out Arg_Tag; Value : Boolean) with Global => null, Pre => not This.Exists_Allow_Null, Post => This.Exists_Allow_Null and This.Allow_Null = Value; function Allow_Null (This : Arg_Tag) return Boolean with Global => null, Pre => This.Exists_Allow_Null; function Exists_Allow_Null (This : Arg_Tag) return Boolean with Global => null; procedure Set_Enum (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Enum, Post => This.Exists_Enum and This.Enum = Value; function Enum (This : Arg_Tag) return String with Global => null, Pre => This.Exists_Enum; function Exists_Enum (This : Arg_Tag) return Boolean with Global => null; type Arg_Tag_Ptr is access all Arg_Tag with Storage_Pool => Default_Subpool; type Copyright_Tag is tagged limited private; procedure Set_Text (This : in out Copyright_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Text, Post => This.Exists_Text and This.Text = Value; function Text (This : Copyright_Tag) return String with Global => null, Pre => This.Exists_Text; function Exists_Text (This : Copyright_Tag) return Boolean with Global => null; type Copyright_Ptr is access all Copyright_Tag with Storage_Pool => Default_Subpool; type Description_Tag is tagged limited private; procedure Set_Text (This : in out Description_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Text, Post => This.Exists_Text and This.Text = Value; function Text (This : Description_Tag) return String with Global => null, Pre => This.Exists_Text; function Exists_Text (This : Description_Tag) return Boolean with Global => null; procedure Set_Summary (This : in out Description_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Summary, Post => This.Exists_Summary and This.Summary = Value; function Summary (This : Description_Tag) return String with Global => null, Pre => This.Exists_Summary; function Exists_Summary (This : Description_Tag) return Boolean with Global => null; type Description_Tag_Ptr is access all Description_Tag with Storage_Pool => Default_Subpool; type Entry_Value is new Aida.Nat32_T; type Entry_Tag is tagged limited private; procedure Set_Name (This : in out Entry_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Entry_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Entry_Tag) return Boolean with Global => null; procedure Set_Summary (This : in out Entry_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Summary, Post => This.Exists_Summary and This.Summary = Value; function Summary (This : Entry_Tag) return String with Global => null, Pre => This.Exists_Summary; function Exists_Summary (This : Entry_Tag) return Boolean with Global => null; procedure Set_Value (This : in out Entry_Tag; Value : Entry_Value) with Global => null, Pre => not This.Exists_Value, Post => This.Exists_Value and This.Value = Value; function Value (This : Entry_Tag) return Entry_Value with Global => null, Pre => This.Exists_Value; function Value_As_String (This : Entry_Tag) return String with Global => null, Pre => This.Exists_Value; function Exists_Value (This : Entry_Tag) return Boolean with Global => null; procedure Set_Since (This : in out Entry_Tag; Value : Version_Number) with Global => null, Pre => not This.Exists_Since, Post => This.Exists_Since and This.Since = Value; function Since (This : Entry_Tag) return Version_Number with Global => null, Pre => This.Exists_Since; function Exists_Since (This : Entry_Tag) return Boolean with Global => null; type Entry_Tag_Ptr is access all Entry_Tag with Storage_Pool => Default_Subpool; type Enum_Child_Kind_Id is (Child_Dummy, Child_Description, Child_Entry); type Enum_Child (Kind_Id : Enum_Child_Kind_Id := Child_Dummy) is record case Kind_Id is when Child_Dummy => Dummy : not null String_Ptr := Empty_String'Access; when Child_Description => Description_Tag : not null Description_Tag_Ptr; when Child_Entry => Entry_Tag : not null Entry_Tag_Ptr; end case; end record; package Enum_Child_Vectors is new Ac.Vectors (Index_Type => Positive, Element_Type => Enum_Child, "=" => "="); type Enum_Children_Ref (E : not null access constant Enum_Child_Vectors.Vector) is limited null record with Implicit_Dereference => E; type Enum_Tag is tagged limited private; function Children (This : aliased Enum_Tag) return Enum_Children_Ref; procedure Append_Child (This : in out Enum_Tag; Item : not null Wayland_XML.Description_Tag_Ptr); procedure Append_Child (This : in out Enum_Tag; Item : not null Entry_Tag_Ptr); procedure Set_Name (This : in out Enum_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Enum_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Enum_Tag) return Boolean with Global => null; procedure Set_Bitfield (This : in out Enum_Tag; Value : Boolean) with Global => null, Pre => not This.Exists_Bitfield, Post => This.Exists_Bitfield and This.Bitfield = Value; function Bitfield (This : Enum_Tag) return Boolean with Global => null, Pre => This.Exists_Bitfield; function Exists_Bitfield (This : Enum_Tag) return Boolean with Global => null; procedure Set_Since (This : in out Enum_Tag; Value : Version_Number) with Global => null, Pre => not This.Exists_Since, Post => This.Exists_Since and This.Since = Value; function Since (This : Enum_Tag) return Version_Number with Global => null, Pre => This.Exists_Since; function Exists_Since (This : Enum_Tag) return Boolean with Global => null; type Enum_Tag_Ptr is access all Enum_Tag with Storage_Pool => Default_Subpool; type Event_Child_Kind_Id is (Child_Dummy, Child_Description, Child_Arg); type Event_Child (Kind_Id : Event_Child_Kind_Id := Child_Dummy) is record case Kind_Id is when Child_Dummy => Dummy : not null String_Ptr := Empty_String'Access; when Child_Description => Description_Tag : not null Description_Tag_Ptr; when Child_Arg => Arg_Tag : not null Arg_Tag_Ptr; end case; end record; package Event_Child_Vectors is new Ac.Vectors (Index_Type => Positive, Element_Type => Event_Child, "=" => "="); type Event_Children_Ref (E : not null access constant Event_Child_Vectors.Vector) is limited null record with Implicit_Dereference => E; type Event_Tag is tagged limited private; function Children (This : aliased Event_Tag) return Event_Children_Ref; procedure Append_Child (This : in out Event_Tag; Item : not null Description_Tag_Ptr); procedure Append_Child (This : in out Event_Tag; Item : not null Wayland_XML.Arg_Tag_Ptr); procedure Set_Name (This : in out Event_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Event_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Event_Tag) return Boolean with Global => null; procedure Set_Since_Attribute (This : in out Event_Tag; Value : Version_Number) with Global => null, Pre => not This.Exists_Since_Attribute, Post => This.Exists_Since_Attribute and This.Since_Attribute = Value; function Since_Attribute (This : Event_Tag) return Version_Number with Global => null, Pre => This.Exists_Since_Attribute; function Since_Attribute_As_Pos32 (This : Event_Tag) return Aida.Pos32_T with Global => null, Pre => This.Exists_Since_Attribute; function Exists_Since_Attribute (This : Event_Tag) return Boolean with Global => null; type Event_Tag_Ptr is access all Event_Tag with Storage_Pool => Default_Subpool; type Request_Child_Kind_Id is (Child_Dummy, Child_Description, Child_Arg); type Request_Child (Kind_Id : Request_Child_Kind_Id := Child_Dummy) is record case Kind_Id is when Child_Dummy => Dummy : not null String_Ptr := Empty_String'Access; when Child_Description => Description_Tag : not null Description_Tag_Ptr; when Child_Arg => Arg_Tag : not null Arg_Tag_Ptr; end case; end record; package Request_Child_Vectors is new Ac.Vectors (Index_Type => Aida.Pos32_T, Element_Type => Request_Child, "=" => "="); type Request_Children_Ref (E : not null access constant Request_Child_Vectors.Vector) is limited null record with Implicit_Dereference => E; type Request_Tag is tagged limited private; function Children (This : aliased Request_Tag) return Request_Children_Ref; procedure Append_Child (This : in out Request_Tag; Item : not null Description_Tag_Ptr); procedure Append_Child (This : in out Request_Tag; Item : not null Arg_Tag_Ptr); procedure Set_Name (This : in out Request_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre'Class => not This.Exists_Name, Post'Class => This.Exists_Name and This.Name = Value; function Name (This : Request_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Request_Tag) return Boolean with Global => null; procedure Set_Type_Attribute (This : in out Request_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Type_Attribute, Post => This.Exists_Type_Attribute and This.Type_Attribute = Value; function Type_Attribute (This : Request_Tag) return String with Global => null, Pre => This.Exists_Type_Attribute; function Exists_Type_Attribute (This : Request_Tag) return Boolean with Global => null; procedure Set_Since (This : in out Request_Tag; Value : Version_Number) with Global => null, Pre => not This.Exists_Since, Post => This.Exists_Since and This.Since = Value; function Since (This : Request_Tag) return Version_Number with Global => null, Pre => This.Exists_Since; function Since_As_Pos32 (This : Request_Tag) return Aida.Pos32_T with Global => null, Pre => This.Exists_Since; function Exists_Since (This : Request_Tag) return Boolean with Global => null; function Description (This : Request_Tag) return String with Global => null, Pre => This.Exists_Description; -- Returns true if there is one unique description. function Exists_Description (This : Request_Tag) return Boolean with Global => null; type Request_Tag_Ptr is access all Request_Tag with Storage_Pool => Default_Subpool; type Interface_Child_Kind_Id is (Child_Dummy, Child_Description, Child_Request, Child_Event, Child_Enum); type Interface_Child (Kind_Id : Interface_Child_Kind_Id := Child_Dummy) is record case Kind_Id is when Child_Dummy => Dummy : not null String_Ptr := Empty_String'Access; when Child_Description => Description_Tag : not null Description_Tag_Ptr; when Child_Request => Request_Tag : not null Request_Tag_Ptr; when Child_Event => Event_Tag : not null Event_Tag_Ptr; when Child_Enum => Enum_Tag : not null Enum_Tag_Ptr; end case; end record; package Interface_Child_Vectors is new Ac.Vectors (Index_Type => Positive, Element_Type => Interface_Child, "=" => "="); type Interface_Children_Ref (E : not null access constant Interface_Child_Vectors.Vector) is limited null record with Implicit_Dereference => E; type Interface_Tag is tagged limited private; procedure Set_Name (This : in out Interface_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Interface_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Interface_Tag) return Boolean with Global => null; procedure Set_Version (This : in out Interface_Tag; Value : Version_Number) with Global => null, Pre => not This.Exists_Version, Post => This.Exists_Version and This.Version = Value; function Version (This : Interface_Tag) return Version_Number with Global => null, Pre => This.Exists_Version; function Exists_Version (This : Interface_Tag) return Boolean with Global => null; function Children (This : aliased Interface_Tag) return Interface_Children_Ref; procedure Append_Child (This : in out Interface_Tag; Item : not null Description_Tag_Ptr); procedure Append_Child (This : in out Interface_Tag; Item : not null Request_Tag_Ptr); procedure Append_Child (This : in out Interface_Tag; Item : not null Event_Tag_Ptr); procedure Append_Child (This : in out Interface_Tag; Item : not null Enum_Tag_Ptr); type Interface_Tag_Ptr is access all Interface_Tag with Storage_Pool => Default_Subpool; type Protocol_Child_Kind_Id is (Child_Dummy, Child_Copyright, Child_Interface); type Protocol_Child (Kind_Id : Protocol_Child_Kind_Id := Child_Dummy) is record case Kind_Id is when Child_Dummy => Dummy : not null String_Ptr := Empty_String'Access; when Child_Copyright => Copyright_Tag : not null Copyright_Ptr; when Child_Interface => Interface_Tag : not null Interface_Tag_Ptr; end case; end record; package Protocol_Child_Vectors is new Ac.Vectors (Index_Type => Positive, Element_Type => Protocol_Child, "=" => "="); type Protocol_Children_Ref (E : not null access constant Protocol_Child_Vectors.Vector) is limited null record with Implicit_Dereference => E; type Protocol_Tag is tagged limited private; procedure Set_Name (This : in out Protocol_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) with Global => null, Pre => not This.Exists_Name, Post => This.Exists_Name and This.Name = Value; function Name (This : Protocol_Tag) return String with Global => null, Pre => This.Exists_Name; function Exists_Name (This : Protocol_Tag) return Boolean with Global => null; function Children (This : aliased Protocol_Tag) return Protocol_Children_Ref; procedure Append_Child (This : in out Protocol_Tag; Item : not null Copyright_Ptr); procedure Append_Child (This : in out Protocol_Tag; Item : not null Interface_Tag_Ptr); type Protocol_Tag_Ptr is access all Protocol_Tag with Storage_Pool => Default_Subpool; private type Nullable_String_Ptr (Exists : Boolean := False) is record case Exists is when True => Value : not null String_Ptr := Empty_String'Access; when False => null; end case; end record; type Nullable_Boolean (Exists : Boolean := False) is record case Exists is when True => Value : Boolean; when False => null; end case; end record; type Nullable_Version (Exists : Boolean := False) is record case Exists is when True => Value : Version_Number; when False => null; end case; end record; type Nullable_Allow_Null (Exists : Boolean := False) is record case Exists is when True => Value : Boolean; when False => null; end case; end record; type Nullable_Type_Attribute (Exists : Boolean := False) is record case Exists is when True => Value : Arg_Type_Attribute; when False => null; end case; end record; type Arg_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Type_Attribute : Nullable_Type_Attribute; My_Interface_Attribute : Nullable_String_Ptr; My_Summary : Nullable_String_Ptr; My_Allow_Null : Nullable_Allow_Null; My_Enum : Nullable_String_Ptr; end record; function Name (This : Arg_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Arg_Tag) return Boolean is (This.My_Name.Exists); function Type_Attribute (This : Arg_Tag) return Arg_Type_Attribute is (This.My_Type_Attribute.Value); function Exists_Type_Attribute (This : Arg_Tag) return Boolean is (This.My_Type_Attribute.Exists); function Interface_Attribute (This : Arg_Tag) return String is (This.My_Interface_Attribute.Value.all); function Exists_Interface_Attribute (This : Arg_Tag) return Boolean is (This.My_Interface_Attribute.Exists); function Summary (This : Arg_Tag) return String is (This.My_Summary.Value.all); function Exists_Summary (This : Arg_Tag) return Boolean is (This.My_Summary.Exists); function Allow_Null (This : Arg_Tag) return Boolean is (This.My_Allow_Null.Value); function Exists_Allow_Null (This : Arg_Tag) return Boolean is (This.My_Allow_Null.Exists); function Enum (This : Arg_Tag) return String is (This.My_Enum.Value.all); function Exists_Enum (This : Arg_Tag) return Boolean is (This.My_Enum.Exists); type Copyright_Tag is tagged limited record My_Text : Nullable_String_Ptr; end record; function Text (This : Copyright_Tag) return String is (This.My_Text.Value.all); function Exists_Text (This : Copyright_Tag) return Boolean is (This.My_Text.Exists); type Description_Tag is tagged limited record My_Text : Nullable_String_Ptr; My_Summary : Nullable_String_Ptr; end record; function Text (This : Description_Tag) return String is (This.My_Text.Value.all); function Exists_Text (This : Description_Tag) return Boolean is (This.My_Text.Exists); function Summary (This : Description_Tag) return String is (This.My_Summary.Value.all); function Exists_Summary (This : Description_Tag) return Boolean is (This.My_Summary.Exists); type Nullable_Entry_Value (Exists : Boolean := False) is record case Exists is when True => Value : Entry_Value; when False => null; end case; end record; type Entry_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Value : Nullable_Entry_Value; My_Summary : Nullable_String_Ptr; My_Since : Nullable_Version; end record; function Name (This : Entry_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Entry_Tag) return Boolean is (This.My_Name.Exists); function Value (This : Entry_Tag) return Entry_Value is (This.My_Value.Value); function Value_As_String (This : Entry_Tag) return String is (Aida.Int32.To_String (Aida.Nat32_T (This.My_Value.Value))); function Exists_Value (This : Entry_Tag) return Boolean is (This.My_Value.Exists); function Summary (This : Entry_Tag) return String is (This.My_Summary.Value.all); function Exists_Summary (This : Entry_Tag) return Boolean is (This.My_Summary.Exists); function Since (This : Entry_Tag) return Version_Number is (This.My_Since.Value); function Exists_Since (This : Entry_Tag) return Boolean is (This.My_Since.Exists); type Enum_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Bitfield : Nullable_Boolean; My_Since : Nullable_Version; My_Children : aliased Enum_Child_Vectors.Vector; end record; function Name (This : Enum_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Enum_Tag) return Boolean is (This.My_Name.Exists); function Bitfield (This : Enum_Tag) return Boolean is (This.My_Bitfield.Value); function Exists_Bitfield (This : Enum_Tag) return Boolean is (This.My_Bitfield.Exists); function Since (This : Enum_Tag) return Version_Number is (This.My_Since.Value); function Exists_Since (This : Enum_Tag) return Boolean is (This.My_Since.Exists); function Children (This : aliased Enum_Tag) return Enum_Children_Ref is ((E => This.My_Children'Access)); type Nullable_Since_Attribute (Exists : Boolean := False) is record case Exists is when True => Value : Version_Number; when False => null; end case; end record; type Event_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Since_Attribute : Nullable_Since_Attribute; My_Children : aliased Event_Child_Vectors.Vector; end record; function Name (This : Event_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Event_Tag) return Boolean is (This.My_Name.Exists); function Since_Attribute (This : Event_Tag) return Version_Number is (This.My_Since_Attribute.Value); function Since_Attribute_As_Pos32 (This : Event_Tag) return Aida.Pos32_T is (Aida.Pos32_T (This.My_Since_Attribute.Value)); function Exists_Since_Attribute (This : Event_Tag) return Boolean is (This.My_Since_Attribute.Exists); function Children (This : aliased Event_Tag) return Event_Children_Ref is ((E => This.My_Children'Access)); type Nullable_Since_T (Exists : Boolean := False) is record case Exists is when True => Value : Version_Number; when False => null; end case; end record; type Request_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Children : aliased Request_Child_Vectors.Vector; My_Type_Attribute : Nullable_String_Ptr; My_Since : Nullable_Since_T; end record; function Name (This : Request_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Request_Tag) return Boolean is (This.My_Name.Exists); function Children (This : aliased Request_Tag) return Request_Children_Ref is ((E => This.My_Children'Access)); function Type_Attribute (This : Request_Tag) return String is (This.My_Type_Attribute.Value.all); function Exists_Type_Attribute (This : Request_Tag) return Boolean is (This.My_Type_Attribute.Exists); function Since (This : Request_Tag) return Version_Number is (This.My_Since.Value); function Since_As_Pos32 (This : Request_Tag) return Aida.Pos32_T is (Aida.Pos32_T (This.My_Since.Value)); function Exists_Since (This : Request_Tag) return Boolean is (This.My_Since.Exists); type Interface_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Version : Nullable_Version; My_Children : aliased Interface_Child_Vectors.Vector; end record; function Name (This : Interface_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Interface_Tag) return Boolean is (This.My_Name.Exists); function Version (This : Interface_Tag) return Version_Number is (This.My_Version.Value); function Exists_Version (This : Interface_Tag) return Boolean is (This.My_Version.Exists); function Children (This : aliased Interface_Tag) return Interface_Children_Ref is ((E => This.My_Children'Access)); type Protocol_Tag is tagged limited record My_Name : Nullable_String_Ptr; My_Children : aliased Protocol_Child_Vectors.Vector; end record; function Name (This : Protocol_Tag) return String is (This.My_Name.Value.all); function Exists_Name (This : Protocol_Tag) return Boolean is (This.My_Name.Exists); function Children (This : aliased Protocol_Tag) return Protocol_Children_Ref is ((E => This.My_Children'Access)); end Wayland_XML;
gitter-badger/libAnne
Ada
1,920
ads
package Generics.Mathematics.Angles with Pure is --@Description Provides generic functions for Mathematics.Angles --@Version 1.0 generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "+"(Left, Right : Angle_Type) return Angle_Type is <>; function Add_Unit_Unit(Left : Unit_Type; Right : Unit_Type) return Angle_Type; generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "+"(Left, Right : Angle_Type) return Angle_Type is <>; function Add_Unit_Angle(Left : Unit_Type; Right : Angle_Type) return Angle_Type; generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "+"(Left, Right : Angle_Type) return Angle_Type is <>; function Add_Angle_Unit(Left : Angle_Type; Right : Unit_Type) return Angle_Type; generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "-"(Left, Right : Angle_Type) return Angle_Type is <>; function Subtract_Unit_Unit(Left : Unit_Type; Right : Unit_Type) return Angle_Type; generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "-"(Left, Right : Angle_Type) return Angle_Type is <>; function Subtract_Unit_Angle(Left : Unit_Type; Right : Angle_Type) return Angle_Type; generic type Unit_Type is private; type Angle_Type is private; with function To_Angle(Value : Unit_Type) return Angle_Type is <>; with function "-"(Left, Right : Angle_Type) return Angle_Type is <>; function Subtract_Angle_Unit(Left : Angle_Type; Right : Unit_Type) return Angle_Type; end Generics.Mathematics.Angles;
charlie5/cBound
Ada
1,495
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_render_color_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_color_iterator_t is -- Item -- type Item is record data : access xcb.xcb_render_color_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_color_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_color_iterator_t.Item, Element_Array => xcb.xcb_render_color_iterator_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_color_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_color_iterator_t.Pointer, Element_Array => xcb.xcb_render_color_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_color_iterator_t;
faelys/natools
Ada
1,631
ads
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Static_Maps.S_Expressions.Conditionals is a common parent to -- -- generated static hash maps related to S-expression conditionals system. -- ------------------------------------------------------------------------------ package Natools.Static_Maps.S_Expressions.Conditionals is pragma Pure; end Natools.Static_Maps.S_Expressions.Conditionals;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
18,219
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.SYSCFG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CFGR1_MEM_MODE_Field is STM32_SVD.UInt2; subtype CFGR1_BOOT_MODE_Field is STM32_SVD.UInt2; -- SYSCFG configuration register 1 type CFGR1_Register is record -- Memory mapping selection bits MEM_MODE : CFGR1_MEM_MODE_Field := 16#0#; -- unspecified Reserved_2_7 : STM32_SVD.UInt6 := 16#0#; -- Read-only. Boot mode selected by the boot pins status bits BOOT_MODE : CFGR1_BOOT_MODE_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR1_Register use record MEM_MODE at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; BOOT_MODE at 0 range 8 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype CFGR2_FWDISEN_Field is STM32_SVD.Bit; subtype CFGR2_CAPA_Field is STM32_SVD.UInt3; subtype CFGR2_I2C_PB6_FMP_Field is STM32_SVD.Bit; subtype CFGR2_I2C_PB7_FMP_Field is STM32_SVD.Bit; subtype CFGR2_I2C_PB8_FMP_Field is STM32_SVD.Bit; subtype CFGR2_I2C_PB9_FMP_Field is STM32_SVD.Bit; subtype CFGR2_I2C1_FMP_Field is STM32_SVD.Bit; subtype CFGR2_I2C2_FMP_Field is STM32_SVD.Bit; -- SYSCFG configuration register 2 type CFGR2_Register is record -- Firewall disable bit FWDISEN : CFGR2_FWDISEN_Field := 16#0#; -- Configuration of internal VLCD rail connection to optional external -- capacitor CAPA : CFGR2_CAPA_Field := 16#0#; -- unspecified Reserved_4_7 : STM32_SVD.UInt4 := 16#0#; -- Fm+ drive capability on PB6 enable bit I2C_PB6_FMP : CFGR2_I2C_PB6_FMP_Field := 16#0#; -- Fm+ drive capability on PB7 enable bit I2C_PB7_FMP : CFGR2_I2C_PB7_FMP_Field := 16#0#; -- Fm+ drive capability on PB8 enable bit I2C_PB8_FMP : CFGR2_I2C_PB8_FMP_Field := 16#0#; -- Fm+ drive capability on PB9 enable bit I2C_PB9_FMP : CFGR2_I2C_PB9_FMP_Field := 16#0#; -- I2C1 Fm+ drive capability enable bit I2C1_FMP : CFGR2_I2C1_FMP_Field := 16#0#; -- I2C2 Fm+ drive capability enable bit I2C2_FMP : CFGR2_I2C2_FMP_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR2_Register use record FWDISEN at 0 range 0 .. 0; CAPA at 0 range 1 .. 3; Reserved_4_7 at 0 range 4 .. 7; I2C_PB6_FMP at 0 range 8 .. 8; I2C_PB7_FMP at 0 range 9 .. 9; I2C_PB8_FMP at 0 range 10 .. 10; I2C_PB9_FMP at 0 range 11 .. 11; I2C1_FMP at 0 range 12 .. 12; I2C2_FMP at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- EXTICR1_EXTI array element subtype EXTICR1_EXTI_Element is STM32_SVD.UInt4; -- EXTICR1_EXTI array type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR1_EXTI type EXTICR1_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : STM32_SVD.UInt16; when True => -- EXTI as an array Arr : EXTICR1_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR1_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 1 type EXTICR1_Register is record -- EXTI x configuration (x = 0 to 3) EXTI : EXTICR1_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EXTICR1_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR2_EXTI array element subtype EXTICR2_EXTI_Element is STM32_SVD.UInt4; -- EXTICR2_EXTI array type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR2_EXTI type EXTICR2_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : STM32_SVD.UInt16; when True => -- EXTI as an array Arr : EXTICR2_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR2_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 2 type EXTICR2_Register is record -- EXTI x configuration (x = 4 to 7) EXTI : EXTICR2_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EXTICR2_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR3_EXTI array element subtype EXTICR3_EXTI_Element is STM32_SVD.UInt4; -- EXTICR3_EXTI array type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR3_EXTI type EXTICR3_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : STM32_SVD.UInt16; when True => -- EXTI as an array Arr : EXTICR3_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR3_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 3 type EXTICR3_Register is record -- EXTI x configuration (x = 8 to 11) EXTI : EXTICR3_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EXTICR3_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR4_EXTI array element subtype EXTICR4_EXTI_Element is STM32_SVD.UInt4; -- EXTICR4_EXTI array type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR4_EXTI type EXTICR4_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : STM32_SVD.UInt16; when True => -- EXTI as an array Arr : EXTICR4_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR4_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 4 type EXTICR4_Register is record -- EXTI12 EXTI : EXTICR4_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EXTICR4_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype COMP1_CTRL_COMP1EN_Field is STM32_SVD.Bit; subtype COMP1_CTRL_COMP1INNSEL_Field is STM32_SVD.UInt2; subtype COMP1_CTRL_COMP1WM_Field is STM32_SVD.Bit; subtype COMP1_CTRL_COMP1LPTIMIN1_Field is STM32_SVD.Bit; subtype COMP1_CTRL_COMP1POLARITY_Field is STM32_SVD.Bit; subtype COMP1_CTRL_COMP1VALUE_Field is STM32_SVD.Bit; subtype COMP1_CTRL_COMP1LOCK_Field is STM32_SVD.Bit; -- Comparator 1 control and status register type COMP1_CTRL_Register is record -- Comparator 1 enable bit COMP1EN : COMP1_CTRL_COMP1EN_Field := 16#0#; -- unspecified Reserved_1_3 : STM32_SVD.UInt3 := 16#0#; -- Comparator 1 Input Minus connection configuration bit COMP1INNSEL : COMP1_CTRL_COMP1INNSEL_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Comparator 1 window mode selection bit COMP1WM : COMP1_CTRL_COMP1WM_Field := 16#0#; -- unspecified Reserved_9_11 : STM32_SVD.UInt3 := 16#0#; -- Comparator 1 LPTIM input propagation bit COMP1LPTIMIN1 : COMP1_CTRL_COMP1LPTIMIN1_Field := 16#0#; -- unspecified Reserved_13_14 : STM32_SVD.UInt2 := 16#0#; -- Comparator 1 polarity selection bit COMP1POLARITY : COMP1_CTRL_COMP1POLARITY_Field := 16#0#; -- unspecified Reserved_16_29 : STM32_SVD.UInt14 := 16#0#; -- Comparator 1 output status bit COMP1VALUE : COMP1_CTRL_COMP1VALUE_Field := 16#0#; -- COMP1_CSR register lock bit COMP1LOCK : COMP1_CTRL_COMP1LOCK_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for COMP1_CTRL_Register use record COMP1EN at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; COMP1INNSEL at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; COMP1WM at 0 range 8 .. 8; Reserved_9_11 at 0 range 9 .. 11; COMP1LPTIMIN1 at 0 range 12 .. 12; Reserved_13_14 at 0 range 13 .. 14; COMP1POLARITY at 0 range 15 .. 15; Reserved_16_29 at 0 range 16 .. 29; COMP1VALUE at 0 range 30 .. 30; COMP1LOCK at 0 range 31 .. 31; end record; subtype COMP2_CTRL_COMP2EN_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2SPEED_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2INNSEL_Field is STM32_SVD.UInt3; subtype COMP2_CTRL_COMP2INPSEL_Field is STM32_SVD.UInt3; subtype COMP2_CTRL_COMP2LPTIMIN2_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2LPTIMIN1_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2POLARITY_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2VALUE_Field is STM32_SVD.Bit; subtype COMP2_CTRL_COMP2LOCK_Field is STM32_SVD.Bit; -- Comparator 2 control and status register type COMP2_CTRL_Register is record -- Comparator 2 enable bit COMP2EN : COMP2_CTRL_COMP2EN_Field := 16#0#; -- unspecified Reserved_1_2 : STM32_SVD.UInt2 := 16#0#; -- Comparator 2 power mode selection bit COMP2SPEED : COMP2_CTRL_COMP2SPEED_Field := 16#0#; -- Comparator 2 Input Minus connection configuration bit COMP2INNSEL : COMP2_CTRL_COMP2INNSEL_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Comparator 2 Input Plus connection configuration bit COMP2INPSEL : COMP2_CTRL_COMP2INPSEL_Field := 16#0#; -- unspecified Reserved_11_11 : STM32_SVD.Bit := 16#0#; -- Comparator 2 LPTIM input 2 propagation bit COMP2LPTIMIN2 : COMP2_CTRL_COMP2LPTIMIN2_Field := 16#0#; -- Comparator 2 LPTIM input 1 propagation bit COMP2LPTIMIN1 : COMP2_CTRL_COMP2LPTIMIN1_Field := 16#0#; -- unspecified Reserved_14_14 : STM32_SVD.Bit := 16#0#; -- Comparator 2 polarity selection bit COMP2POLARITY : COMP2_CTRL_COMP2POLARITY_Field := 16#0#; -- unspecified Reserved_16_29 : STM32_SVD.UInt14 := 16#0#; -- Comparator 2 output status bit COMP2VALUE : COMP2_CTRL_COMP2VALUE_Field := 16#0#; -- COMP2_CSR register lock bit COMP2LOCK : COMP2_CTRL_COMP2LOCK_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for COMP2_CTRL_Register use record COMP2EN at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; COMP2SPEED at 0 range 3 .. 3; COMP2INNSEL at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; COMP2INPSEL at 0 range 8 .. 10; Reserved_11_11 at 0 range 11 .. 11; COMP2LPTIMIN2 at 0 range 12 .. 12; COMP2LPTIMIN1 at 0 range 13 .. 13; Reserved_14_14 at 0 range 14 .. 14; COMP2POLARITY at 0 range 15 .. 15; Reserved_16_29 at 0 range 16 .. 29; COMP2VALUE at 0 range 30 .. 30; COMP2LOCK at 0 range 31 .. 31; end record; subtype CFGR3_EN_BGAP_Field is STM32_SVD.Bit; subtype CFGR3_SEL_VREF_OUT_Field is STM32_SVD.UInt2; subtype CFGR3_ENBUF_BGAP_ADC_Field is STM32_SVD.Bit; subtype CFGR3_ENBUF_SENSOR_ADC_Field is STM32_SVD.Bit; subtype CFGR3_ENBUF_VREFINT_COMP_Field is STM32_SVD.Bit; subtype CFGR3_ENREF_RC48MHz_Field is STM32_SVD.Bit; subtype CFGR3_REF_RC48MHz_RDYF_Field is STM32_SVD.Bit; subtype CFGR3_SENSOR_ADC_RDYF_Field is STM32_SVD.Bit; subtype CFGR3_VREFINT_ADC_RDYF_Field is STM32_SVD.Bit; subtype CFGR3_VREFINT_COMP_RDYF_Field is STM32_SVD.Bit; subtype CFGR3_VREFINT_RDYF_Field is STM32_SVD.Bit; subtype CFGR3_REF_LOCK_Field is STM32_SVD.Bit; -- SYSCFG configuration register 3 type CFGR3_Register is record -- Vref Enable bit EN_BGAP : CFGR3_EN_BGAP_Field := 16#0#; -- unspecified Reserved_1_3 : STM32_SVD.UInt3 := 16#0#; -- BGAP_ADC connection bit SEL_VREF_OUT : CFGR3_SEL_VREF_OUT_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- VREFINT reference for ADC enable bit ENBUF_BGAP_ADC : CFGR3_ENBUF_BGAP_ADC_Field := 16#0#; -- Sensor reference for ADC enable bit ENBUF_SENSOR_ADC : CFGR3_ENBUF_SENSOR_ADC_Field := 16#0#; -- unspecified Reserved_10_11 : STM32_SVD.UInt2 := 16#0#; -- VREFINT reference for comparator 2 enable bit ENBUF_VREFINT_COMP : CFGR3_ENBUF_VREFINT_COMP_Field := 16#0#; -- VREFINT reference for 48 MHz RC oscillator enable bit ENREF_RC48MHz : CFGR3_ENREF_RC48MHz_Field := 16#0#; -- unspecified Reserved_14_25 : STM32_SVD.UInt12 := 16#0#; -- Read-only. VREFINT for 48 MHz RC oscillator ready flag REF_RC48MHz_RDYF : CFGR3_REF_RC48MHz_RDYF_Field := 16#0#; -- Read-only. Sensor for ADC ready flag SENSOR_ADC_RDYF : CFGR3_SENSOR_ADC_RDYF_Field := 16#0#; -- Read-only. VREFINT for ADC ready flag VREFINT_ADC_RDYF : CFGR3_VREFINT_ADC_RDYF_Field := 16#0#; -- Read-only. VREFINT for comparator ready flag VREFINT_COMP_RDYF : CFGR3_VREFINT_COMP_RDYF_Field := 16#0#; -- Read-only. VREFINT ready flag VREFINT_RDYF : CFGR3_VREFINT_RDYF_Field := 16#0#; -- Write-only. REF_CTRL lock bit REF_LOCK : CFGR3_REF_LOCK_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR3_Register use record EN_BGAP at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; SEL_VREF_OUT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; ENBUF_BGAP_ADC at 0 range 8 .. 8; ENBUF_SENSOR_ADC at 0 range 9 .. 9; Reserved_10_11 at 0 range 10 .. 11; ENBUF_VREFINT_COMP at 0 range 12 .. 12; ENREF_RC48MHz at 0 range 13 .. 13; Reserved_14_25 at 0 range 14 .. 25; REF_RC48MHz_RDYF at 0 range 26 .. 26; SENSOR_ADC_RDYF at 0 range 27 .. 27; VREFINT_ADC_RDYF at 0 range 28 .. 28; VREFINT_COMP_RDYF at 0 range 29 .. 29; VREFINT_RDYF at 0 range 30 .. 30; REF_LOCK at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- System configuration controller and COMP register type SYSCFG_COMP_Peripheral is record -- SYSCFG configuration register 1 CFGR1 : aliased CFGR1_Register; -- SYSCFG configuration register 2 CFGR2 : aliased CFGR2_Register; -- external interrupt configuration register 1 EXTICR1 : aliased EXTICR1_Register; -- external interrupt configuration register 2 EXTICR2 : aliased EXTICR2_Register; -- external interrupt configuration register 3 EXTICR3 : aliased EXTICR3_Register; -- external interrupt configuration register 4 EXTICR4 : aliased EXTICR4_Register; -- Comparator 1 control and status register COMP1_CTRL : aliased COMP1_CTRL_Register; -- Comparator 2 control and status register COMP2_CTRL : aliased COMP2_CTRL_Register; -- SYSCFG configuration register 3 CFGR3 : aliased CFGR3_Register; end record with Volatile; for SYSCFG_COMP_Peripheral use record CFGR1 at 16#0# range 0 .. 31; CFGR2 at 16#4# range 0 .. 31; EXTICR1 at 16#8# range 0 .. 31; EXTICR2 at 16#C# range 0 .. 31; EXTICR3 at 16#10# range 0 .. 31; EXTICR4 at 16#14# range 0 .. 31; COMP1_CTRL at 16#18# range 0 .. 31; COMP2_CTRL at 16#1C# range 0 .. 31; CFGR3 at 16#20# range 0 .. 31; end record; -- System configuration controller and COMP register SYSCFG_COMP_Periph : aliased SYSCFG_COMP_Peripheral with Import, Address => SYSCFG_COMP_Base; end STM32_SVD.SYSCFG;
reznikmm/matreshka
Ada
11,868
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.CMOF.Associations; with AMF.CMOF.Classes; with AMF.CMOF.Comments; with AMF.CMOF.Constraints; with AMF.CMOF.Data_Types; with AMF.CMOF.Element_Imports; with AMF.CMOF.Enumeration_Literals; with AMF.CMOF.Enumerations; with AMF.CMOF.Expressions; with AMF.CMOF.Opaque_Expressions; with AMF.CMOF.Operations; with AMF.CMOF.Package_Imports; with AMF.CMOF.Package_Merges; with AMF.CMOF.Packages; with AMF.CMOF.Parameters; with AMF.CMOF.Primitive_Types; with AMF.CMOF.Properties; with AMF.CMOF.Tags; package AMF.Visitors.CMOF_Visitors is pragma Preelaborate; type CMOF_Visitor is limited interface and AMF.Visitors.Abstract_Visitor; not overriding procedure Enter_Association (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Associations.CMOF_Association_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Association (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Associations.CMOF_Association_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Class (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Classes.CMOF_Class_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Class (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Classes.CMOF_Class_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Comment (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Comments.CMOF_Comment_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Comment (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Comments.CMOF_Comment_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Constraint (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Constraints.CMOF_Constraint_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Constraint (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Constraints.CMOF_Constraint_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Data_Type (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Data_Types.CMOF_Data_Type_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Data_Type (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Data_Types.CMOF_Data_Type_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Element_Import (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Element_Imports.CMOF_Element_Import_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Element_Import (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Element_Imports.CMOF_Element_Import_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Enumeration (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Enumerations.CMOF_Enumeration_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Enumeration (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Enumerations.CMOF_Enumeration_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Enumeration_Literal (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Enumeration_Literal (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Expression (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Expressions.CMOF_Expression_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Expression (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Expressions.CMOF_Expression_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Opaque_Expression (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Opaque_Expression (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Operation (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Operations.CMOF_Operation_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Operation (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Operations.CMOF_Operation_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Package (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Packages.CMOF_Package_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Package (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Packages.CMOF_Package_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Package_Import (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Package_Imports.CMOF_Package_Import_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Package_Import (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Package_Imports.CMOF_Package_Import_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Package_Merge (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Package_Merge (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Parameter (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Parameters.CMOF_Parameter_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Parameter (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Parameters.CMOF_Parameter_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Primitive_Type (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Primitive_Type (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Property (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Properties.CMOF_Property_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Property (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Properties.CMOF_Property_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Enter_Tag (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Tags.CMOF_Tag_Access; Control : in out AMF.Visitors.Traverse_Control) is null; not overriding procedure Leave_Tag (Self : in out CMOF_Visitor; Element : not null AMF.CMOF.Tags.CMOF_Tag_Access; Control : in out AMF.Visitors.Traverse_Control) is null; end AMF.Visitors.CMOF_Visitors;
stcarrez/dynamo
Ada
68,389
ads
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT INTERFACE COMPONENTS -- -- -- -- A S I S . D A T A _ D E C O M P O S I T I O N -- -- -- -- S p e c -- -- -- -- Copyright (c) 1995-2006, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Semantic Interface -- -- Specification Standard (ISO/IEC 15291) for use with GNAT. The copyright -- -- notice above, and the license provisions that follow apply solely to the -- -- contents of the part following the private keyword. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 22 package Asis.Data_Decomposition (optional) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Repinfo; use Repinfo; package Asis.Data_Decomposition is ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Asis.Data_Decomposition -- -- This package is optional. -- -- Operations to decompose data values using the ASIS type information and a -- Portable_Data stream, representing a data value of that type. -- -- An application can write data, using the -- Asis.Data_Decomposition.Portable_Transfer package to an external medium -- for later retrieval by another application. The second application reads -- that data and then uses this package to convert that data into useful -- information. Simple discrete scalar types can be converted directly into -- useful information. Composite types, such as records and arrays, -- shall first be broken into their various discriminants and components. -- -- A data stream representing a record value can be decomposed into a group -- of discriminant and component data streams by extracting those streams -- from the record's data stream. This extraction is performed by applying -- any of the Record_Components which describe the discriminants and -- components of the record type. Each discriminant and each component of a -- record type is described by a Record_Component value. Each value -- encapsulates the information needed, by the implementation, to efficiently -- extract the associated field from a data stream representing a record -- value of the correct type. -- -- A data stream representing an array value can be decomposed into a group -- of component data streams by extracting those streams from the array's -- data stream. This extraction is performed by applying the single -- Array_Component which describes the components of the array type. One -- Array_Component value is used to describe all array components. The value -- encapsulates the information needed, by the implementation, to efficiently -- extract any of the array components. -- -- Assumptions and Limitations of this Interface: -- -- a) The data stream is appropriate for the ASIS host machine. For example, -- the implementation of this interface will not need to worry about -- byte flipping or reordering of bits caused by movement of data between -- machine architectures. -- -- b) Records, arrays, and their components may be packed. -- -- c) Records, array components, enumerations, and scalar types may have -- representation and length clauses applied to them. This includes scalar -- types used as record discriminants and array indices. -- -- d) This specification supports two of the three type models discussed -- below. Models A and B are supported. Model C is not supported. -- -- 1) Simple "static" types contain no variants, have a single fixed 'Size, -- and all components and attributes are themselves static and/or fully -- constrained. The size and position for any component of the type -- can be determined without regard to constraints. For example: -- -- type Static_Record is -- record -- F1, F2 : Natural; -- C1 : Wide_Character; -- A1 : Wide_String (1..5); -- end record; -- -- type Static_Discriminated (X : Boolean) is -- record -- F1, F2 : Natural; -- C1 : Wide_Character; -- end record; -- -- type Static_Array is array (Integer range 1 .. 100) of Boolean; -- type Static_Enum is (One, Two, Three); -- type Static_Integer is range 1 .. 512; -- type Static_Float is digits 15 range -100.0 .. 100.0; -- type Static_Fixed is delta 0.1 range -100.0 .. 100.0; -- -- 2) Simple "dynamic" types contain one or more components or attributes -- whose size, position, or value depends on the value of one or more -- constraints computed at execution time. This means that the size, -- position, or number of components within the data type cannot be -- determined without reference to constraint values. -- -- Records containing components, whose size depends on discriminants -- of the record, can be handled because the discriminants for a record -- value are fully specified by the data stream form of the record -- value. For example: -- -- type Dynamic_Length (Length : Natural) is -- record -- S1 : Wide_String (1 .. Length); -- end record; -- -- type Dynamic_Variant (When : Boolean) is -- record -- case When is -- when True => -- C1 : Wide_Character; -- when False => -- null; -- end case; -- end record; -- -- Arrays with an unconstrained subtype, whose 'Length, 'First, and -- 'Last depend on dynamic index constraints, can be handled because -- these attributes can be queried and stored when the data stream is -- written. For example: -- -- I : Integer := Some_Function; -- type Dynamic_Array is -- array (Integer range I .. I + 10) of Boolean; -- -- type Heap_Array is array (Integer range <>) of Boolean; -- type Access_Array is access Heap_Array; -- X : Access_Array := new Heap_Array (1 .. 100); -- -- 3) Complex, externally "discriminated" records, contain one or more -- components whose size or position depends on the value of one or -- more non-static external values (values not stored within instances -- of the type) at execution time. The size for a value of the type -- cannot be determined without reference to these external values, -- whose runtime values are not known to the ASIS Context and cannot be -- automatically recorded by the -- Asis.Data_Decomposition.Portable_Transfer generics. For example: -- -- N : Natural := Function_Call(); -- .... -- declare -- type Complex is -- record -- S1 : Wide_String (1 .. N); -- end record; -- begin -- .... -- end; -- -- -- General Usage Rules: -- -- All operations in this package will attempt to detect the use of invalid -- data streams. A data stream is "invalid" if an operation determines that -- the stream could not possibly represent a value of the expected variety. -- Possible errors are: stream is of incorrect length, stream contains bit -- patterns which are illegal, etc. The exception ASIS_Inappropriate_Element -- is raised in these cases. The Status value is Data_Error. The -- Diagnosis string will indicate the kind of error detected. -- -- All implementations will handle arrays with a minimum of 16 dimensions, -- or the number of dimensions allowed by their compiler, whichever is -- smaller. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 22.1 type Record_Component ------------------------------------------------------------------------------ -- Record_Component -- -- Describes one discriminant or component of a record type. Implementation -- is highly implementation dependent. The "=" operator is not meaningful -- between Record_Component values unless one of them is the -- Nil_Record_Component value. -- -- A record type describes composite values which contain zero or more -- discriminant and component fields. A_Record_Type_Definition can be -- queried to obtain a list of Record_Components. Each Record_Component -- contains the information necessary to extract one discriminant or -- component field of the record. -- -- Record_Components are intended for use with data stream extraction -- operations. An extraction operation is performed using a Record_Component, -- in conjunction with a data stream representing a value of the record type. -- The record data stream contains data for all fields of the record. The -- result is an extracted data stream representing just the value of the one -- field. Record_Components are implemented so as to allow for efficient -- extraction of field values. -- -- An extracted field data stream is suitable for all uses. If the field is a -- scalar type, it can be converted directly into useful information. If the -- field is, in turn, another composite value, it can be further decomposed -- into its own component values. -- -- There are two ways to obtain the Record_Components or the Array_Component -- needed to further decompose an embedded composite field. First, if the -- type of the field is known, the type definition can be directly queried to -- obtain the Record_Components or the Array_Component that describe its -- internal structure. Second, the Record_Component used to extract the field -- can be queried to obtain the same Record_Components or the same -- Array_Component. Both methods return identical information. -- -- This kind of nested decomposition can be carried to any required level. -- -- Record_Components become invalid when the Context, from which they -- originate, is closed. All Record_Components are obtained by referencing a) -- an Element, which has an associated Context, b) another Record_Component, -- or c) an Array_Component. Ultimately, all component values originate from -- a A_Type_Definition Element; that Element determines their Context of -- origin. ------------------------------------------------------------------------------ type Record_Component is private; Nil_Record_Component : constant Record_Component; function "=" (Left : Record_Component; Right : Record_Component) return Boolean is abstract; ------------------------------------------------------------------------------ -- 22.2 type Record_Component_List ------------------------------------------------------------------------------ type Record_Component_List is array (Asis.List_Index range <>) of Record_Component; ------------------------------------------------------------------------------ -- 22.3 type Array_Component ------------------------------------------------------------------------------ -- Array_Component -- -- Describes the components of an array valued field for a record type. -- Implementation is highly implementor dependent. The "=" operator is not -- meaningful between Array_Component values unless one of them is the -- Nil_Array_Component value. -- -- An array type describes composite values which contain zero or more indexed -- components. Both An_Unconstrained_Array_Definition or -- A_Constrained_Array_Definition can be queried to obtain a single -- Array_Component. The Array_Component contains the information necessary to -- extract any arbitrary component of the array. -- -- Array_Components are intended for use with data stream extraction -- operations. An extraction operation is performed using an Array_Component, -- in conjunction with a data stream representing a value of the array type. -- The array data stream contains data for all components of the array. The -- result is an extracted data stream representing just the value of the one -- component. Array_Components are implemented so as to allow for efficient -- extraction of array component values. -- -- An extracted component data stream is suitable for all uses. If the -- component is a scalar type, it can be converted directly into useful -- information. If the component is, in turn, another composite value, it can -- be further decomposed into its own component values. -- -- There are two ways to obtain the Record_Components or the Array_Component -- needed to further decompose an embedded composite component. First, if the -- type of the component is known, the type definition can be directly queried -- to obtain the Record_Components or the Array_Component that describe its -- internal structure. Second, the Array_Component used to extract the -- component can be queried to obtain the same Record_Components or the same -- Array_Component. Both methods return identical information. -- -- This kind of nested decomposition can be carried to any required level. -- -- Array_Components become invalid when the Context, from which they -- originate, is closed. All Record_Components are obtained by referencing a) -- an Element, which has an associated Context, b) a Record_Component, or c) -- another Array_Component. Ultimately, all component values originate from a -- A_Type_Definition Element; that Element determines their Context of origin. ------------------------------------------------------------------------------ type Array_Component is private; Nil_Array_Component : constant Array_Component; function "=" (Left : Array_Component; Right : Array_Component) return Boolean is abstract; ------------------------------------------------------------------------------ -- 22.4 type Array_Component_List ------------------------------------------------------------------------------ type Array_Component_List is array (Asis.List_Index range <>) of Array_Component; ------------------------------------------------------------------------------ -- 22.5 type Dimension_Indexes ------------------------------------------------------------------------------ -- Dimension_Indexes - an array of index values used to access an array stream ------------------------------------------------------------------------------ type Dimension_Indexes is array (Asis.ASIS_Positive range <>) of Asis.ASIS_Positive; ------------------------------------------------------------------------------ -- 22.6 type Array_Component_Iterator ------------------------------------------------------------------------------ -- Array_Component_Iterator - Used to iterate over successive components of an -- array. This can be more efficient than using individual index values when -- extracting array components from a data stream because it substitutes two -- subroutine calls (Next and Done) for the multiplications and divisions -- implicit in indexing an N dimensional array with a single index value. -- -- Iterators can be copied. The copies operate independently (have separate -- state). -- -- An example: -- -- declare -- Component : Array_Component := ...; -- Iter : Array_Component_Iterator; -- Array_Stream : Portable_Data (...) := ...; -- Component_Stream : Portable_Data (...); -- begin -- Iter := Array_Iterator (Component); -- while not Done (Iter) loop -- Component_Stream := Component_Data_Stream (Iter, Array_Stream); -- Next (Iter); -- end loop; -- end; ------------------------------------------------------------------------------ type Array_Component_Iterator is private; Nil_Array_Component_Iterator : constant Array_Component_Iterator; ------------------------------------------------------------------------------ -- 22.7 type Portable_Data ------------------------------------------------------------------------------ -- -- Portable Data Representation - an ordered "stream" of data values -- -- The portable representation for application data is an array of data -- values. This portable data representation is guaranteed to be valid when -- written, and later read, on the same machine architecture, using the same -- implementor's compiler and runtime system. Portability of the data -- values, across implementations and architectures, is not guaranteed. -- Some implementors may be able to provide data values which are portable -- across a larger subset of their supported machine architectures. -- -- Some of the problems encountered when changing architectures are: bit -- order, byte order, floating point representation, and alignment -- constraints. Some of the problems encountered when changing runtime -- systems or implementations are: type representation, optimization, -- record padding, and other I/O subsystem implementation variations. -- -- The nature of these data values is deliberately unspecified. An -- implementor will choose a data value type that is suitable for the -- expected uses of these arrays and data values. Arrays and data -- values have these uses: -- -- a) Array values are used in conjunction with the -- Asis.Data_Decomposition interface. The data value type should be -- readily decomposable, by that package, so that array and record -- components can be efficiently extracted from a data stream represented -- by this array type. The efficiency of that interface is a priority. -- -- b) The data value type is read and written by applications. It -- should have a size that makes efficient I/O possible. Applications can -- be expected to perform I/O in any or all of these ways: -- -- 1) Ada.Sequential_Io or Ada.Direct_Io could be used to read or write -- these values. -- -- 2) Individual values may be placed inside other types and those types -- may be read or written. -- -- 3) The 'Address of a data value, plus the 'Size of the data value -- type, may be used to perform low level system I/O. Note: This -- requires the 'Size of the type and the 'Size of a variable of that -- type to be the same for some implementations. -- -- 4) Individual values may be passed through Unchecked_Conversion in -- order to obtain a different value type, of the same 'Size, suitable -- for use with some user I/O facility. This usage is non-portable -- across implementations. -- -- c) Array values are read and written by applications. The data value -- type should have a size that makes efficient I/O possible. -- Applications can be expected to perform I/O in any or all of these -- ways: -- -- 1) Ada.Sequential_Io or Ada.Direct_Io could be used to read or write a -- constrained array subtype. -- -- 2) Array values may be placed inside other types and those types may -- be read and written. -- -- 3) The 'Address of the first array value, plus the 'Length of the -- array times the 'Size of the values, may be used to perform low -- level system I/O. Note: This implies that the array type is -- unpacked, or, that the packed array type has no "padding" (e.g., -- groups of five 6-bit values packed into 32-bit words with 2 bits -- of padding every 5 elements). -- -- 4) Array values may be passed through Unchecked_Conversion in order to -- obtain an array value, with a different value type, suitable for -- use with some user I/O facility. This usage is non-portable across -- implementations. -- -- The data value type should be chosen so that the 'Address of the first -- array data value is also the 'Address of the first storage unit containing -- array data. This is especially necessary for target architectures where -- the "bit" instructions address bits in the opposite direction as that used -- by normal machine memory (or array component) indexing. A recommended -- 'Size is System.Storage_Unit (or a multiple of that size). -- -- Implementations that do not support Unchecked_Conversion of array values, -- or which do not guarantee that Unchecked_Conversion of array values will -- always "do the right thing" (convert only the data, and not the dope vector -- information), should provide warnings in their ASIS documentation that -- detail possible consequences and work-arounds. -- -- The index range for the Portable_Data type shall be a numeric type whose -- range is large enough to encompass the Portable_Data representation for all -- possible runtime data values. -- -- All conversion interfaces always return Portable_Data array values with a -- 'First of one (1). -- -- The Portable_Value type may be implemented in any way -- whatsoever. It need not be a numeric type. ------------------------------------------------------------------------------ type Portable_Value is mod 2 ** 8; subtype Portable_Positive is Asis.ASIS_Positive range 1 .. Implementation_Defined_Integer_Constant; type Portable_Data is array (Portable_Positive range <>) of Portable_Value; Nil_Portable_Data : Portable_Data (1 .. 0); ------------------------------------------------------------------------------ -- 22.8 type Type_Model_Kinds ------------------------------------------------------------------------------ -- Type_Model_Kinds -- -- Each Type_Definition fits into one of three type models. ------------------------------------------------------------------------------ type Type_Model_Kinds is (A_Simple_Static_Model, A_Simple_Dynamic_Model, A_Complex_Dynamic_Model, Not_A_Type_Model); -- Nil arguments ------------------------------------------------------------------------------ -- 22.9 function Type_Model_Kind ------------------------------------------------------------------------------ function Type_Model_Kind (Type_Definition : Asis.Type_Definition) return Type_Model_Kinds; function Type_Model_Kind (Component : Record_Component) return Type_Model_Kinds; function Type_Model_Kind (Component : Array_Component) return Type_Model_Kinds; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the type definition to query -- Component - Specifies a record field with a record or array type -- -- Returns the model that best describes the type indicated by the argument. -- Returns Not_A_Type_Model for any unexpected argument such as a Nil value. -- -- Expected Element_Kinds: -- A_Type_Definition -- -- --|A4G Type_Model_Kind is extended to operate on A_Subtype_Indication -- --|A4G Elements ------------------------------------------------------------------------------ -- 22.10 function Is_Nil ------------------------------------------------------------------------------ function Is_Nil (Right : Record_Component) return Boolean; function Is_Nil (Right : Array_Component) return Boolean; ------------------------------------------------------------------------------ -- Right - Specifies the component to check -- -- Returns True if Right is a Nil (or uninitialized) component value. -- -- Returns False for all other values. -- -- All component values are appropriate. -- ------------------------------------------------------------------------------ -- 22.11 function Is_Equal ------------------------------------------------------------------------------ function Is_Equal (Left : Record_Component; Right : Record_Component) return Boolean; function Is_Equal (Left : Array_Component; Right : Array_Component) return Boolean; ------------------------------------------------------------------------------ -- Left - Specifies the left component to compare -- Right - Specifies the right component to compare -- -- Returns True if Left and Right represent the same physical component of the -- same record or array type, from the same physical compilation unit. The -- two components may or may not be from the same open ASIS Context variable. -- -- Implies: -- Is_Equal (Enclosing_Compilation_Unit (Component_Declaration (Left)), -- Enclosing_Compilation_Unit (Component_Declaration (Right))) -- = True -- -- All component values are appropriate. -- ------------------------------------------------------------------------------ -- 22.12 function Is_Identical ------------------------------------------------------------------------------ function Is_Identical (Left : Record_Component; Right : Record_Component) return Boolean; function Is_Identical (Left : Array_Component; Right : Array_Component) return Boolean; ------------------------------------------------------------------------------ -- Left - Specifies the left component to compare -- Right - Specifies the right component to compare -- -- Returns True if Left and Right represent the same physical component of the -- same record or array type, from the same physical compilation unit and the -- same open ASIS Context variable. -- -- Implies: -- Is_Identical (Enclosing_Compilation_Unit (Component_Declaration (Left)), -- Enclosing_Compilation_Unit (Component_Declaration (Right))) -- = True -- -- All component values are appropriate. -- ------------------------------------------------------------------------------ -- 22.13 function Is_Array ------------------------------------------------------------------------------ function Is_Array (Component : Record_Component) return Boolean; function Is_Array (Component : Array_Component) return Boolean; ------------------------------------------------------------------------------ -- Component - Specifies any component -- -- Returns True if the component has an array subtype (contains an array -- value). -- -- Returns False for Nil components and any component that is not an embedded -- array. -- ------------------------------------------------------------------------------ -- 22.14 function Is_Record ------------------------------------------------------------------------------ function Is_Record (Component : Record_Component) return Boolean; function Is_Record (Component : Array_Component) return Boolean; ------------------------------------------------------------------------------ -- Component - Specifies any component -- -- Returns True if the component has a record subtype. -- Returns False for Nil components and any component that is not an embedded -- record. -- ------------------------------------------------------------------------------ -- 22.15 function Done ------------------------------------------------------------------------------ function Done (Iterator : Array_Component_Iterator) return Boolean; ------------------------------------------------------------------------------ -- Iterator - Specifies the iterator to query -- -- Returns True if the iterator has been advanced past the last array -- component. Returns True for a Nil_Array_Component_Iterator. -- ------------------------------------------------------------------------------ -- 22.16 procedure Next ------------------------------------------------------------------------------ procedure Next (Iterator : in out Array_Component_Iterator); ------------------------------------------------------------------------------ -- Iterator - Specifies the iterator to advance -- -- Advances the iterator to the next array component. Use Done to test the -- iterator to see if it has passed the last component. Does nothing if the -- iterator is already past the last component. -- ------------------------------------------------------------------------------ -- 22.17 procedure Reset ------------------------------------------------------------------------------ procedure Reset (Iterator : in out Array_Component_Iterator); ------------------------------------------------------------------------------ -- Iterator - Specifies the iterator to reset -- -- Resets the iterator to the first array component. -- ------------------------------------------------------------------------------ -- 22.18 function Array_Index ------------------------------------------------------------------------------ function Array_Index (Iterator : Array_Component_Iterator) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Iterator - Specifies the iterator to query -- -- Returns the Index value which, when used in conjunction with the -- Array_Component value used to create the Iterator, indexes the same array -- component as that presently addressed by the Iterator. -- -- Raises ASIS_Inappropriate_Element if given a Nil_Array_Component_Iterator -- or one where Done(Iterator) = True. The Status value is Data_Error. -- The Diagnosis string will indicate the kind of error detected. -- ------------------------------------------------------------------------------ -- 22.19 function Array_Indexes ------------------------------------------------------------------------------ function Array_Indexes (Iterator : Array_Component_Iterator) return Dimension_Indexes; ------------------------------------------------------------------------------ -- Iterator - Specifies the iterator to query -- -- Returns the index values which, when used in conjunction with the -- Array_Component value used to create the Iterator, indexes the same array -- component as that presently addressed by the Iterator. -- -- Raises ASIS_Inappropriate_Element if given a Nil_Array_Component_Iterator -- or one where Done(Iterator) = True. The Status value is Data_Error. -- The Diagnosis string will indicate the kind of error detected. -- ------------------------------------------------------------------------------ -- 22.20 function Discriminant_Components ------------------------------------------------------------------------------ function Discriminant_Components (Type_Definition : Asis.Type_Definition) return Record_Component_List; function Discriminant_Components (Component : Record_Component) return Record_Component_List; function Discriminant_Components (Component : Array_Component) return Record_Component_List; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the record type definition to query -- Component - Specifies a component which has a record subtype, -- Is_Record(Component) = True -- -- Returns a list of the discriminant components for records of the indicated -- record type. -- -- The result describes the locations of the record type's discriminants, -- regardless of the static or dynamic nature of the record type. -- All return components are intended for use with a data stream representing -- a value of the indicated record type. -- -- All Is_Record(Component) = True arguments are appropriate. All return -- values are valid parameters for all query operations. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from a record type) -- A_Record_Type_Definition -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- A_Simple_Dynamic_Model -- A_Complex_Dynamic_Model -- ------------------------------------------------------------------------------ -- 22.21 function Record_Components ------------------------------------------------------------------------------ function Record_Components (Type_Definition : Asis.Type_Definition) return Record_Component_List; function Record_Components (Component : Record_Component) return Record_Component_List; function Record_Components (Component : Array_Component) return Record_Component_List; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the record type definition to query -- Component - Specifies a component which has a record subtype, -- Is_Record(Component) = True -- -- Returns a list of the discriminants and components for the indicated simple -- static record type. (See rule 6.A above.) -- -- The result describes the locations of the record type's discriminants and -- components. All return components are intended for use with a data stream -- representing a value of the indicated record type. -- -- All Is_Record (Component) = True values, having simple static types, are -- appropriate. All return values are valid parameters for all query -- operations. -- -- Note: If an Ada implementation uses implementation-dependent record -- components (Reference Manual 13.5.1 (15)), then each such component of -- the record type is included in the result. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from a record type) -- A_Record_Type_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- ------------------------------------------------------------------------------ -- 22.22 function Record_Components ------------------------------------------------------------------------------ function Record_Components (Type_Definition : Asis.Type_Definition; Data_Stream : Portable_Data) return Record_Component_List; function Record_Components (Component : Record_Component; Data_Stream : Portable_Data) return Record_Component_List; function Record_Components (Component : Array_Component; Data_Stream : Portable_Data) return Record_Component_List; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the record type definition to query -- Component - Specifies a component which has a record subtype, -- Is_Record(Component) = True -- Data_Stream - Specifies a data stream containing, at least, the -- complete set of discriminant or index constraints for -- the type -- -- Returns a list of the discriminants and components for the indicated record -- type, using the data stream argument as a guide. The record type shall be -- either a simple static, or a simple dynamic, record type. (See rules 6.A -- and 6.B above.) -- -- The result describes the locations of the record type's discriminants and -- all components of the appropriate variant parts. The contents of the list -- are determined by the discriminant values present in the data stream. -- -- A simple static type will always return the same component list (Is_Equal -- parts) regardless of the Data_Stream, because the layout of a simple static -- type does not change with changes in discriminant values. A simple dynamic -- type returns different component lists (non-Is_Equal parts) depending on -- the contents of the Data_Stream, because the contents and layout of a -- simple dynamic type changes with changes in discriminant values. All -- return components are intended for use with a data stream representing a -- value of the indicate record type. -- -- The Data_Stream shall represent a fully discriminated value of the -- indicated record type. The stream may have been read from a file, it may -- have been extracted from some enclosing data stream, or it may be an -- artificial value created by the Construct_Artificial_Data_Stream operation. -- Only the discriminant portion of the Data_Stream is checked for validity, -- and, only some discriminant fields may need to be checked, depending on the -- complexity of the record type. The best approach, for any application that -- is constructing artificial data streams, is to always provide appropriate -- values for all discriminant fields. It is not necessary to provide values -- for non-discriminant fields. -- -- All Is_Record(Component) = True values are appropriate. All return values -- are valid parameters for all query operations. -- -- Note: If an Ada implementation uses implementation-dependent record -- components (Reference Manual 13.5.1 (15)), then each such component of the -- record type is included in the result. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from a record type) -- A_Record_Type_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- A_Simple_Dynamic_Model -- ------------------------------------------------------------------------------ -- 22.23 function Array_Components ------------------------------------------------------------------------------ function Array_Components (Type_Definition : Asis.Type_Definition) return Array_Component; function Array_Components (Component : Record_Component) return Array_Component; function Array_Components (Component : Array_Component) return Array_Component; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the array type definition to query -- Component - Specifies a component which has an array subtype, -- Is_Array(Component) = True -- -- Returns a single component, describing all components of the indicated -- array type. The array type shall be a simple static, or a simple dynamic -- array type. (See rules 6.A and 6.B above.) -- -- The result contains all information necessary to index and extract any -- component of a data stream representing a value of the indicated array -- type. -- -- All Is_Array (Component) = True values are appropriate. All return values -- are valid parameters for all query operations. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from an array type) -- An_Unconstrained_Array_Definition -- A_Constrained_Array_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- A_Simple_Dynamic_Model -- ------------------------------------------------------------------------------ -- 22.24 function Array_Iterator ------------------------------------------------------------------------------ function Array_Iterator (Component : Array_Component) return Array_Component_Iterator; ------------------------------------------------------------------------------ -- Component - Specifies an array component to be used for iteration -- -- Returns an iterator poised to fetch the 1st component of an array. -- ------------------------------------------------------------------------------ -- 22.25 function Component_Data_Stream ------------------------------------------------------------------------------ function Component_Data_Stream (Component : Record_Component; Data_Stream : Portable_Data) return Portable_Data; function Component_Data_Stream (Component : Array_Component; Index : Asis.ASIS_Positive; Data_Stream : Portable_Data) return Portable_Data; function Component_Data_Stream (Component : Array_Component; Indexes : Dimension_Indexes; Data_Stream : Portable_Data) return Portable_Data; function Component_Data_Stream (Iterator : Array_Component_Iterator; Data_Stream : Portable_Data) return Portable_Data; ------------------------------------------------------------------------------ -- Component - Specifies the component or discriminant to be extracted -- Index - Specifies an index, 1..Array_Length, within an array -- Indexes - Specifies a list of index values, there is one value for -- each dimension of the array type, each index N is in the -- range 1..Array_Length (Component, N); -- Iterator - Specifies the array component to extract -- Data_Stream - Specifies the data stream from which to extract the result -- -- Returns a data stream representing just the value of the chosen Component. -- The return value is sliced from the data stream. The Data_Stream shall -- represent a value of the appropriate type. It may have been obtained from -- a file, extracted from another data stream, or artificially constructed -- using the Construct_Artificial_Data_Stream operation. -- -- An artificial data stream may raise ASIS_Inappropriate_Element (the Status -- is Value_Error). Only the constraint values are valid, once they -- have been properly initialized, and can be safely extracted from an -- artificial data stream. -- -- Raises ASIS_Inappropriate_Element if given a Nil_Array_Component_Iterator -- or one where Done(Iterator) = True. The Status value is Data_Error. -- The Diagnosis string will indicate the kind of error detected. -- -- All non-Nil component values are appropriate. -- ------------------------------------------------------------------------------ -- 22.26 function Component_Declaration ------------------------------------------------------------------------------ function Component_Declaration (Component : Record_Component) return Asis.Declaration; ------------------------------------------------------------------------------ -- Component - Specifies the component to be queried -- -- Returns an Asis.Declaration, which is either A_Component_Declaration -- or A_Discriminant_Specification. These values can be used to determine the -- subtype, type, and base type of the record component. The result may be an -- explicit declaration made by the user, or, it may be an implicit -- component declaration for an implementation-defined component (Reference -- Manual 13.5.1(15)). -- -- All non-Nil component values are appropriate. -- -- Returns Element_Kinds: -- A_Declaration -- -- Returns Declaration_Kinds: -- A_Component_Declaration -- A_Discriminant_Specification -- ------------------------------------------------------------------------------ -- 22.27 function Component_Indication ------------------------------------------------------------------------------ function Component_Indication (Component : Array_Component) return Asis.Subtype_Indication; ------------------------------------------------------------------------------ -- Component - Specifies the component to be queried -- -- Returns an Asis.Subtype_Indication. These values can be used to determine -- the subtype, type, and base type of the array components. -- -- All non-Nil component values are appropriate. -- -- Returns Element_Kinds: -- A_Subtype_Indication -- ------------------------------------------------------------------------------ -- 22.28 function All_Named_Components ------------------------------------------------------------------------------ function All_Named_Components (Type_Definition : Asis.Type_Definition) return Asis.Defining_Name_List; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the record type definition to query -- -- Returns a list of all discriminant and component entity names defined by -- the record type. All record type definitions are appropriate for this -- operation. This query provides a means for determining whether a field, -- with a particular name, exists for some possible instance of the record -- type. This list does not include the names of implementation-defined -- components (Reference Manual 13.5.1 (15)); those name have the form of -- An_Attribute_Reference expression. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from a record type) -- A_Record_Type_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- A_Simple_Dynamic_Model -- A_Complex_Dynamic_Model -- ------------------------------------------------------------------------------ -- 22.29 function Array_Length ------------------------------------------------------------------------------ function Array_Length (Component : Record_Component) return Asis.ASIS_Natural; function Array_Length (Component : Array_Component) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Component - Specifies the component to query -- -- Returns the number of components within an array valued component. The -- array subtype may be multidimensional. The result treats the array as if -- it were unidimensional. It is the product of the 'Lengths of the -- individual array dimensions. -- -- All Is_Array(Component) = True values are appropriate. -- ------------------------------------------------------------------------------ -- 22.30 function Array_Length ------------------------------------------------------------------------------ function Array_Length (Component : Record_Component; Dimension : Asis.ASIS_Natural) return Asis.ASIS_Natural; function Array_Length (Component : Array_Component; Dimension : Asis.ASIS_Natural) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Component - Specifies the component to query -- Dimension - Specifies the array dimension to query -- -- Returns the number of components within an array valued component. The -- array subtype may be unidimensional. The result is the 'Length(Dimension) -- of the array. -- -- All Is_Array(Component) = True values are appropriate. -- ------------------------------------------------------------------------------ -- 22.31 function Size ------------------------------------------------------------------------------ function Size (Type_Definition : Asis.Type_Definition) return Asis.ASIS_Natural; function Size (Component : Record_Component) return Asis.ASIS_Natural; function Size (Component : Array_Component) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Type_Definition - Specifies a type definition, whose 'Size is desired -- Component - Specifies a component, whose 'Size is desired -- -- Returns the minimum number of bits required to hold a simple static type, -- the number of bits allocated to hold a record field, or the number of bits -- allocated to hold each array component. -- -- --|AN Application Note: -- --|AN -- --|AN For components, this is the number of bits allocated -- --|AN within the composite value. It may be greater than the number -- --|AN of bits occupied by data values of this component type. -- --|AN Also, the data value, when occupying more space than is -- --|AN minimally required, may be preceded, followed, or surrounded by -- --|AN padding bits which are necessary to fully occupy the space allotted. -- --|AN -- All non-Nil component values are appropriate. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- -- --|A4G Size is extended to operate on A_Subtype_Indication -- --|A4G Elements -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- ------------------------------------------------------------------------------ -- 22.32 function Size ------------------------------------------------------------------------------ function Size (Type_Definition : Asis.Type_Definition; Data_Stream : Portable_Data) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the type definition to query -- Data_Stream - Specifies a data stream containing, at least, the -- complete set of discriminant or index constraints for -- the type -- -- Returns the 'Size of a value of this type, with these constraints. This is -- the minimum number of bits that is needed to hold any possible value of the -- given fully constrained subtype. Only the constraint portion of the -- Data_Stream is checked. -- -- The Data_Stream may be a data stream or it may be an artificial -- data stream created by the Construct_Artificial_Data_Stream operation. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Appropriate Asis.Data_Decomposition.Type_Model_Kinds: -- A_Simple_Static_Model -- A_Simple_Dynamic_Model -- ------------------------------------------------------------------------------ -- 22.33 function Position ------------------------------------------------------------------------------ function Position (Component : Record_Component) return Asis.ASIS_Natural; function Position (Component : Array_Component; Index : Asis.ASIS_Positive) return Asis.ASIS_Natural; function Position (Component : Array_Component; Indexes : Dimension_Indexes) return Asis.ASIS_Natural; function Position (Iterator : Array_Component_Iterator) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Component - Specifies the component to query -- Index - Specifies a value in the range 1..Array_Length (Component), -- the index of the component to query -- Indexes - Specifies a list of index values, there is one value for -- each dimension of the array type, each index N is in the -- range 1..Array_Length (Component, N); -- Iterator - Specifies a particular array component to query -- -- Returns the System.Storage_Unit offset, from the start of the first storage -- unit occupied by the enclosing composite type, of the first of the storage -- units occupied by the Component. The offset is measured in storage units. -- -- All non-Nil component values are appropriate. Raises -- ASIS_Inappropriate_Element with a Status of Data_Error if any index is not -- in the expected range or if Done (Iterator) = True. The Status value will -- be Data_Error. The Diagnosis string will indicate the kind of error -- detected. -- ------------------------------------------------------------------------------ -- 22.34 function First_Bit ------------------------------------------------------------------------------ function First_Bit (Component : Record_Component) return Asis.ASIS_Natural; function First_Bit (Component : Array_Component; Index : Asis.ASIS_Positive) return Asis.ASIS_Natural; function First_Bit (Component : Array_Component; Indexes : Dimension_Indexes) return Asis.ASIS_Natural; function First_Bit (Iterator : Array_Component_Iterator) return Asis.ASIS_Natural; ------------------------------------------------------------------------------ -- Component - Specifies the component to query -- Index - Specifies a value in the range 1..Array_Length (Component), -- the index of the component to query -- Indexes - Specifies a list of index values, there is one value for -- each dimension of the array type, each index N is in the -- range 1..Array_Length (Component, N); -- Iterator - Specifies a particular array component to query -- -- Returns the bit offset, from the start of the first of the storage units -- occupied by the Component, of the first bit occupied by the Component. The -- offset is measured in bits. -- -- All non-Nil component values are appropriate. Raises -- ASIS_Inappropriate_Element with a Status of Data_Error if any index is not -- in the expected range or if Done (Iterator) = True. The Status value will -- be Data_Error. The Diagnosis string will indicate the kind of error -- detected. -- ------------------------------------------------------------------------------ -- 22.35 function Last_Bit ------------------------------------------------------------------------------ function Last_Bit (Component : Record_Component) return Asis.ASIS_Integer; function Last_Bit (Component : Array_Component; Index : Asis.ASIS_Positive) return Asis.ASIS_Integer; function Last_Bit (Component : Array_Component; Indexes : Dimension_Indexes) return Asis.ASIS_Integer; function Last_Bit (Iterator : Array_Component_Iterator) return Asis.ASIS_Integer; ------------------------------------------------------------------------------ -- Component - Specifies the component to query -- Index - Specifies a value in the range 1..Array_Length (Component), -- the index of the component to query -- Indexes - Specifies a list of index values, there is one value for -- each dimension of the array type, each index N is in the -- range 1..Array_Length (Component, N); -- Iterator - Specifies a particular array component to query -- -- Returns the bit offset, from the start of the first of the storage units -- occupied by the Index'th Element, of the last bit occupied by the Element. -- The offset is measured in bits. -- -- Note, that Last_Bit may be equal to -1 for a component which is -- an empty array -- -- All non-Nil component values are appropriate. Raises -- ASIS_Inappropriate_Element with a Status of Data_Error if any index is not -- in the expected range or if Done (Iterator) = True. The Status value will -- be Data_Error. The Diagnosis string will indicate the kind of error -- detected. -- ------------------------------------------------------------------------------ -- 22.36 function Portable_Constrained_Subtype ------------------------------------------------------------------------------ -- Generic for Data Stream Conversions ------------------------------------------------------------------------------ generic -- Ada notation for a constrained subtype. -- type Constrained_Subtype (<>) is private; type Constrained_Subtype is private; function Portable_Constrained_Subtype (Data_Stream : Portable_Data) return Constrained_Subtype; ------------------------------------------------------------------------------ -- Data_Stream - Specifies an extracted component of a record -- -- Instantiated with an appropriate scalar type, (e.g., System.Integer, can be -- used to convert a data stream to a value that can be directly examined). -- -- Instantiated with a record type, can be used to convert a data stream to a -- value that can be directly examined. -- -- Instantiations with constrained array subtypes may not convert array values -- if they were created using the Portable_Array_Type_1, -- Portable_Array_Type_2, or Portable_Array_Type_3 interfaces. -- -- May raise Constraint_Error if the subtype is a scalar and the converted -- value is not in the subtype's range. -- ------------------------------------------------------------------------------ -- 22.37 function Construct_Artificial_Data_Stream ------------------------------------------------------------------------------ function Construct_Artificial_Data_Stream (Type_Definition : Asis.Type_Definition; Data_Stream : Portable_Data; Discriminant : Record_Component; Value : Portable_Data) return Portable_Data; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the record type definition for the record -- valued data stream being constructed -- Data_Stream - Specifies the data stream constructed so far; initially -- specified as the Nil_Portable_Data value -- Discriminant - Specifies the discriminant of the record type that is -- being set or changed -- Value - Specifies a data stream representing a single -- discriminant value of the appropriate type -- -- Used to artificially construct a data stream which represents the -- discriminant portion of a fully constrained value of the indicated record -- type. This operation is called once with a value for each discriminant of -- the record type (the order in which the discriminants are specified is not -- important). The return value of each call is used as the input Data_Stream -- for the next. -- -- The resulting artificial data stream may be used solely for the purpose of -- creating Record_Component values. The values of any non-discriminant -- fields are arbitrary and quite possibly invalid. The resulting -- component values may then be used for any purpose. In particular, they may -- be used to determine First_Bit, Last_Bit, and Size values for all record -- discriminants and components. -- -- Appropriate Element_Kinds: -- A_Type_Definition -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition (derived from a record type) -- A_Record_Type_Definition -- -- -- ??? Should be extended for A_Subtype_Indication -- -- Raises ASIS_Inappropriate_Element, with a Status of Data_Error, if the -- discriminant Value is inappropriate for the specified Discriminant. -- ------------------------------------------------------------------------------ private type Portable_Data_Access is access all Portable_Data; -- ??? Do we have to keep the whole parent stream? Is not a list -- ??? of parent discriminants (in the form suitable for A4G.DDA_Aux) -- ??? enough? type Discrim_List_Access is access all Discrim_List; type Record_Component is record Parent_Record_Type : Asis.Definition := Nil_Element; -- The definition of the type from which this component was extracted -- ??? Do we really need this? Component_Name : Asis.Defining_Name := Nil_Element; -- The defining name corresponding to the component in -- Parent_Record_Type -- ??? Why not just keep the entity node? Is_Record_Comp : Boolean := False; -- Flag indcating if the component itself is of a record type Is_Array_Comp : Boolean := False; -- Flag indcating if the component itself is of an array type Position : ASIS_Natural := 0; -- Position of the component, as it is to be returned by -- Position query First_Bit : ASIS_Natural := 0; -- Component first bit, as it is to be returned by First_Bit query Last_Bit : ASIS_Integer := 0; -- Component last bit, as it is to be returned by Last_Bit query -- Note, that Last_Bit may be equal to -1 for a component which is -- an empty array Size : ASIS_Natural := 0; -- Component size, as it is to be returned by Size query Parent_Discrims : Discrim_List_Access := null; -- The reference to a list of discriminants from the enclosed record -- value (null if there is no discriminant) Parent_Context : Context_Id := Non_Associated; -- An ASIS Context from which a given component is originated Obtained : ASIS_OS_Time := Nil_ASIS_OS_Time; -- Time when a given component was created, needed for validity -- checks -- What else do we need??? -- ??? Do we need the reference to a tree file from which the -- ??? component is obtained (plus tree swapping mechanism similar -- ??? to what is used for Elements end record; Nil_Record_Component : constant Record_Component := (Parent_Record_Type => Nil_Element, Component_Name => Nil_Element, Is_Record_Comp => False, Is_Array_Comp => False, Position => 0, First_Bit => 0, Last_Bit => 0, Size => 0, Parent_Discrims => null, Parent_Context => Non_Associated, Obtained => Nil_ASIS_OS_Time); type Dimention_Length is array (1 .. 16) of Asis.ASIS_Natural; type Array_Component is record -- ??? Currently, the same structure as for Record_Component Parent_Array_Type : Asis.Definition := Nil_Element; -- The definition of the Array type to which this component -- belongs ??? Array_Type_Entity : Entity_Id := Empty; -- Entyty Id for the array type from which the array component was -- extracted. It may not correspond to Parent_Array_Type, and it may -- be the implicit type entity as well. Parent_Component_Name : Asis.Defining_Name := Nil_Element; -- The defining name corresponding to the record component (which is of -- array type) to which a given array componnets directly belonds -- (Nil_Element, if the array component is not directly extracted from -- some record component). It may contain index constraint, so we -- need it. We also need it to compare array components. Is_Record_Comp : Boolean := False; -- Flag indcating if the component itself is of a record type Is_Array_Comp : Boolean := False; -- Flag indcating if the component itself is of an array type Position : ASIS_Natural := 0; -- Position of the component, as it is to be returned by -- Position query First_Bit : ASIS_Natural := 0; -- Component first bit, as it is to be returned by First_Bit query Last_Bit : ASIS_Integer := 0; -- Component last bit, as it is to be returned by Last_Bit query -- Note, that Last_Bit may be equal to -1 for a component which is -- an empty array Size : ASIS_Natural := 0; -- Component size, as it is to be returned by Size query Parent_Discrims : Discrim_List_Access := null; -- The reference to a list of discriminants from the enclosed record -- value (null if there is no discriminant), needed in case when the -- array componnet is extracted from a record component which in turn -- depends on discriminant Parent_Context : Context_Id := Non_Associated; -- An ASIS Context from which a given component is originated Obtained : ASIS_OS_Time := Nil_ASIS_OS_Time; -- Time when a given component was created, needed for validity -- checks -- What else do we need??? Dimension : ASIS_Natural range 1 .. 16; -- Dimension of enclosing array value Length : Dimention_Length := (others => 0); end record; Nil_Array_Component : constant Array_Component := (Parent_Array_Type => Nil_Element, Array_Type_Entity => Empty, Parent_Component_Name => Nil_Element, Is_Record_Comp => False, Is_Array_Comp => False, Position => 0, First_Bit => 0, Last_Bit => 0, Size => 0, Parent_Discrims => null, Parent_Context => Non_Associated, Obtained => Nil_ASIS_OS_Time, Dimension => 1, Length => (others => 0)); type Array_Component_Iterator is record Component : Array_Component; Max_Len : Asis.ASIS_Natural := 0; Index : Asis.ASIS_Natural := 0; end record; Nil_Array_Component_Iterator : constant Array_Component_Iterator := (Component => Nil_Array_Component, Max_Len => 0, Index => 0); ------------------------------------------------------------------------------ end Asis.Data_Decomposition;
zhmu/ananas
Ada
123,147
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . R E G P A T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1986 by University of Toronto. -- -- Copyright (C) 1999-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is an altered Ada 95 version of the original V8 style regular -- expression library written in C by Henry Spencer. Apart from the -- translation to Ada, the interface has been considerably changed to -- use the Ada String type instead of C-style nul-terminated strings. -- Beware that some of this code is subtly aware of the way operator -- precedence is structured in regular expressions. Serious changes in -- regular-expression syntax might require a total rethink. with System.IO; use System.IO; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Unchecked_Conversion; package body System.Regpat is Debug : constant Boolean := False; -- Set to True to activate debug traces. This is normally set to constant -- False to simply delete all the trace code. It is to be edited to True -- for internal debugging of the package. ---------------------------- -- Implementation details -- ---------------------------- -- This is essentially a linear encoding of a nondeterministic -- finite-state machine, also known as syntax charts or -- "railroad normal form" in parsing technology. -- Each node is an opcode plus a "next" pointer, possibly plus an -- operand. "Next" pointers of all nodes except BRANCH implement -- concatenation; a "next" pointer with a BRANCH on both ends of it -- is connecting two alternatives. -- The operand of some types of node is a literal string; for others, -- it is a node leading into a sub-FSM. In particular, the operand of -- a BRANCH node is the first node of the branch. -- (NB this is *not* a tree structure: the tail of the branch connects -- to the thing following the set of BRANCHes). -- You can see the exact byte-compiled version by using the Dump -- subprogram. However, here are a few examples: -- (a|b): 1 : BRANCH (next at 9) -- 4 : EXACT (next at 17) operand=a -- 9 : BRANCH (next at 17) -- 12 : EXACT (next at 17) operand=b -- 17 : EOP (next at 0) -- -- (ab)*: 1 : CURLYX (next at 25) { 0, 32767} -- 8 : OPEN 1 (next at 12) -- 12 : EXACT (next at 18) operand=ab -- 18 : CLOSE 1 (next at 22) -- 22 : WHILEM (next at 0) -- 25 : NOTHING (next at 28) -- 28 : EOP (next at 0) -- The opcodes are: type Opcode is -- Name Operand? Meaning (EOP, -- no End of program MINMOD, -- no Next operator is not greedy -- Classes of characters ANY, -- no Match any one character except newline SANY, -- no Match any character, including new line ANYOF, -- class Match any character in this class EXACT, -- str Match this string exactly EXACTF, -- str Match this string (case-folding is one) NOTHING, -- no Match empty string SPACE, -- no Match any whitespace character NSPACE, -- no Match any non-whitespace character DIGIT, -- no Match any numeric character NDIGIT, -- no Match any non-numeric character ALNUM, -- no Match any alphanumeric character NALNUM, -- no Match any non-alphanumeric character -- Branches BRANCH, -- node Match this alternative, or the next -- Simple loops (when the following node is one character in length) STAR, -- node Match this simple thing 0 or more times PLUS, -- node Match this simple thing 1 or more times CURLY, -- 2num node Match this simple thing between n and m times. -- Complex loops CURLYX, -- 2num node Match this complex thing {n,m} times -- The nums are coded on two characters each WHILEM, -- no Do curly processing and see if rest matches -- Matches after or before a word BOL, -- no Match "" at beginning of line MBOL, -- no Same, assuming multiline (match after \n) SBOL, -- no Same, assuming single line (don't match at \n) EOL, -- no Match "" at end of line MEOL, -- no Same, assuming multiline (match before \n) SEOL, -- no Same, assuming single line (don't match at \n) BOUND, -- no Match "" at any word boundary NBOUND, -- no Match "" at any word non-boundary -- Parenthesis groups handling REFF, -- num Match some already matched string, folded OPEN, -- num Mark this point in input as start of #n CLOSE); -- num Analogous to OPEN for Opcode'Size use 8; -- Opcode notes: -- BRANCH -- The set of branches constituting a single choice are hooked -- together with their "next" pointers, since precedence prevents -- anything being concatenated to any individual branch. The -- "next" pointer of the last BRANCH in a choice points to the -- thing following the whole choice. This is also where the -- final "next" pointer of each individual branch points; each -- branch starts with the operand node of a BRANCH node. -- STAR,PLUS -- '?', and complex '*' and '+', are implemented with CURLYX. -- branches. Simple cases (one character per match) are implemented with -- STAR and PLUS for speed and to minimize recursive plunges. -- OPEN,CLOSE -- ...are numbered at compile time. -- EXACT, EXACTF -- There are in fact two arguments, the first one is the length (minus -- one of the string argument), coded on one character, the second -- argument is the string itself, coded on length + 1 characters. -- A node is one char of opcode followed by two chars of "next" pointer. -- "Next" pointers are stored as two 8-bit pieces, high order first. The -- value is a positive offset from the opcode of the node containing it. -- An operand, if any, simply follows the node. (Note that much of the -- code generation knows about this implicit relationship.) -- Using two bytes for the "next" pointer is vast overkill for most -- things, but allows patterns to get big without disasters. Next_Pointer_Bytes : constant := 3; -- Points after the "next pointer" data. An instruction is therefore: -- 1 byte: instruction opcode -- 2 bytes: pointer to next instruction -- * bytes: optional data for the instruction ----------------------- -- Character classes -- ----------------------- -- This is the implementation for character classes ([...]) in the -- syntax for regular expressions. Each character (0..256) has an -- entry into the table. This makes for a very fast matching -- algorithm. type Class_Byte is mod 256; type Character_Class is array (Class_Byte range 0 .. 31) of Class_Byte; type Bit_Conversion_Array is array (Class_Byte range 0 .. 7) of Class_Byte; Bit_Conversion : constant Bit_Conversion_Array := [1, 2, 4, 8, 16, 32, 64, 128]; type Std_Class is (ANYOF_NONE, ANYOF_ALNUM, -- Alphanumeric class [a-zA-Z0-9] ANYOF_NALNUM, ANYOF_SPACE, -- Space class [ \t\n\r\f] ANYOF_NSPACE, ANYOF_DIGIT, -- Digit class [0-9] ANYOF_NDIGIT, ANYOF_ALNUMC, -- Alphanumeric class [a-zA-Z0-9] ANYOF_NALNUMC, ANYOF_ALPHA, -- Alpha class [a-zA-Z] ANYOF_NALPHA, ANYOF_ASCII, -- Ascii class (7 bits) 0..127 ANYOF_NASCII, ANYOF_CNTRL, -- Control class ANYOF_NCNTRL, ANYOF_GRAPH, -- Graphic class ANYOF_NGRAPH, ANYOF_LOWER, -- Lower case class [a-z] ANYOF_NLOWER, ANYOF_PRINT, -- printable class ANYOF_NPRINT, ANYOF_PUNCT, -- ANYOF_NPUNCT, ANYOF_UPPER, -- Upper case class [A-Z] ANYOF_NUPPER, ANYOF_XDIGIT, -- Hexadecimal digit ANYOF_NXDIGIT ); procedure Set_In_Class (Bitmap : in out Character_Class; C : Character); -- Set the entry to True for C in the class Bitmap function Get_From_Class (Bitmap : Character_Class; C : Character) return Boolean; -- Return True if the entry is set for C in the class Bitmap procedure Reset_Class (Bitmap : out Character_Class); -- Clear all the entries in the class Bitmap pragma Inline (Set_In_Class); pragma Inline (Get_From_Class); pragma Inline (Reset_Class); ----------------------- -- Local Subprograms -- ----------------------- function "=" (Left : Character; Right : Opcode) return Boolean; function Is_Alnum (C : Character) return Boolean; -- Return True if C is an alphanum character or an underscore ('_') function Is_White_Space (C : Character) return Boolean; -- Return True if C is a whitespace character function Is_Printable (C : Character) return Boolean; -- Return True if C is a printable character function Operand (P : Pointer) return Pointer; -- Return a pointer to the first operand of the node at P function String_Length (Program : Program_Data; P : Pointer) return Program_Size; -- Return the length of the string argument of the node at P function String_Operand (P : Pointer) return Pointer; -- Return a pointer to the string argument of the node at P procedure Bitmap_Operand (Program : Program_Data; P : Pointer; Op : out Character_Class); -- Return a pointer to the string argument of the node at P function Get_Next (Program : Program_Data; IP : Pointer) return Pointer; -- Dig the next instruction pointer out of a node procedure Optimize (Self : in out Pattern_Matcher); -- Optimize a Pattern_Matcher by noting certain special cases function Read_Natural (Program : Program_Data; IP : Pointer) return Natural; -- Return the 2-byte natural coded at position IP -- All of the subprograms above are tiny and should be inlined pragma Inline ("="); pragma Inline (Is_Alnum); pragma Inline (Is_White_Space); pragma Inline (Get_Next); pragma Inline (Operand); pragma Inline (Read_Natural); pragma Inline (String_Length); pragma Inline (String_Operand); type Expression_Flags is record Has_Width, -- Known never to match null string Simple, -- Simple enough to be STAR/PLUS operand SP_Start : Boolean; -- Starts with * or + end record; Worst_Expression : constant Expression_Flags := (others => False); -- Worst case procedure Dump_Until (Program : Program_Data; Index : in out Pointer; Till : Pointer; Indent : Natural; Do_Print : Boolean := True); -- Dump the program until the node Till (not included) is met. Every line -- is indented with Index spaces at the beginning Dumps till the end if -- Till is 0. procedure Dump_Operation (Program : Program_Data; Index : Pointer; Indent : Natural); -- Same as above, but only dumps a single operation, and compute its -- indentation from the program. --------- -- "=" -- --------- function "=" (Left : Character; Right : Opcode) return Boolean is begin return Character'Pos (Left) = Opcode'Pos (Right); end "="; -------------------- -- Bitmap_Operand -- -------------------- procedure Bitmap_Operand (Program : Program_Data; P : Pointer; Op : out Character_Class) is function Convert is new Ada.Unchecked_Conversion (Program_Data, Character_Class); begin Op (0 .. 31) := Convert (Program (P + Next_Pointer_Bytes .. P + 34)); end Bitmap_Operand; ------------- -- Compile -- ------------- procedure Compile (Matcher : out Pattern_Matcher; Expression : String; Final_Code_Size : out Program_Size; Flags : Regexp_Flags := No_Flags) is -- We can't allocate space until we know how big the compiled form -- will be, but we can't compile it (and thus know how big it is) -- until we've got a place to put the code. So we cheat: we compile -- it twice, once with code generation turned off and size counting -- turned on, and once "for real". -- This also means that we don't allocate space until we are sure -- that the thing really will compile successfully, and we never -- have to move the code and thus invalidate pointers into it. -- Beware that the optimization-preparation code in here knows -- about some of the structure of the compiled regexp. PM : Pattern_Matcher renames Matcher; Program : Program_Data renames PM.Program; Emit_Ptr : Pointer := Program_First; Parse_Pos : Natural := Expression'First; -- Input-scan pointer Parse_End : constant Natural := Expression'Last; ---------------------------- -- Subprograms for Create -- ---------------------------- procedure Emit (B : Character); -- Output the Character B to the Program. If code-generation is -- disabled, simply increments the program counter. function Emit_Node (Op : Opcode) return Pointer; -- If code-generation is enabled, Emit_Node outputs the -- opcode Op and reserves space for a pointer to the next node. -- Return value is the location of new opcode, i.e. old Emit_Ptr. procedure Emit_Natural (IP : Pointer; N : Natural); -- Split N on two characters at position IP procedure Emit_Class (Bitmap : Character_Class); -- Emits a character class procedure Case_Emit (C : Character); -- Emit C, after converting is to lower-case if the regular -- expression is case insensitive. procedure Parse (Parenthesized : Boolean; Capturing : Boolean; Flags : out Expression_Flags; IP : out Pointer); -- Parse regular expression, i.e. main body or parenthesized thing. -- Caller must absorb opening parenthesis. Capturing should be set to -- True when we have an open parenthesis from which we want the user -- to extra text. procedure Parse_Branch (Flags : out Expression_Flags; First : Boolean; IP : out Pointer); -- Implements the concatenation operator and handles '|'. -- First should be true if this is the first item of the alternative. procedure Parse_Piece (Expr_Flags : out Expression_Flags; IP : out Pointer); -- Parse something followed by possible [*+?] procedure Parse_Atom (Expr_Flags : out Expression_Flags; IP : out Pointer); -- Parse_Atom is the lowest level parse procedure. -- -- Optimization: Gobbles an entire sequence of ordinary characters so -- that it can turn them into a single node, which is smaller to store -- and faster to run. Backslashed characters are exceptions, each -- becoming a separate node; the code is simpler that way and it's -- not worth fixing. procedure Insert_Operator (Op : Opcode; Operand : Pointer; Greedy : Boolean := True); -- Insert_Operator inserts an operator in front of an already-emitted -- operand and relocates the operand. This applies to PLUS and STAR. -- If Minmod is True, then the operator is non-greedy. function Insert_Operator_Before (Op : Opcode; Operand : Pointer; Greedy : Boolean; Opsize : Pointer) return Pointer; -- Insert an operator before Operand (and move the latter forward in the -- program). Opsize is the size needed to represent the operator. This -- returns the position at which the operator was inserted, and moves -- Emit_Ptr after the new position of the operand. procedure Insert_Curly_Operator (Op : Opcode; Min : Natural; Max : Natural; Operand : Pointer; Greedy : Boolean := True); -- Insert an operator for CURLY ({Min}, {Min,} or {Min,Max}). -- If Minmod is True, then the operator is non-greedy. procedure Link_Tail (P, Val : Pointer); -- Link_Tail sets the next-pointer at the end of a node chain procedure Link_Operand_Tail (P, Val : Pointer); -- Link_Tail on operand of first argument; noop if operand-less procedure Fail (M : String); pragma No_Return (Fail); -- Fail with a diagnostic message, if possible function Is_Curly_Operator (IP : Natural) return Boolean; -- Return True if IP is looking at a '{' that is the beginning -- of a curly operator, i.e. it matches {\d+,?\d*} function Is_Mult (IP : Natural) return Boolean; -- Return True if C is a regexp multiplier: '+', '*' or '?' procedure Get_Curly_Arguments (IP : Natural; Min : out Natural; Max : out Natural; Greedy : out Boolean); -- Parse the argument list for a curly operator. -- It is assumed that IP is indeed pointing at a valid operator. -- So what is IP and how come IP is not referenced in the body ??? procedure Parse_Character_Class (IP : out Pointer); -- Parse a character class. -- The calling subprogram should consume the opening '[' before. procedure Parse_Literal (Expr_Flags : out Expression_Flags; IP : out Pointer); -- Parse_Literal encodes a string of characters to be matched exactly function Parse_Posix_Character_Class return Std_Class; -- Parse a posix character class, like [:alpha:] or [:^alpha:]. -- The caller is supposed to absorb the opening [. pragma Inline (Is_Mult); pragma Inline (Emit_Natural); pragma Inline (Parse_Character_Class); -- since used only once --------------- -- Case_Emit -- --------------- procedure Case_Emit (C : Character) is begin if (Flags and Case_Insensitive) /= 0 then Emit (To_Lower (C)); else -- Dump current character Emit (C); end if; end Case_Emit; ---------- -- Emit -- ---------- procedure Emit (B : Character) is begin if Emit_Ptr <= PM.Size then Program (Emit_Ptr) := B; end if; Emit_Ptr := Emit_Ptr + 1; end Emit; ---------------- -- Emit_Class -- ---------------- procedure Emit_Class (Bitmap : Character_Class) is subtype Program31 is Program_Data (0 .. 31); function Convert is new Ada.Unchecked_Conversion (Character_Class, Program31); begin -- What is the mysterious constant 31 here??? Can't it be expressed -- symbolically (size of integer - 1 or some such???). In any case -- it should be declared as a constant (and referenced presumably -- as this constant + 1 below. if Emit_Ptr + 31 <= PM.Size then Program (Emit_Ptr .. Emit_Ptr + 31) := Convert (Bitmap); end if; Emit_Ptr := Emit_Ptr + 32; end Emit_Class; ------------------ -- Emit_Natural -- ------------------ procedure Emit_Natural (IP : Pointer; N : Natural) is begin if IP + 1 <= PM.Size then Program (IP + 1) := Character'Val (N / 256); Program (IP) := Character'Val (N mod 256); end if; end Emit_Natural; --------------- -- Emit_Node -- --------------- function Emit_Node (Op : Opcode) return Pointer is Result : constant Pointer := Emit_Ptr; begin if Emit_Ptr + 2 <= PM.Size then Program (Emit_Ptr) := Character'Val (Opcode'Pos (Op)); Program (Emit_Ptr + 1) := ASCII.NUL; Program (Emit_Ptr + 2) := ASCII.NUL; end if; Emit_Ptr := Emit_Ptr + Next_Pointer_Bytes; return Result; end Emit_Node; ---------- -- Fail -- ---------- procedure Fail (M : String) is begin raise Expression_Error with M; end Fail; ------------------------- -- Get_Curly_Arguments -- ------------------------- procedure Get_Curly_Arguments (IP : Natural; Min : out Natural; Max : out Natural; Greedy : out Boolean) is pragma Unreferenced (IP); Save_Pos : Natural := Parse_Pos + 1; begin Min := 0; Max := Max_Curly_Repeat; while Expression (Parse_Pos) /= '}' and then Expression (Parse_Pos) /= ',' loop Parse_Pos := Parse_Pos + 1; end loop; Min := Natural'Value (Expression (Save_Pos .. Parse_Pos - 1)); if Expression (Parse_Pos) = ',' then Save_Pos := Parse_Pos + 1; while Expression (Parse_Pos) /= '}' loop Parse_Pos := Parse_Pos + 1; end loop; if Save_Pos /= Parse_Pos then Max := Natural'Value (Expression (Save_Pos .. Parse_Pos - 1)); end if; else Max := Min; end if; if Parse_Pos < Expression'Last and then Expression (Parse_Pos + 1) = '?' then Greedy := False; Parse_Pos := Parse_Pos + 1; else Greedy := True; end if; end Get_Curly_Arguments; --------------------------- -- Insert_Curly_Operator -- --------------------------- procedure Insert_Curly_Operator (Op : Opcode; Min : Natural; Max : Natural; Operand : Pointer; Greedy : Boolean := True) is Old : Pointer; begin Old := Insert_Operator_Before (Op, Operand, Greedy, Opsize => 7); Emit_Natural (Old + Next_Pointer_Bytes, Min); Emit_Natural (Old + Next_Pointer_Bytes + 2, Max); end Insert_Curly_Operator; ---------------------------- -- Insert_Operator_Before -- ---------------------------- function Insert_Operator_Before (Op : Opcode; Operand : Pointer; Greedy : Boolean; Opsize : Pointer) return Pointer is Dest : constant Pointer := Emit_Ptr; Old : Pointer; Size : Pointer := Opsize; begin -- If not greedy, we have to emit another opcode first if not Greedy then Size := Size + Next_Pointer_Bytes; end if; -- Move the operand in the byte-compilation, so that we can insert -- the operator before it. if Emit_Ptr + Size <= PM.Size then Program (Operand + Size .. Emit_Ptr + Size) := Program (Operand .. Emit_Ptr); end if; -- Insert the operator at the position previously occupied by the -- operand. Emit_Ptr := Operand; if not Greedy then Old := Emit_Node (MINMOD); Link_Tail (Old, Old + Next_Pointer_Bytes); end if; Old := Emit_Node (Op); Emit_Ptr := Dest + Size; return Old; end Insert_Operator_Before; --------------------- -- Insert_Operator -- --------------------- procedure Insert_Operator (Op : Opcode; Operand : Pointer; Greedy : Boolean := True) is Discard : Pointer; pragma Warnings (Off, Discard); begin Discard := Insert_Operator_Before (Op, Operand, Greedy, Opsize => Next_Pointer_Bytes); end Insert_Operator; ----------------------- -- Is_Curly_Operator -- ----------------------- function Is_Curly_Operator (IP : Natural) return Boolean is Scan : Natural := IP; begin if Expression (Scan) /= '{' or else Scan + 2 > Expression'Last or else not Is_Digit (Expression (Scan + 1)) then return False; end if; Scan := Scan + 1; -- The first digit loop Scan := Scan + 1; if Scan > Expression'Last then return False; end if; exit when not Is_Digit (Expression (Scan)); end loop; if Expression (Scan) = ',' then loop Scan := Scan + 1; if Scan > Expression'Last then return False; end if; exit when not Is_Digit (Expression (Scan)); end loop; end if; return Expression (Scan) = '}'; end Is_Curly_Operator; ------------- -- Is_Mult -- ------------- function Is_Mult (IP : Natural) return Boolean is C : constant Character := Expression (IP); begin return C = '*' or else C = '+' or else C = '?' or else (C = '{' and then Is_Curly_Operator (IP)); end Is_Mult; ----------------------- -- Link_Operand_Tail -- ----------------------- procedure Link_Operand_Tail (P, Val : Pointer) is begin if P <= PM.Size and then Program (P) = BRANCH then Link_Tail (Operand (P), Val); end if; end Link_Operand_Tail; --------------- -- Link_Tail -- --------------- procedure Link_Tail (P, Val : Pointer) is Scan : Pointer; Temp : Pointer; Offset : Pointer; begin -- Find last node (the size of the pattern matcher might be too -- small, so don't try to read past its end). Scan := P; while Scan + Next_Pointer_Bytes <= PM.Size loop Temp := Get_Next (Program, Scan); exit when Temp = Scan; Scan := Temp; end loop; Offset := Val - Scan; Emit_Natural (Scan + 1, Natural (Offset)); end Link_Tail; ----------- -- Parse -- ----------- -- Combining parenthesis handling with the base level of regular -- expression is a trifle forced, but the need to tie the tails of the -- the branches to what follows makes it hard to avoid. procedure Parse (Parenthesized : Boolean; Capturing : Boolean; Flags : out Expression_Flags; IP : out Pointer) is E : String renames Expression; Br, Br2 : Pointer; Ender : Pointer; Par_No : Natural; New_Flags : Expression_Flags; Have_Branch : Boolean := False; begin Flags := (Has_Width => True, others => False); -- Tentatively -- Make an OPEN node, if parenthesized if Parenthesized and then Capturing then if Matcher.Paren_Count > Max_Paren_Count then Fail ("too many ()"); end if; Par_No := Matcher.Paren_Count + 1; Matcher.Paren_Count := Matcher.Paren_Count + 1; IP := Emit_Node (OPEN); Emit (Character'Val (Par_No)); else IP := 0; Par_No := 0; end if; -- Pick up the branches, linking them together Parse_Branch (New_Flags, True, Br); if Br = 0 then IP := 0; return; end if; if Parse_Pos <= Parse_End and then E (Parse_Pos) = '|' then Insert_Operator (BRANCH, Br); Have_Branch := True; end if; if IP /= 0 then Link_Tail (IP, Br); -- OPEN -> first else IP := Br; end if; if not New_Flags.Has_Width then Flags.Has_Width := False; end if; Flags.SP_Start := Flags.SP_Start or else New_Flags.SP_Start; while Parse_Pos <= Parse_End and then (E (Parse_Pos) = '|') loop Parse_Pos := Parse_Pos + 1; Parse_Branch (New_Flags, False, Br); if Br = 0 then IP := 0; return; end if; Link_Tail (IP, Br); -- BRANCH -> BRANCH if not New_Flags.Has_Width then Flags.Has_Width := False; end if; Flags.SP_Start := Flags.SP_Start or else New_Flags.SP_Start; end loop; -- Make a closing node, and hook it on the end if Parenthesized then if Capturing then Ender := Emit_Node (CLOSE); Emit (Character'Val (Par_No)); Link_Tail (IP, Ender); else -- Need to keep looking after the closing parenthesis Ender := Emit_Ptr; end if; else Ender := Emit_Node (EOP); Link_Tail (IP, Ender); end if; if Have_Branch and then Emit_Ptr <= PM.Size + 1 then -- Hook the tails of the branches to the closing node Br := IP; loop Link_Operand_Tail (Br, Ender); Br2 := Get_Next (Program, Br); exit when Br2 = Br; Br := Br2; end loop; end if; -- Check for proper termination if Parenthesized then if Parse_Pos > Parse_End or else E (Parse_Pos) /= ')' then Fail ("unmatched ()"); end if; Parse_Pos := Parse_Pos + 1; elsif Parse_Pos <= Parse_End then if E (Parse_Pos) = ')' then Fail ("unmatched ')'"); else Fail ("junk on end"); -- "Can't happen" end if; end if; end Parse; ---------------- -- Parse_Atom -- ---------------- procedure Parse_Atom (Expr_Flags : out Expression_Flags; IP : out Pointer) is C : Character; begin -- Tentatively set worst expression case Expr_Flags := Worst_Expression; C := Expression (Parse_Pos); Parse_Pos := Parse_Pos + 1; case (C) is when '^' => IP := Emit_Node (if (Flags and Multiple_Lines) /= 0 then MBOL elsif (Flags and Single_Line) /= 0 then SBOL else BOL); when '$' => IP := Emit_Node (if (Flags and Multiple_Lines) /= 0 then MEOL elsif (Flags and Single_Line) /= 0 then SEOL else EOL); when '.' => IP := Emit_Node (if (Flags and Single_Line) /= 0 then SANY else ANY); Expr_Flags.Has_Width := True; Expr_Flags.Simple := True; when '[' => Parse_Character_Class (IP); Expr_Flags.Has_Width := True; Expr_Flags.Simple := True; when '(' => declare New_Flags : Expression_Flags; begin if Parse_Pos <= Parse_End - 1 and then Expression (Parse_Pos) = '?' and then Expression (Parse_Pos + 1) = ':' then Parse_Pos := Parse_Pos + 2; -- Non-capturing parenthesis Parse (True, False, New_Flags, IP); else -- Capturing parenthesis Parse (True, True, New_Flags, IP); Expr_Flags.Has_Width := Expr_Flags.Has_Width or else New_Flags.Has_Width; Expr_Flags.SP_Start := Expr_Flags.SP_Start or else New_Flags.SP_Start; if IP = 0 then return; end if; end if; end; when '|' | ASCII.LF | ')' => Fail ("internal urp"); -- Supposed to be caught earlier when '?' | '+' | '*' => Fail (C & " follows nothing"); when '{' => if Is_Curly_Operator (Parse_Pos - 1) then Fail (C & " follows nothing"); else Parse_Literal (Expr_Flags, IP); end if; when '\' => if Parse_Pos > Parse_End then Fail ("trailing \"); end if; Parse_Pos := Parse_Pos + 1; case Expression (Parse_Pos - 1) is when 'b' => IP := Emit_Node (BOUND); when 'B' => IP := Emit_Node (NBOUND); when 's' => IP := Emit_Node (SPACE); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'S' => IP := Emit_Node (NSPACE); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'd' => IP := Emit_Node (DIGIT); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'D' => IP := Emit_Node (NDIGIT); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'w' => IP := Emit_Node (ALNUM); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'W' => IP := Emit_Node (NALNUM); Expr_Flags.Simple := True; Expr_Flags.Has_Width := True; when 'A' => IP := Emit_Node (SBOL); when 'G' => IP := Emit_Node (SEOL); when '0' .. '9' => IP := Emit_Node (REFF); declare Save : constant Natural := Parse_Pos - 1; begin while Parse_Pos <= Expression'Last and then Is_Digit (Expression (Parse_Pos)) loop Parse_Pos := Parse_Pos + 1; end loop; Emit (Character'Val (Natural'Value (Expression (Save .. Parse_Pos - 1)))); end; when others => Parse_Pos := Parse_Pos - 1; Parse_Literal (Expr_Flags, IP); end case; when others => Parse_Literal (Expr_Flags, IP); end case; end Parse_Atom; ------------------ -- Parse_Branch -- ------------------ procedure Parse_Branch (Flags : out Expression_Flags; First : Boolean; IP : out Pointer) is E : String renames Expression; Chain : Pointer; Last : Pointer; New_Flags : Expression_Flags; Discard : Pointer; pragma Warnings (Off, Discard); begin Flags := Worst_Expression; -- Tentatively IP := (if First then Emit_Ptr else Emit_Node (BRANCH)); Chain := 0; while Parse_Pos <= Parse_End and then E (Parse_Pos) /= ')' and then E (Parse_Pos) /= ASCII.LF and then E (Parse_Pos) /= '|' loop Parse_Piece (New_Flags, Last); if Last = 0 then IP := 0; return; end if; Flags.Has_Width := Flags.Has_Width or else New_Flags.Has_Width; if Chain = 0 then -- First piece Flags.SP_Start := Flags.SP_Start or else New_Flags.SP_Start; else Link_Tail (Chain, Last); end if; Chain := Last; end loop; -- Case where loop ran zero CURLY if Chain = 0 then Discard := Emit_Node (NOTHING); end if; end Parse_Branch; --------------------------- -- Parse_Character_Class -- --------------------------- procedure Parse_Character_Class (IP : out Pointer) is Bitmap : Character_Class; Invert : Boolean := False; In_Range : Boolean := False; Named_Class : Std_Class := ANYOF_NONE; Value : Character; Last_Value : Character := ASCII.NUL; begin Reset_Class (Bitmap); -- Do we have an invert character class ? if Parse_Pos <= Parse_End and then Expression (Parse_Pos) = '^' then Invert := True; Parse_Pos := Parse_Pos + 1; end if; -- First character can be ] or - without closing the class if Parse_Pos <= Parse_End and then (Expression (Parse_Pos) = ']' or else Expression (Parse_Pos) = '-') then Set_In_Class (Bitmap, Expression (Parse_Pos)); Parse_Pos := Parse_Pos + 1; end if; -- While we don't have the end of the class while Parse_Pos <= Parse_End and then Expression (Parse_Pos) /= ']' loop Named_Class := ANYOF_NONE; Value := Expression (Parse_Pos); Parse_Pos := Parse_Pos + 1; -- Do we have a Posix character class if Value = '[' then Named_Class := Parse_Posix_Character_Class; elsif Value = '\' then if Parse_Pos = Parse_End then Fail ("Trailing \"); end if; Value := Expression (Parse_Pos); Parse_Pos := Parse_Pos + 1; case Value is when 'w' => Named_Class := ANYOF_ALNUM; when 'W' => Named_Class := ANYOF_NALNUM; when 's' => Named_Class := ANYOF_SPACE; when 'S' => Named_Class := ANYOF_NSPACE; when 'd' => Named_Class := ANYOF_DIGIT; when 'D' => Named_Class := ANYOF_NDIGIT; when 'n' => Value := ASCII.LF; when 'r' => Value := ASCII.CR; when 't' => Value := ASCII.HT; when 'f' => Value := ASCII.FF; when 'e' => Value := ASCII.ESC; when 'a' => Value := ASCII.BEL; -- when 'x' => ??? hexadecimal value -- when 'c' => ??? control character -- when '0'..'9' => ??? octal character when others => null; end case; end if; -- Do we have a character class? if Named_Class /= ANYOF_NONE then -- A range like 'a-\d' or 'a-[:digit:] is not a range if In_Range then Set_In_Class (Bitmap, Last_Value); Set_In_Class (Bitmap, '-'); In_Range := False; end if; -- Expand the range case Named_Class is when ANYOF_NONE => null; when ANYOF_ALNUM | ANYOF_ALNUMC => for Value in Class_Byte'Range loop if Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NALNUM | ANYOF_NALNUMC => for Value in Class_Byte'Range loop if not Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_SPACE => for Value in Class_Byte'Range loop if Is_White_Space (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NSPACE => for Value in Class_Byte'Range loop if not Is_White_Space (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_DIGIT => for Value in Class_Byte'Range loop if Is_Digit (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NDIGIT => for Value in Class_Byte'Range loop if not Is_Digit (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_ALPHA => for Value in Class_Byte'Range loop if Is_Letter (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NALPHA => for Value in Class_Byte'Range loop if not Is_Letter (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_ASCII => for Value in 0 .. 127 loop Set_In_Class (Bitmap, Character'Val (Value)); end loop; when ANYOF_NASCII => for Value in 128 .. 255 loop Set_In_Class (Bitmap, Character'Val (Value)); end loop; when ANYOF_CNTRL => for Value in Class_Byte'Range loop if Is_Control (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NCNTRL => for Value in Class_Byte'Range loop if not Is_Control (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_GRAPH => for Value in Class_Byte'Range loop if Is_Graphic (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NGRAPH => for Value in Class_Byte'Range loop if not Is_Graphic (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_LOWER => for Value in Class_Byte'Range loop if Is_Lower (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NLOWER => for Value in Class_Byte'Range loop if not Is_Lower (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_PRINT => for Value in Class_Byte'Range loop if Is_Printable (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NPRINT => for Value in Class_Byte'Range loop if not Is_Printable (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_PUNCT => for Value in Class_Byte'Range loop if Is_Printable (Character'Val (Value)) and then not Is_White_Space (Character'Val (Value)) and then not Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NPUNCT => for Value in Class_Byte'Range loop if not Is_Printable (Character'Val (Value)) or else Is_White_Space (Character'Val (Value)) or else Is_Alnum (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_UPPER => for Value in Class_Byte'Range loop if Is_Upper (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NUPPER => for Value in Class_Byte'Range loop if not Is_Upper (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_XDIGIT => for Value in Class_Byte'Range loop if Is_Hexadecimal_Digit (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; when ANYOF_NXDIGIT => for Value in Class_Byte'Range loop if not Is_Hexadecimal_Digit (Character'Val (Value)) then Set_In_Class (Bitmap, Character'Val (Value)); end if; end loop; end case; -- Not a character range elsif not In_Range then Last_Value := Value; if Parse_Pos > Expression'Last then Fail ("Empty character class []"); end if; if Expression (Parse_Pos) = '-' and then Parse_Pos < Parse_End and then Expression (Parse_Pos + 1) /= ']' then Parse_Pos := Parse_Pos + 1; In_Range := True; else Set_In_Class (Bitmap, Value); end if; -- Else in a character range else if Last_Value > Value then Fail ("Invalid Range [" & Last_Value'Img & "-" & Value'Img & "]"); end if; while Last_Value <= Value loop Set_In_Class (Bitmap, Last_Value); Last_Value := Character'Succ (Last_Value); end loop; In_Range := False; end if; end loop; -- Optimize case-insensitive ranges (put the upper case or lower -- case character into the bitmap) if (Flags and Case_Insensitive) /= 0 then for C in Character'Range loop if Get_From_Class (Bitmap, C) then Set_In_Class (Bitmap, To_Lower (C)); Set_In_Class (Bitmap, To_Upper (C)); end if; end loop; end if; -- Optimize inverted classes if Invert then for J in Bitmap'Range loop Bitmap (J) := not Bitmap (J); end loop; end if; Parse_Pos := Parse_Pos + 1; -- Emit the class IP := Emit_Node (ANYOF); Emit_Class (Bitmap); end Parse_Character_Class; ------------------- -- Parse_Literal -- ------------------- -- This is a bit tricky due to quoted chars and due to -- the multiplier characters '*', '+', and '?' that -- take the SINGLE char previous as their operand. -- On entry, the character at Parse_Pos - 1 is going to go -- into the string, no matter what it is. It could be -- following a \ if Parse_Atom was entered from the '\' case. -- Basic idea is to pick up a good char in C and examine -- the next char. If Is_Mult (C) then twiddle, if it's a \ -- then frozzle and if it's another magic char then push C and -- terminate the string. If none of the above, push C on the -- string and go around again. -- Start_Pos is used to remember where "the current character" -- starts in the string, if due to an Is_Mult we need to back -- up and put the current char in a separate 1-character string. -- When Start_Pos is 0, C is the only char in the string; -- this is used in Is_Mult handling, and in setting the SIMPLE -- flag at the end. procedure Parse_Literal (Expr_Flags : out Expression_Flags; IP : out Pointer) is Start_Pos : Natural := 0; C : Character; Length_Ptr : Pointer; Has_Special_Operator : Boolean := False; begin Expr_Flags := Worst_Expression; -- Ensure Expr_Flags is initialized Parse_Pos := Parse_Pos - 1; -- Look at current character IP := Emit_Node (if (Flags and Case_Insensitive) /= 0 then EXACTF else EXACT); Length_Ptr := Emit_Ptr; Emit_Ptr := String_Operand (IP); Parse_Loop : loop C := Expression (Parse_Pos); -- Get current character case C is when '.' | '[' | '(' | ')' | '|' | ASCII.LF | '$' | '^' => if Start_Pos = 0 then Start_Pos := Parse_Pos; Emit (C); -- First character is always emitted else exit Parse_Loop; -- Else we are done end if; when '?' | '+' | '*' | '{' => if Start_Pos = 0 then Start_Pos := Parse_Pos; Emit (C); -- First character is always emitted -- Are we looking at an operator, or is this -- simply a normal character ? elsif not Is_Mult (Parse_Pos) then Start_Pos := Parse_Pos; Case_Emit (C); else -- We've got something like "abc?d". Mark this as a -- special case. What we want to emit is a first -- constant string for "ab", then one for "c" that will -- ultimately be transformed with a CURLY operator, A -- special case has to be handled for "a?", since there -- is no initial string to emit. Has_Special_Operator := True; exit Parse_Loop; end if; when '\' => Start_Pos := Parse_Pos; if Parse_Pos = Parse_End then Fail ("Trailing \"); else case Expression (Parse_Pos + 1) is when 'b' | 'B' | 's' | 'S' | 'd' | 'D' | 'w' | 'W' | '0' .. '9' | 'G' | 'A' => exit Parse_Loop; when 'n' => Emit (ASCII.LF); when 't' => Emit (ASCII.HT); when 'r' => Emit (ASCII.CR); when 'f' => Emit (ASCII.FF); when 'e' => Emit (ASCII.ESC); when 'a' => Emit (ASCII.BEL); when others => Emit (Expression (Parse_Pos + 1)); end case; Parse_Pos := Parse_Pos + 1; end if; when others => Start_Pos := Parse_Pos; Case_Emit (C); end case; Parse_Pos := Parse_Pos + 1; exit Parse_Loop when Parse_Pos > Parse_End or else Emit_Ptr - Length_Ptr = 254; end loop Parse_Loop; -- Is the string followed by a '*+?{' operator ? If yes, and if there -- is an initial string to emit, do it now. if Has_Special_Operator and then Emit_Ptr >= Length_Ptr + Next_Pointer_Bytes then Emit_Ptr := Emit_Ptr - 1; Parse_Pos := Start_Pos; end if; if Length_Ptr <= PM.Size then Program (Length_Ptr) := Character'Val (Emit_Ptr - Length_Ptr - 2); end if; Expr_Flags.Has_Width := True; -- Slight optimization when there is a single character if Emit_Ptr = Length_Ptr + 2 then Expr_Flags.Simple := True; end if; end Parse_Literal; ----------------- -- Parse_Piece -- ----------------- -- Note that the branching code sequences used for '?' and the -- general cases of '*' and + are somewhat optimized: they use -- the same NOTHING node as both the endmarker for their branch -- list and the body of the last branch. It might seem that -- this node could be dispensed with entirely, but the endmarker -- role is not redundant. procedure Parse_Piece (Expr_Flags : out Expression_Flags; IP : out Pointer) is Op : Character; New_Flags : Expression_Flags; Greedy : Boolean := True; begin Parse_Atom (New_Flags, IP); if IP = 0 or else Parse_Pos > Parse_End or else not Is_Mult (Parse_Pos) then Expr_Flags := New_Flags; return; end if; Op := Expression (Parse_Pos); Expr_Flags := (if Op /= '+' then (SP_Start => True, others => False) else (Has_Width => True, others => False)); -- Detect non greedy operators in the easy cases if Op /= '{' and then Parse_Pos + 1 <= Parse_End and then Expression (Parse_Pos + 1) = '?' then Greedy := False; Parse_Pos := Parse_Pos + 1; end if; -- Generate the byte code case Op is when '*' => if New_Flags.Simple then Insert_Operator (STAR, IP, Greedy); else Link_Tail (IP, Emit_Node (WHILEM)); Insert_Curly_Operator (CURLYX, 0, Max_Curly_Repeat, IP, Greedy); Link_Tail (IP, Emit_Node (NOTHING)); end if; when '+' => if New_Flags.Simple then Insert_Operator (PLUS, IP, Greedy); else Link_Tail (IP, Emit_Node (WHILEM)); Insert_Curly_Operator (CURLYX, 1, Max_Curly_Repeat, IP, Greedy); Link_Tail (IP, Emit_Node (NOTHING)); end if; when '?' => if New_Flags.Simple then Insert_Curly_Operator (CURLY, 0, 1, IP, Greedy); else Link_Tail (IP, Emit_Node (WHILEM)); Insert_Curly_Operator (CURLYX, 0, 1, IP, Greedy); Link_Tail (IP, Emit_Node (NOTHING)); end if; when '{' => declare Min, Max : Natural; begin Get_Curly_Arguments (Parse_Pos, Min, Max, Greedy); if New_Flags.Simple then Insert_Curly_Operator (CURLY, Min, Max, IP, Greedy); else Link_Tail (IP, Emit_Node (WHILEM)); Insert_Curly_Operator (CURLYX, Min, Max, IP, Greedy); Link_Tail (IP, Emit_Node (NOTHING)); end if; end; when others => null; end case; Parse_Pos := Parse_Pos + 1; if Parse_Pos <= Parse_End and then Is_Mult (Parse_Pos) then Fail ("nested *+{"); end if; end Parse_Piece; --------------------------------- -- Parse_Posix_Character_Class -- --------------------------------- function Parse_Posix_Character_Class return Std_Class is Invert : Boolean := False; Class : Std_Class := ANYOF_NONE; E : String renames Expression; -- Class names. Note that code assumes that the length of all -- classes starting with the same letter have the same length. Alnum : constant String := "alnum:]"; Alpha : constant String := "alpha:]"; Ascii_C : constant String := "ascii:]"; Cntrl : constant String := "cntrl:]"; Digit : constant String := "digit:]"; Graph : constant String := "graph:]"; Lower : constant String := "lower:]"; Print : constant String := "print:]"; Punct : constant String := "punct:]"; Space : constant String := "space:]"; Upper : constant String := "upper:]"; Word : constant String := "word:]"; Xdigit : constant String := "xdigit:]"; begin -- Case of character class specified if Parse_Pos <= Parse_End and then Expression (Parse_Pos) = ':' then Parse_Pos := Parse_Pos + 1; -- Do we have something like: [[:^alpha:]] if Parse_Pos <= Parse_End and then Expression (Parse_Pos) = '^' then Invert := True; Parse_Pos := Parse_Pos + 1; end if; -- Check for class names based on first letter case Expression (Parse_Pos) is when 'a' => -- All 'a' classes have the same length (Alnum'Length) if Parse_Pos + Alnum'Length - 1 <= Parse_End then if E (Parse_Pos .. Parse_Pos + Alnum'Length - 1) = Alnum then Class := (if Invert then ANYOF_NALNUMC else ANYOF_ALNUMC); Parse_Pos := Parse_Pos + Alnum'Length; elsif E (Parse_Pos .. Parse_Pos + Alpha'Length - 1) = Alpha then Class := (if Invert then ANYOF_NALPHA else ANYOF_ALPHA); Parse_Pos := Parse_Pos + Alpha'Length; elsif E (Parse_Pos .. Parse_Pos + Ascii_C'Length - 1) = Ascii_C then Class := (if Invert then ANYOF_NASCII else ANYOF_ASCII); Parse_Pos := Parse_Pos + Ascii_C'Length; else Fail ("Invalid character class: " & E); end if; else Fail ("Invalid character class: " & E); end if; when 'c' => if Parse_Pos + Cntrl'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Cntrl'Length - 1) = Cntrl then Class := (if Invert then ANYOF_NCNTRL else ANYOF_CNTRL); Parse_Pos := Parse_Pos + Cntrl'Length; else Fail ("Invalid character class: " & E); end if; when 'd' => if Parse_Pos + Digit'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Digit'Length - 1) = Digit then Class := (if Invert then ANYOF_NDIGIT else ANYOF_DIGIT); Parse_Pos := Parse_Pos + Digit'Length; end if; when 'g' => if Parse_Pos + Graph'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Graph'Length - 1) = Graph then Class := (if Invert then ANYOF_NGRAPH else ANYOF_GRAPH); Parse_Pos := Parse_Pos + Graph'Length; else Fail ("Invalid character class: " & E); end if; when 'l' => if Parse_Pos + Lower'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Lower'Length - 1) = Lower then Class := (if Invert then ANYOF_NLOWER else ANYOF_LOWER); Parse_Pos := Parse_Pos + Lower'Length; else Fail ("Invalid character class: " & E); end if; when 'p' => -- All 'p' classes have the same length if Parse_Pos + Print'Length - 1 <= Parse_End then if E (Parse_Pos .. Parse_Pos + Print'Length - 1) = Print then Class := (if Invert then ANYOF_NPRINT else ANYOF_PRINT); Parse_Pos := Parse_Pos + Print'Length; elsif E (Parse_Pos .. Parse_Pos + Punct'Length - 1) = Punct then Class := (if Invert then ANYOF_NPUNCT else ANYOF_PUNCT); Parse_Pos := Parse_Pos + Punct'Length; else Fail ("Invalid character class: " & E); end if; else Fail ("Invalid character class: " & E); end if; when 's' => if Parse_Pos + Space'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Space'Length - 1) = Space then Class := (if Invert then ANYOF_NSPACE else ANYOF_SPACE); Parse_Pos := Parse_Pos + Space'Length; else Fail ("Invalid character class: " & E); end if; when 'u' => if Parse_Pos + Upper'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Upper'Length - 1) = Upper then Class := (if Invert then ANYOF_NUPPER else ANYOF_UPPER); Parse_Pos := Parse_Pos + Upper'Length; else Fail ("Invalid character class: " & E); end if; when 'w' => if Parse_Pos + Word'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Word'Length - 1) = Word then Class := (if Invert then ANYOF_NALNUM else ANYOF_ALNUM); Parse_Pos := Parse_Pos + Word'Length; else Fail ("Invalid character class: " & E); end if; when 'x' => if Parse_Pos + Xdigit'Length - 1 <= Parse_End and then E (Parse_Pos .. Parse_Pos + Xdigit'Length - 1) = Xdigit then Class := (if Invert then ANYOF_NXDIGIT else ANYOF_XDIGIT); Parse_Pos := Parse_Pos + Xdigit'Length; else Fail ("Invalid character class: " & E); end if; when others => Fail ("Invalid character class: " & E); end case; -- Character class not specified else return ANYOF_NONE; end if; return Class; end Parse_Posix_Character_Class; -- Local Declarations Result : Pointer; Expr_Flags : Expression_Flags; -- Start of processing for Compile begin Parse (False, False, Expr_Flags, Result); if Result = 0 then Fail ("Couldn't compile expression"); end if; Final_Code_Size := Emit_Ptr - 1; -- Do we want to actually compile the expression, or simply get the -- code size ??? if Emit_Ptr <= PM.Size then Optimize (PM); end if; PM.Flags := Flags; end Compile; function Compile (Expression : String; Flags : Regexp_Flags := No_Flags) return Pattern_Matcher is -- Assume the compiled regexp will fit in 1000 chars. If it does not we -- will have to compile a second time once the correct size is known. If -- it fits, we save a significant amount of time by avoiding the second -- compilation. Dummy : Pattern_Matcher (1000); Size : Program_Size; begin Compile (Dummy, Expression, Size, Flags); if Size <= Dummy.Size then return Pattern_Matcher' (Size => Size, First => Dummy.First, Anchored => Dummy.Anchored, Must_Have => Dummy.Must_Have, Must_Have_Length => Dummy.Must_Have_Length, Paren_Count => Dummy.Paren_Count, Flags => Dummy.Flags, Program => Dummy.Program (Dummy.Program'First .. Dummy.Program'First + Size - 1)); else -- We have to recompile now that we know the size -- ??? Can we use Ada 2005's return construct ? declare Result : Pattern_Matcher (Size); begin Compile (Result, Expression, Size, Flags); return Result; end; end if; end Compile; procedure Compile (Matcher : out Pattern_Matcher; Expression : String; Flags : Regexp_Flags := No_Flags) is Size : Program_Size; begin Compile (Matcher, Expression, Size, Flags); if Size > Matcher.Size then raise Expression_Error with "Pattern_Matcher is too small"; end if; end Compile; -------------------- -- Dump_Operation -- -------------------- procedure Dump_Operation (Program : Program_Data; Index : Pointer; Indent : Natural) is Current : Pointer := Index; begin Dump_Until (Program, Current, Current + 1, Indent); end Dump_Operation; ---------------- -- Dump_Until -- ---------------- procedure Dump_Until (Program : Program_Data; Index : in out Pointer; Till : Pointer; Indent : Natural; Do_Print : Boolean := True) is function Image (S : String) return String; -- Remove leading space ----------- -- Image -- ----------- function Image (S : String) return String is begin if S (S'First) = ' ' then return S (S'First + 1 .. S'Last); else return S; end if; end Image; -- Local variables Op : Opcode; Next : Pointer; Length : Pointer; Local_Indent : Natural := Indent; -- Start of processing for Dump_Until begin while Index < Till loop Op := Opcode'Val (Character'Pos ((Program (Index)))); Next := Get_Next (Program, Index); if Do_Print then declare Point : constant String := Pointer'Image (Index); begin Put ([1 .. 4 - Point'Length => ' '] & Point & ":" & [1 .. Local_Indent * 2 => ' '] & Opcode'Image (Op)); end; -- Print the parenthesis number if Op = OPEN or else Op = CLOSE or else Op = REFF then Put (Image (Natural'Image (Character'Pos (Program (Index + Next_Pointer_Bytes))))); end if; if Next = Index then Put (" (-)"); else Put (" (" & Image (Pointer'Image (Next)) & ")"); end if; end if; case Op is when ANYOF => declare Bitmap : Character_Class; Last : Character := ASCII.NUL; Current : Natural := 0; Current_Char : Character; begin Bitmap_Operand (Program, Index, Bitmap); if Do_Print then Put ("["); while Current <= 255 loop Current_Char := Character'Val (Current); -- First item in a range if Get_From_Class (Bitmap, Current_Char) then Last := Current_Char; -- Search for the last item in the range loop Current := Current + 1; exit when Current > 255; Current_Char := Character'Val (Current); exit when not Get_From_Class (Bitmap, Current_Char); end loop; if not Is_Graphic (Last) then Put (Last'Img); else Put (Last); end if; if Character'Succ (Last) /= Current_Char then Put ("\-" & Character'Pred (Current_Char)); end if; else Current := Current + 1; end if; end loop; Put_Line ("]"); end if; Index := Index + Next_Pointer_Bytes + Bitmap'Length; end; when EXACT | EXACTF => Length := String_Length (Program, Index); if Do_Print then Put (" (" & Image (Program_Size'Image (Length + 1)) & " chars) <" & String (Program (String_Operand (Index) .. String_Operand (Index) + Length))); Put_Line (">"); end if; Index := String_Operand (Index) + Length + 1; -- Node operand when BRANCH | STAR | PLUS => if Do_Print then New_Line; end if; Index := Index + Next_Pointer_Bytes; Dump_Until (Program, Index, Pointer'Min (Next, Till), Local_Indent + 1, Do_Print); when CURLY | CURLYX => if Do_Print then Put_Line (" {" & Image (Natural'Image (Read_Natural (Program, Index + Next_Pointer_Bytes))) & "," & Image (Natural'Image (Read_Natural (Program, Index + 5))) & "}"); end if; Index := Index + 7; Dump_Until (Program, Index, Pointer'Min (Next, Till), Local_Indent + 1, Do_Print); when OPEN => if Do_Print then New_Line; end if; Index := Index + 4; Local_Indent := Local_Indent + 1; when CLOSE | REFF => if Do_Print then New_Line; end if; Index := Index + 4; if Op = CLOSE then Local_Indent := Local_Indent - 1; end if; when others => Index := Index + Next_Pointer_Bytes; if Do_Print then New_Line; end if; exit when Op = EOP; end case; end loop; end Dump_Until; ---------- -- Dump -- ---------- procedure Dump (Self : Pattern_Matcher) is Program : Program_Data renames Self.Program; Index : Pointer := Program'First; -- Start of processing for Dump begin Put_Line ("Must start with (Self.First) = " & Character'Image (Self.First)); if (Self.Flags and Case_Insensitive) /= 0 then Put_Line (" Case_Insensitive mode"); end if; if (Self.Flags and Single_Line) /= 0 then Put_Line (" Single_Line mode"); end if; if (Self.Flags and Multiple_Lines) /= 0 then Put_Line (" Multiple_Lines mode"); end if; Dump_Until (Program, Index, Self.Program'Last + 1, 0); end Dump; -------------------- -- Get_From_Class -- -------------------- function Get_From_Class (Bitmap : Character_Class; C : Character) return Boolean is Value : constant Class_Byte := Character'Pos (C); begin return (Bitmap (Value / 8) and Bit_Conversion (Value mod 8)) /= 0; end Get_From_Class; -------------- -- Get_Next -- -------------- function Get_Next (Program : Program_Data; IP : Pointer) return Pointer is begin return IP + Pointer (Read_Natural (Program, IP + 1)); end Get_Next; -------------- -- Is_Alnum -- -------------- function Is_Alnum (C : Character) return Boolean is begin return Is_Alphanumeric (C) or else C = '_'; end Is_Alnum; ------------------ -- Is_Printable -- ------------------ function Is_Printable (C : Character) return Boolean is begin -- Printable if space or graphic character or other whitespace -- Other white space includes (HT/LF/VT/FF/CR = codes 9-13) return C in Character'Val (32) .. Character'Val (126) or else C in ASCII.HT .. ASCII.CR; end Is_Printable; -------------------- -- Is_White_Space -- -------------------- function Is_White_Space (C : Character) return Boolean is begin -- Note: HT = 9, LF = 10, VT = 11, FF = 12, CR = 13 return C = ' ' or else C in ASCII.HT .. ASCII.CR; end Is_White_Space; ----------- -- Match -- ----------- procedure Match (Self : Pattern_Matcher; Data : String; Matches : out Match_Array; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) is Program : Program_Data renames Self.Program; -- Shorter notation First_In_Data : constant Integer := Integer'Max (Data_First, Data'First); Last_In_Data : constant Integer := Integer'Min (Data_Last, Data'Last); -- Global work variables Input_Pos : Natural; -- String-input pointer BOL_Pos : Natural; -- Beginning of input, for ^ check Matched : Boolean := False; -- Until proven True Matches_Full : Match_Array (0 .. Natural'Max (Self.Paren_Count, Matches'Last)); -- Stores the value of all the parenthesis pairs. -- We do not use directly Matches, so that we can also use back -- references (REFF) even if Matches is too small. type Natural_Array is array (Match_Count range <>) of Natural; Matches_Tmp : Natural_Array (Matches_Full'Range); -- Save the opening position of parenthesis Last_Paren : Natural := 0; -- Last parenthesis seen Greedy : Boolean := True; -- True if the next operator should be greedy type Current_Curly_Record; type Current_Curly_Access is access all Current_Curly_Record; type Current_Curly_Record is record Paren_Floor : Natural; -- How far back to strip parenthesis data Cur : Integer; -- How many instances of scan we've matched Min : Natural; -- Minimal number of scans to match Max : Natural; -- Maximal number of scans to match Greedy : Boolean; -- Whether to work our way up or down Scan : Pointer; -- The thing to match Next : Pointer; -- What has to match after it Lastloc : Natural; -- Where we started matching this scan Old_Cc : Current_Curly_Access; -- Before we started this one end record; -- Data used to handle the curly operator and the plus and star -- operators for complex expressions. Current_Curly : Current_Curly_Access := null; -- The curly currently being processed ----------------------- -- Local Subprograms -- ----------------------- function Index (Start : Positive; C : Character) return Natural; -- Find character C in Data starting at Start and return position function Repeat (IP : Pointer; Max : Natural := Natural'Last) return Natural; -- Repeatedly match something simple, report how many -- It only matches on things of length 1. -- Starting from Input_Pos, it matches at most Max CURLY. function Try (Pos : Positive) return Boolean; -- Try to match at specific point function Match (IP : Pointer) return Boolean; -- This is the main matching routine. Conceptually the strategy -- is simple: check to see whether the current node matches, -- call self recursively to see whether the rest matches, -- and then act accordingly. -- -- In practice Match makes some effort to avoid recursion, in -- particular by going through "ordinary" nodes (that don't -- need to know whether the rest of the match failed) by -- using a loop instead of recursion. -- Why is the above comment part of the spec rather than body ??? function Match_Whilem return Boolean; -- Return True if a WHILEM matches the Current_Curly function Recurse_Match (IP : Pointer; From : Natural) return Boolean; pragma Inline (Recurse_Match); -- Calls Match recursively. It saves and restores the parenthesis -- status and location in the input stream correctly, so that -- backtracking is possible function Match_Simple_Operator (Op : Opcode; Scan : Pointer; Next : Pointer; Greedy : Boolean) return Boolean; -- Return True it the simple operator (possibly non-greedy) matches Dump_Indent : Integer := -1; procedure Dump_Current (Scan : Pointer; Prefix : Boolean := True); procedure Dump_Error (Msg : String); -- Debug: print the current context pragma Inline (Index); pragma Inline (Repeat); -- These are two complex functions, but used only once pragma Inline (Match_Whilem); pragma Inline (Match_Simple_Operator); ----------- -- Index -- ----------- function Index (Start : Positive; C : Character) return Natural is begin for J in Start .. Last_In_Data loop if Data (J) = C then return J; end if; end loop; return 0; end Index; ------------------- -- Recurse_Match -- ------------------- function Recurse_Match (IP : Pointer; From : Natural) return Boolean is L : constant Natural := Last_Paren; Tmp_F : constant Match_Array := Matches_Full (From + 1 .. Matches_Full'Last); Start : constant Natural_Array := Matches_Tmp (From + 1 .. Matches_Tmp'Last); Input : constant Natural := Input_Pos; Dump_Indent_Save : constant Integer := Dump_Indent; begin if Match (IP) then return True; end if; Last_Paren := L; Matches_Full (Tmp_F'Range) := Tmp_F; Matches_Tmp (Start'Range) := Start; Input_Pos := Input; Dump_Indent := Dump_Indent_Save; return False; end Recurse_Match; ------------------ -- Dump_Current -- ------------------ procedure Dump_Current (Scan : Pointer; Prefix : Boolean := True) is Length : constant := 10; Pos : constant String := Integer'Image (Input_Pos); begin if Prefix then Put ([1 .. 5 - Pos'Length => ' ']); Put (Pos & " <" & Data (Input_Pos .. Integer'Min (Last_In_Data, Input_Pos + Length - 1))); Put ([1 .. Length - 1 - Last_In_Data + Input_Pos => ' ']); Put ("> |"); else Put (" "); end if; Dump_Operation (Program, Scan, Indent => Dump_Indent); end Dump_Current; ---------------- -- Dump_Error -- ---------------- procedure Dump_Error (Msg : String) is begin Put (" | "); Put ([1 .. Dump_Indent * 2 => ' ']); Put_Line (Msg); end Dump_Error; ----------- -- Match -- ----------- function Match (IP : Pointer) return Boolean is Scan : Pointer := IP; Next : Pointer; Op : Opcode; Result : Boolean; begin Dump_Indent := Dump_Indent + 1; State_Machine : loop pragma Assert (Scan /= 0); -- Determine current opcode and count its usage in debug mode Op := Opcode'Val (Character'Pos (Program (Scan))); -- Calculate offset of next instruction. Second character is most -- significant in Program_Data. Next := Get_Next (Program, Scan); if Debug then Dump_Current (Scan); end if; case Op is when EOP => Dump_Indent := Dump_Indent - 1; return True; -- Success when BRANCH => if Program (Next) /= BRANCH then Next := Operand (Scan); -- No choice, avoid recursion else loop if Recurse_Match (Operand (Scan), 0) then Dump_Indent := Dump_Indent - 1; return True; end if; Scan := Get_Next (Program, Scan); exit when Scan = 0 or else Program (Scan) /= BRANCH; end loop; exit State_Machine; end if; when NOTHING => null; when BOL => exit State_Machine when Input_Pos /= BOL_Pos and then ((Self.Flags and Multiple_Lines) = 0 or else Data (Input_Pos - 1) /= ASCII.LF); when MBOL => exit State_Machine when Input_Pos /= BOL_Pos and then Data (Input_Pos - 1) /= ASCII.LF; when SBOL => exit State_Machine when Input_Pos /= BOL_Pos; when EOL => -- A combination of MEOL and SEOL if (Self.Flags and Multiple_Lines) = 0 then -- Single line mode exit State_Machine when Input_Pos <= Data'Last; elsif Input_Pos <= Last_In_Data then exit State_Machine when Data (Input_Pos) /= ASCII.LF; else exit State_Machine when Last_In_Data /= Data'Last; end if; when MEOL => if Input_Pos <= Last_In_Data then exit State_Machine when Data (Input_Pos) /= ASCII.LF; else exit State_Machine when Last_In_Data /= Data'Last; end if; when SEOL => -- If there is a character before Data'Last (even if -- Last_In_Data stops before then), we can't have the -- end of the line. exit State_Machine when Input_Pos <= Data'Last; when BOUND | NBOUND => -- Was last char in word ? declare N : Boolean := False; Ln : Boolean := False; begin if Input_Pos /= First_In_Data then N := Is_Alnum (Data (Input_Pos - 1)); end if; Ln := (if Input_Pos > Last_In_Data then False else Is_Alnum (Data (Input_Pos))); if Op = BOUND then if N = Ln then exit State_Machine; end if; else if N /= Ln then exit State_Machine; end if; end if; end; when SPACE => exit State_Machine when Input_Pos > Last_In_Data or else not Is_White_Space (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NSPACE => exit State_Machine when Input_Pos > Last_In_Data or else Is_White_Space (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when DIGIT => exit State_Machine when Input_Pos > Last_In_Data or else not Is_Digit (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NDIGIT => exit State_Machine when Input_Pos > Last_In_Data or else Is_Digit (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when ALNUM => exit State_Machine when Input_Pos > Last_In_Data or else not Is_Alnum (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when NALNUM => exit State_Machine when Input_Pos > Last_In_Data or else Is_Alnum (Data (Input_Pos)); Input_Pos := Input_Pos + 1; when ANY => exit State_Machine when Input_Pos > Last_In_Data or else Data (Input_Pos) = ASCII.LF; Input_Pos := Input_Pos + 1; when SANY => exit State_Machine when Input_Pos > Last_In_Data; Input_Pos := Input_Pos + 1; when EXACT => declare Opnd : Pointer := String_Operand (Scan); Current : Positive := Input_Pos; Last : constant Pointer := Opnd + String_Length (Program, Scan); begin while Opnd <= Last loop exit State_Machine when Current > Last_In_Data or else Program (Opnd) /= Data (Current); Current := Current + 1; Opnd := Opnd + 1; end loop; Input_Pos := Current; end; when EXACTF => declare Opnd : Pointer := String_Operand (Scan); Current : Positive := Input_Pos; Last : constant Pointer := Opnd + String_Length (Program, Scan); begin while Opnd <= Last loop exit State_Machine when Current > Last_In_Data or else Program (Opnd) /= To_Lower (Data (Current)); Current := Current + 1; Opnd := Opnd + 1; end loop; Input_Pos := Current; end; when ANYOF => declare Bitmap : Character_Class; begin Bitmap_Operand (Program, Scan, Bitmap); exit State_Machine when Input_Pos > Last_In_Data or else not Get_From_Class (Bitmap, Data (Input_Pos)); Input_Pos := Input_Pos + 1; end; when OPEN => declare No : constant Natural := Character'Pos (Program (Operand (Scan))); begin Matches_Tmp (No) := Input_Pos; end; when CLOSE => declare No : constant Natural := Character'Pos (Program (Operand (Scan))); begin Matches_Full (No) := (Matches_Tmp (No), Input_Pos - 1); if Last_Paren < No then Last_Paren := No; end if; end; when REFF => declare No : constant Natural := Character'Pos (Program (Operand (Scan))); Data_Pos : Natural; begin -- If we haven't seen that parenthesis yet if Last_Paren < No then Dump_Indent := Dump_Indent - 1; if Debug then Dump_Error ("REFF: No match, backtracking"); end if; return False; end if; Data_Pos := Matches_Full (No).First; while Data_Pos <= Matches_Full (No).Last loop if Input_Pos > Last_In_Data or else Data (Input_Pos) /= Data (Data_Pos) then Dump_Indent := Dump_Indent - 1; if Debug then Dump_Error ("REFF: No match, backtracking"); end if; return False; end if; Input_Pos := Input_Pos + 1; Data_Pos := Data_Pos + 1; end loop; end; when MINMOD => Greedy := False; when STAR | PLUS | CURLY => declare Greed : constant Boolean := Greedy; begin Greedy := True; Result := Match_Simple_Operator (Op, Scan, Next, Greed); Dump_Indent := Dump_Indent - 1; return Result; end; when CURLYX => -- Looking at something like: -- 1: CURLYX {n,m} (->4) -- 2: code for complex thing (->3) -- 3: WHILEM (->0) -- 4: NOTHING declare Min : constant Natural := Read_Natural (Program, Scan + Next_Pointer_Bytes); Max : constant Natural := Read_Natural (Program, Scan + Next_Pointer_Bytes + 2); Cc : aliased Current_Curly_Record; Has_Match : Boolean; begin Cc := (Paren_Floor => Last_Paren, Cur => -1, Min => Min, Max => Max, Greedy => Greedy, Scan => Scan + 7, Next => Next, Lastloc => 0, Old_Cc => Current_Curly); Greedy := True; Current_Curly := Cc'Unchecked_Access; Has_Match := Match (Next - Next_Pointer_Bytes); -- Start on the WHILEM Current_Curly := Cc.Old_Cc; Dump_Indent := Dump_Indent - 1; if not Has_Match then if Debug then Dump_Error ("CURLYX failed..."); end if; end if; return Has_Match; end; when WHILEM => Result := Match_Whilem; Dump_Indent := Dump_Indent - 1; if Debug and then not Result then Dump_Error ("WHILEM: no match, backtracking"); end if; return Result; end case; Scan := Next; end loop State_Machine; if Debug then Dump_Error ("failed..."); Dump_Indent := Dump_Indent - 1; end if; -- If we get here, there is no match. For successful matches when EOP -- is the terminating point. return False; end Match; --------------------------- -- Match_Simple_Operator -- --------------------------- function Match_Simple_Operator (Op : Opcode; Scan : Pointer; Next : Pointer; Greedy : Boolean) return Boolean is Next_Char : Character := ASCII.NUL; Next_Char_Known : Boolean := False; No : Integer; -- Can be negative Min : Natural; Max : Natural := Natural'Last; Operand_Code : Pointer; Old : Natural; Last_Pos : Natural; Save : constant Natural := Input_Pos; begin -- Lookahead to avoid useless match attempts when we know what -- character comes next. if Program (Next) = EXACT then Next_Char := Program (String_Operand (Next)); Next_Char_Known := True; end if; -- Find the minimal and maximal values for the operator case Op is when STAR => Min := 0; Operand_Code := Operand (Scan); when PLUS => Min := 1; Operand_Code := Operand (Scan); when others => Min := Read_Natural (Program, Scan + Next_Pointer_Bytes); Max := Read_Natural (Program, Scan + Next_Pointer_Bytes + 2); Operand_Code := Scan + 7; end case; if Debug then Dump_Current (Operand_Code, Prefix => False); end if; -- Non greedy operators if not Greedy then -- Test we can repeat at least Min times if Min /= 0 then No := Repeat (Operand_Code, Min); if No < Min then if Debug then Dump_Error ("failed... matched" & No'Img & " times"); end if; return False; end if; end if; Old := Input_Pos; -- Find the place where 'next' could work if Next_Char_Known then -- Last position to check if Max = Natural'Last then Last_Pos := Last_In_Data; else Last_Pos := Input_Pos + Max; if Last_Pos > Last_In_Data then Last_Pos := Last_In_Data; end if; end if; -- Look for the first possible opportunity if Debug then Dump_Error ("Next_Char must be " & Next_Char); end if; loop -- Find the next possible position while Input_Pos <= Last_Pos and then Data (Input_Pos) /= Next_Char loop Input_Pos := Input_Pos + 1; end loop; if Input_Pos > Last_Pos then return False; end if; -- Check that we still match if we stop at the position we -- just found. declare Num : constant Natural := Input_Pos - Old; begin Input_Pos := Old; if Debug then Dump_Error ("Would we still match at that position?"); end if; if Repeat (Operand_Code, Num) < Num then return False; end if; end; -- Input_Pos now points to the new position if Match (Get_Next (Program, Scan)) then return True; end if; Old := Input_Pos; Input_Pos := Input_Pos + 1; end loop; -- We do not know what the next character is else while Max >= Min loop if Debug then Dump_Error ("Non-greedy repeat, N=" & Min'Img); Dump_Error ("Do we still match Next if we stop here?"); end if; -- If the next character matches if Recurse_Match (Next, 1) then return True; end if; Input_Pos := Save + Min; -- Could not or did not match -- move forward if Repeat (Operand_Code, 1) /= 0 then Min := Min + 1; else if Debug then Dump_Error ("Non-greedy repeat failed..."); end if; return False; end if; end loop; end if; return False; -- Greedy operators else No := Repeat (Operand_Code, Max); if Debug and then No < Min then Dump_Error ("failed... matched" & No'Img & " times"); end if; -- ??? Perl has some special code here in case the next -- instruction is of type EOL, since $ and \Z can match before -- *and* after newline at the end. -- ??? Perl has some special code here in case (paren) is True -- Else, if we don't have any parenthesis while No >= Min loop if not Next_Char_Known or else (Input_Pos <= Last_In_Data and then Data (Input_Pos) = Next_Char) then if Match (Next) then return True; end if; end if; -- Could not or did not work, we back up No := No - 1; Input_Pos := Save + No; end loop; return False; end if; end Match_Simple_Operator; ------------------ -- Match_Whilem -- ------------------ -- This is really hard to understand, because after we match what we -- are trying to match, we must make sure the rest of the REx is going -- to match for sure, and to do that we have to go back UP the parse -- tree by recursing ever deeper. And if it fails, we have to reset -- our parent's current state that we can try again after backing off. function Match_Whilem return Boolean is Cc : constant Current_Curly_Access := Current_Curly; N : constant Natural := Cc.Cur + 1; Ln : Natural := 0; Lastloc : constant Natural := Cc.Lastloc; -- Detection of 0-len begin -- If degenerate scan matches "", assume scan done if Input_Pos = Cc.Lastloc and then N >= Cc.Min then -- Temporarily restore the old context, and check that we -- match was comes after CURLYX. Current_Curly := Cc.Old_Cc; if Current_Curly /= null then Ln := Current_Curly.Cur; end if; if Match (Cc.Next) then return True; end if; if Current_Curly /= null then Current_Curly.Cur := Ln; end if; Current_Curly := Cc; return False; end if; -- First, just match a string of min scans if N < Cc.Min then Cc.Cur := N; Cc.Lastloc := Input_Pos; if Debug then Dump_Error ("Tests that we match at least" & Cc.Min'Img & " N=" & N'Img); end if; if Match (Cc.Scan) then return True; end if; Cc.Cur := N - 1; Cc.Lastloc := Lastloc; if Debug then Dump_Error ("failed..."); end if; return False; end if; -- Prefer next over scan for minimal matching if not Cc.Greedy then Current_Curly := Cc.Old_Cc; if Current_Curly /= null then Ln := Current_Curly.Cur; end if; if Recurse_Match (Cc.Next, Cc.Paren_Floor) then return True; end if; if Current_Curly /= null then Current_Curly.Cur := Ln; end if; Current_Curly := Cc; -- Maximum greed exceeded ? if N >= Cc.Max then if Debug then Dump_Error ("failed..."); end if; return False; end if; -- Try scanning more and see if it helps Cc.Cur := N; Cc.Lastloc := Input_Pos; if Debug then Dump_Error ("Next failed, what about Current?"); end if; if Recurse_Match (Cc.Scan, Cc.Paren_Floor) then return True; end if; Cc.Cur := N - 1; Cc.Lastloc := Lastloc; return False; end if; -- Prefer scan over next for maximal matching if N < Cc.Max then -- more greed allowed ? Cc.Cur := N; Cc.Lastloc := Input_Pos; if Debug then Dump_Error ("Recurse at current position"); end if; if Recurse_Match (Cc.Scan, Cc.Paren_Floor) then return True; end if; end if; -- Failed deeper matches of scan, so see if this one works Current_Curly := Cc.Old_Cc; if Current_Curly /= null then Ln := Current_Curly.Cur; end if; if Debug then Dump_Error ("Failed matching for later positions"); end if; if Match (Cc.Next) then return True; end if; if Current_Curly /= null then Current_Curly.Cur := Ln; end if; Current_Curly := Cc; Cc.Cur := N - 1; Cc.Lastloc := Lastloc; if Debug then Dump_Error ("failed..."); end if; return False; end Match_Whilem; ------------ -- Repeat -- ------------ function Repeat (IP : Pointer; Max : Natural := Natural'Last) return Natural is Scan : Natural := Input_Pos; Last : Natural; Op : constant Opcode := Opcode'Val (Character'Pos (Program (IP))); Count : Natural; C : Character; Bitmap : Character_Class; begin if Max = Natural'Last or else Scan + Max - 1 > Last_In_Data then Last := Last_In_Data; else Last := Scan + Max - 1; end if; case Op is when ANY => while Scan <= Last and then Data (Scan) /= ASCII.LF loop Scan := Scan + 1; end loop; when SANY => Scan := Last + 1; when EXACT => -- The string has only one character if Repeat was called C := Program (String_Operand (IP)); while Scan <= Last and then C = Data (Scan) loop Scan := Scan + 1; end loop; when EXACTF => -- The string has only one character if Repeat was called C := Program (String_Operand (IP)); while Scan <= Last and then To_Lower (C) = Data (Scan) loop Scan := Scan + 1; end loop; when ANYOF => Bitmap_Operand (Program, IP, Bitmap); while Scan <= Last and then Get_From_Class (Bitmap, Data (Scan)) loop Scan := Scan + 1; end loop; when ALNUM => while Scan <= Last and then Is_Alnum (Data (Scan)) loop Scan := Scan + 1; end loop; when NALNUM => while Scan <= Last and then not Is_Alnum (Data (Scan)) loop Scan := Scan + 1; end loop; when SPACE => while Scan <= Last and then Is_White_Space (Data (Scan)) loop Scan := Scan + 1; end loop; when NSPACE => while Scan <= Last and then not Is_White_Space (Data (Scan)) loop Scan := Scan + 1; end loop; when DIGIT => while Scan <= Last and then Is_Digit (Data (Scan)) loop Scan := Scan + 1; end loop; when NDIGIT => while Scan <= Last and then not Is_Digit (Data (Scan)) loop Scan := Scan + 1; end loop; when others => raise Program_Error; end case; Count := Scan - Input_Pos; Input_Pos := Scan; return Count; end Repeat; --------- -- Try -- --------- function Try (Pos : Positive) return Boolean is begin Input_Pos := Pos; Last_Paren := 0; Matches_Full := [others => No_Match]; if Match (Program_First) then Matches_Full (0) := (Pos, Input_Pos - 1); return True; end if; return False; end Try; -- Start of processing for Match begin -- Do we have the regexp Never_Match? if Self.Size = 0 then Matches := [others => No_Match]; return; end if; -- If there is a "must appear" string, look for it if Self.Must_Have_Length > 0 then declare First : constant Character := Program (Self.Must_Have); Must_First : constant Pointer := Self.Must_Have; Must_Last : constant Pointer := Must_First + Pointer (Self.Must_Have_Length - 1); Next_Try : Natural := Index (First_In_Data, First); begin while Next_Try /= 0 and then Data (Next_Try .. Next_Try + Self.Must_Have_Length - 1) = String (Program (Must_First .. Must_Last)) loop Next_Try := Index (Next_Try + 1, First); end loop; if Next_Try = 0 then Matches := [others => No_Match]; return; -- Not present end if; end; end if; -- Mark beginning of line for ^ BOL_Pos := Data'First; -- Simplest case first: an anchored match need be tried only once if Self.Anchored and then (Self.Flags and Multiple_Lines) = 0 then Matched := Try (First_In_Data); elsif Self.Anchored then declare Next_Try : Natural := First_In_Data; begin -- Test the first position in the buffer Matched := Try (Next_Try); -- Else only test after newlines if not Matched then while Next_Try <= Last_In_Data loop while Next_Try <= Last_In_Data and then Data (Next_Try) /= ASCII.LF loop Next_Try := Next_Try + 1; end loop; Next_Try := Next_Try + 1; if Next_Try <= Last_In_Data then Matched := Try (Next_Try); exit when Matched; end if; end loop; end if; end; elsif Self.First /= ASCII.NUL then -- We know what char (modulo casing) it must start with if (Self.Flags and Case_Insensitive) = 0 or else Self.First not in 'a' .. 'z' then declare Next_Try : Natural := Index (First_In_Data, Self.First); begin while Next_Try /= 0 loop Matched := Try (Next_Try); exit when Matched; Next_Try := Index (Next_Try + 1, Self.First); end loop; end; else declare Uc_First : constant Character := To_Upper (Self.First); function Case_Insensitive_Index (Start : Positive) return Natural; -- Search for both Self.First and To_Upper (Self.First). -- If both are nonzero, return the smaller one; if exactly -- one is nonzero, return it; if both are zero, return zero. --------------------------- -- Case_Insenstive_Index -- --------------------------- function Case_Insensitive_Index (Start : Positive) return Natural is Lc_Index : constant Natural := Index (Start, Self.First); Uc_Index : constant Natural := Index (Start, Uc_First); begin if Lc_Index = 0 then return Uc_Index; elsif Uc_Index = 0 then return Lc_Index; else return Natural'Min (Lc_Index, Uc_Index); end if; end Case_Insensitive_Index; Next_Try : Natural := Case_Insensitive_Index (First_In_Data); begin while Next_Try /= 0 loop Matched := Try (Next_Try); exit when Matched; Next_Try := Case_Insensitive_Index (Next_Try + 1); end loop; end; end if; else -- Messy cases: try all locations (including for the empty string) Matched := Try (First_In_Data); if not Matched then for S in First_In_Data + 1 .. Last_In_Data loop Matched := Try (S); exit when Matched; end loop; end if; end if; -- Matched has its value for J in Last_Paren + 1 .. Matches'Last loop Matches_Full (J) := No_Match; end loop; Matches := Matches_Full (Matches'Range); end Match; ----------- -- Match -- ----------- function Match (Self : Pattern_Matcher; Data : String; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Natural is Matches : Match_Array (0 .. 0); begin Match (Self, Data, Matches, Data_First, Data_Last); if Matches (0) = No_Match then return Data'First - 1; else return Matches (0).First; end if; end Match; function Match (Self : Pattern_Matcher; Data : String; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Boolean is Matches : Match_Array (0 .. 0); begin Match (Self, Data, Matches, Data_First, Data_Last); return Matches (0).First >= Data'First; end Match; procedure Match (Expression : String; Data : String; Matches : out Match_Array; Size : Program_Size := Auto_Size; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) is PM : Pattern_Matcher (Size); Finalize_Size : Program_Size; begin if Size = 0 then Match (Compile (Expression), Data, Matches, Data_First, Data_Last); else Compile (PM, Expression, Finalize_Size); Match (PM, Data, Matches, Data_First, Data_Last); end if; end Match; ----------- -- Match -- ----------- function Match (Expression : String; Data : String; Size : Program_Size := Auto_Size; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Natural is PM : Pattern_Matcher (Size); Final_Size : Program_Size; begin if Size = 0 then return Match (Compile (Expression), Data, Data_First, Data_Last); else Compile (PM, Expression, Final_Size); return Match (PM, Data, Data_First, Data_Last); end if; end Match; ----------- -- Match -- ----------- function Match (Expression : String; Data : String; Size : Program_Size := Auto_Size; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Boolean is Matches : Match_Array (0 .. 0); PM : Pattern_Matcher (Size); Final_Size : Program_Size; begin if Size = 0 then Match (Compile (Expression), Data, Matches, Data_First, Data_Last); else Compile (PM, Expression, Final_Size); Match (PM, Data, Matches, Data_First, Data_Last); end if; return Matches (0).First >= Data'First; end Match; ------------- -- Operand -- ------------- function Operand (P : Pointer) return Pointer is begin return P + Next_Pointer_Bytes; end Operand; -------------- -- Optimize -- -------------- procedure Optimize (Self : in out Pattern_Matcher) is Scan : Pointer; Program : Program_Data renames Self.Program; begin -- Start with safe defaults (no optimization): -- * No known first character of match -- * Does not necessarily start at beginning of line -- * No string known that has to appear in data Self.First := ASCII.NUL; Self.Anchored := False; Self.Must_Have := Program'Last + 1; Self.Must_Have_Length := 0; Scan := Program_First; -- First instruction (can be anything) if Program (Scan) = EXACT then Self.First := Program (String_Operand (Scan)); elsif Program (Scan) = EXACTF then Self.First := To_Lower (Program (String_Operand (Scan))); elsif Program (Scan) = BOL or else Program (Scan) = SBOL or else Program (Scan) = MBOL then Self.Anchored := True; end if; end Optimize; ----------------- -- Paren_Count -- ----------------- function Paren_Count (Regexp : Pattern_Matcher) return Match_Count is begin return Regexp.Paren_Count; end Paren_Count; ----------- -- Quote -- ----------- function Quote (Str : String) return String is S : String (1 .. Str'Length * 2); Last : Natural := 0; begin for J in Str'Range loop case Str (J) is when '^' | '$' | '|' | '*' | '+' | '?' | '{' | '}' | '[' | ']' | '(' | ')' | '\' | '.' => S (Last + 1) := '\'; S (Last + 2) := Str (J); Last := Last + 2; when others => S (Last + 1) := Str (J); Last := Last + 1; end case; end loop; return S (1 .. Last); end Quote; ------------------ -- Read_Natural -- ------------------ function Read_Natural (Program : Program_Data; IP : Pointer) return Natural is begin return Character'Pos (Program (IP)) + 256 * Character'Pos (Program (IP + 1)); end Read_Natural; ----------------- -- Reset_Class -- ----------------- procedure Reset_Class (Bitmap : out Character_Class) is begin Bitmap := [others => 0]; end Reset_Class; ------------------ -- Set_In_Class -- ------------------ procedure Set_In_Class (Bitmap : in out Character_Class; C : Character) is Value : constant Class_Byte := Character'Pos (C); begin Bitmap (Value / 8) := Bitmap (Value / 8) or Bit_Conversion (Value mod 8); end Set_In_Class; ------------------- -- String_Length -- ------------------- function String_Length (Program : Program_Data; P : Pointer) return Program_Size is begin pragma Assert (Program (P) = EXACT or else Program (P) = EXACTF); return Character'Pos (Program (P + Next_Pointer_Bytes)); end String_Length; -------------------- -- String_Operand -- -------------------- function String_Operand (P : Pointer) return Pointer is begin return P + 4; end String_Operand; end System.Regpat;
Rodeo-McCabe/orka
Ada
3,590
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Inputs.Pointers.Default is overriding function Position_X (Object : Abstract_Pointer_Input) return GL.Types.Double is (Object.X); overriding function Position_Y (Object : Abstract_Pointer_Input) return GL.Types.Double is (Object.Y); overriding function Delta_X (Object : Abstract_Pointer_Input) return GL.Types.Double is use type GL.Types.Double; begin return Object.Last_X - Object.Prev_X; end Delta_X; overriding function Delta_Y (Object : Abstract_Pointer_Input) return GL.Types.Double is use type GL.Types.Double; begin return Object.Last_Y - Object.Prev_Y; end Delta_Y; overriding function Scroll_X (Object : Abstract_Pointer_Input) return GL.Types.Double is (Object.Scroll_X); overriding function Scroll_Y (Object : Abstract_Pointer_Input) return GL.Types.Double is (Object.Scroll_Y); overriding function Locked (Object : Abstract_Pointer_Input) return Boolean is (Object.Locked); overriding function Visible (Object : Abstract_Pointer_Input) return Boolean is (Object.Visible); overriding procedure Lock_Pointer (Object : in out Abstract_Pointer_Input; Locked : Boolean) is begin if Object.Locked /= Locked then Object.Locked := Locked; if Locked then Abstract_Pointer_Input'Class (Object).Set_Cursor_Mode (Disabled); else Abstract_Pointer_Input'Class (Object).Set_Cursor_Mode ((if Object.Visible then Normal else Hidden)); end if; end if; end Lock_Pointer; overriding procedure Set_Visible (Object : in out Abstract_Pointer_Input; Visible : Boolean) is begin if Object.Visible /= Visible then Object.Visible := Visible; Abstract_Pointer_Input'Class (Object).Set_Cursor_Mode ((if Visible then Normal else Hidden)); end if; end Set_Visible; overriding function Button_Pressed (Object : Abstract_Pointer_Input; Subject : Button) return Boolean is begin return Object.Buttons (Subject); end Button_Pressed; procedure Set_Position (Object : in out Abstract_Pointer_Input; X, Y : GL.Types.Double) is begin if not Object.Locked then Object.X := X; Object.Y := Y; end if; Object.Prev_X := Object.Last_X; Object.Prev_Y := Object.Last_Y; Object.Last_X := X; Object.Last_Y := Y; end Set_Position; procedure Set_Scroll_Offset (Object : in out Abstract_Pointer_Input; X, Y : GL.Types.Double) is begin Object.Scroll_X := X; Object.Scroll_Y := Y; end Set_Scroll_Offset; procedure Set_Button_State (Object : in out Abstract_Pointer_Input; Subject : Button; State : Button_State) is begin Object.Buttons (Subject) := State = Pressed; end Set_Button_State; end Orka.Inputs.Pointers.Default;
zhmu/ananas
Ada
2,598
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . C A S E _ U T I L -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package does not require a body, since it is a package renaming. We -- provide a dummy file containing a No_Body pragma so that previous versions -- of the body (which did exist) will not interfere. pragma No_Body;
reznikmm/matreshka
Ada
3,806
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.ODF_Attributes.FO.Text_Align; package ODF.DOM.Attributes.FO.Text_Align.Internals is function Create (Node : Matreshka.ODF_Attributes.FO.Text_Align.FO_Text_Align_Access) return ODF.DOM.Attributes.FO.Text_Align.ODF_FO_Text_Align; function Wrap (Node : Matreshka.ODF_Attributes.FO.Text_Align.FO_Text_Align_Access) return ODF.DOM.Attributes.FO.Text_Align.ODF_FO_Text_Align; end ODF.DOM.Attributes.FO.Text_Align.Internals;
stcarrez/ada-asf
Ada
1,824
ads
----------------------------------------------------------------------- -- asf-helpers-beans -- Helper packages to write ASF applications -- Copyright (C) 2012, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Basic; with ASF.Requests; package ASF.Helpers.Beans is -- Get a bean instance associated under the given name from the current faces context. -- A null value is returned if the bean does not exist or is not of the good type. generic type Element_Type is new Util.Beans.Basic.Readonly_Bean with private; type Element_Access is access all Element_Type'Class; function Get_Bean (Name : in String) return Element_Access; -- Get a bean instance associated under the given name from the request. -- A null value is returned if the bean does not exist or is not of the good type. generic type Element_Type is new Util.Beans.Basic.Readonly_Bean with private; type Element_Access is access all Element_Type'Class; function Get_Request_Bean (Request : in ASF.Requests.Request'Class; Name : in String) return Element_Access; end ASF.Helpers.Beans;
AaronC98/PlaneSystem
Ada
21,615
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2017, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Calendar; with Ada.Exceptions; with Ada.Strings.Fixed; with Ada.Text_IO; with GNAT.Calendar.Time_IO; with AWS.Headers; with AWS.Messages; with AWS.MIME; with AWS.Net.Buffered; with AWS.SMTP.Authentication; with AWS.Utils; package body AWS.SMTP.Client is procedure Open (Server : Receiver; Sock : out Net.Socket_Access; Status : out SMTP.Status); -- Open session with a SMTP server procedure Close (Sock : in out Net.Socket_Access; Status : in out SMTP.Status); -- Close session with the SMTP server procedure Output_Header (Sock : Net.Socket_Type'Class; From : E_Mail_Data; To : Recipients; CC : Recipients; BCC : Recipients; Subject : String; Status : out SMTP.Status; Is_MIME : Boolean := False; To_All : Boolean); -- Output SMTP headers (MAIL, RCPT, DATA, From, To, Subject, Date) procedure Output_Simple_Header (Sock : Net.Socket_Type'Class; From : E_Mail_Data; To : Recipients; CC : Recipients; BCC : Recipients; Status : out SMTP.Status; To_All : Boolean); -- Output SMTP protocol commands (MAIL, RCPT, DATA) procedure Put_Translated_Line (Sock : Net.Socket_Type'Class; Text : String); -- Translate a leading dot to two dots procedure Terminate_Mail_Data (Sock : in out Net.Socket_Type'Class); -- Send string CRLF & '.' & CRLF procedure Shutdown (Sock : in out Net.Socket_Access); -- Shutdown and close the socket. Do not raise an exception if the Socket -- is not connected. ----------------- -- Base64_Data -- ----------------- function Base64_Data (Name, Content : String) return Attachment is begin return (Base64_Data, To_Unbounded_String (Name), To_Unbounded_String (Content)); end Base64_Data; ----------- -- Close -- ----------- procedure Close (Sock : in out Net.Socket_Access; Status : in out SMTP.Status) is Answer : Server_Reply; begin Net.Buffered.Put_Line (Sock.all, "QUIT"); Check_Answer (Sock.all, Answer); if Answer.Code /= Service_Closing then Add (Answer, Status); end if; Net.Buffered.Shutdown (Sock.all); Net.Free (Sock); end Close; ---------- -- File -- ---------- function File (Filename : String) return Attachment is begin return (File, To_Unbounded_String (Filename)); end File; ---------- -- Open -- ---------- procedure Open (Server : Receiver; Sock : out Net.Socket_Access; Status : out SMTP.Status) is Answer : Server_Reply; begin -- Clear status code Clear (Status); -- Open server Sock := Net.Socket (Security => Server.Secure); Sock.Set_Timeout (Server.Timeout); Sock.Connect (To_String (Server.Name), Server.Port, Family => Server.Family); -- Check connect message Check_Answer (Sock.all, Answer); if Answer.Code = Service_Ready then -- Open session Net.Buffered.Put_Line (Sock.all, "HELO " & Net.Host_Name); Check_Answer (Sock.all, Answer); -- If no success, close the connection if Answer.Code /= Requested_Action_Ok then Add (Answer, Status); Shutdown (Sock); end if; else Add (Answer, Status); Shutdown (Sock); end if; exception when others => Shutdown (Sock); raise; end Open; ------------------- -- Output_Header -- ------------------- procedure Output_Header (Sock : Net.Socket_Type'Class; From : E_Mail_Data; To : Recipients; CC : Recipients; BCC : Recipients; Subject : String; Status : out SMTP.Status; Is_MIME : Boolean := False; To_All : Boolean) is function Current_Date return String; -- Returns current date and time for SMTP "Date:" field procedure Send (Header_Name : String; Emails : Recipients); -- Write header Header_Name for the corresponding recipients ------------------ -- Current_Date -- ------------------ function Current_Date return String is TZ : constant String := Utils.Time_Zone; begin -- Format is: Mon, 1 Jan 2002 12:00:00 (+/-)HHMM if TZ = "" then return GNAT.Calendar.Time_IO.Image (Calendar.Clock, "%a, %-d %b %Y %T"); else return GNAT.Calendar.Time_IO.Image (Calendar.Clock, "%a, %-d %b %Y %T ") & TZ; end if; end Current_Date; ---------- -- Send -- ---------- procedure Send (Header_Name : String; Emails : Recipients) is begin if Emails /= No_Recipient then Net.Buffered.Put (Sock, Header_Name & ": " & Image (Emails (Emails'First))); for K in Emails'First + 1 .. Emails'Last loop Net.Buffered.Put (Sock, ", " & Image (Emails (K))); end loop; Net.Buffered.New_Line (Sock); end if; end Send; begin -- Output the MAIL, RCPT and DATA headers Output_Simple_Header (Sock, From, To, CC, BCC, Status, To_All); if Is_Ok (Status) then -- Time Stamp Net.Buffered.Put_Line (Sock, "Date: " & Current_Date); -- From Net.Buffered.Put_Line (Sock, "From: " & Image (From)); -- Subject Net.Buffered.Put_Line (Sock, "Subject: " & Subject); -- To Send ("To", To); -- CC Send ("Cc", CC); -- Note that BCC is not sent here as these are the data headers -- sent to the client. The BCC recipients have been added into the -- RCPT TO: fields. if Is_MIME then Net.Buffered.Put_Line (Sock, "MIME-Version: 1.0 (produced by AWS/SMTP)"); else Net.Buffered.New_Line (Sock); end if; end if; end Output_Header; -------------------------- -- Output_Simple_Header -- -------------------------- procedure Output_Simple_Header (Sock : Net.Socket_Type'Class; From : E_Mail_Data; To : Recipients; CC : Recipients; BCC : Recipients; Status : out SMTP.Status; To_All : Boolean) is Have_One : Boolean := False; procedure Send (Emails : Recipients); -- Procedure set to this recipient ---------- -- Send -- ---------- procedure Send (Emails : Recipients) is Answer : Server_Reply; begin for K in Emails'Range loop Net.Buffered.Put_Line (Sock, "RCPT TO:<" & Image (Emails (K), Address) & '>'); Check_Answer (Sock, Answer); if Answer.Code = Requested_Action_Ok then Have_One := True; else Add (Answer, Status); end if; end loop; end Send; Answer : Server_Reply; begin -- MAIL Net.Buffered.Put_Line (Sock, "MAIL FROM:<" & Image (From, Address) & '>'); Check_Answer (Sock, Answer); if Answer.Code = Requested_Action_Ok then -- RCPT Send (To); Send (CC); Send (BCC); if not To_All and then Have_One then Status := (Code => Requested_Action_Ok, Reason => Null_Unbounded_String, Warnings => Status.Reason); end if; if Is_Ok (Status) then -- DATA Net.Buffered.Put_Line (Sock, "DATA"); Check_Answer (Sock, Answer); if Answer.Code /= Start_Mail_Input then -- Not possible to send mail header data Add (Answer, Status); end if; end if; else -- Error in From address Add (Answer, Status); end if; end Output_Simple_Header; ------------------------- -- Put_Translated_Line -- ------------------------- procedure Put_Translated_Line (Sock : Net.Socket_Type'Class; Text : String) is use Ada.Strings; First : Natural := Text'First; LF_Dot : Natural; begin if Text'Length > 0 and then Text (Text'First) = '.' then Net.Buffered.Put (Sock, "."); end if; loop LF_Dot := Fixed.Index (Text, ASCII.LF & '.', First); exit when LF_Dot = 0; Net.Buffered.Put (Sock, Text (First .. LF_Dot + 1)); -- Write dot after line feed twice First := LF_Dot + 1; end loop; Net.Buffered.Put_Line (Sock, Text (First .. Text'Last)); end Put_Translated_Line; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : E_Mail_Data; Subject : String; Message : String; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is begin Send (Server, From, Recipients'(1 => To), Subject, Message, Status, CC, BCC, To_All); end Send; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : E_Mail_Data; Subject : String; Message : String := ""; Attachments : Attachment_Set; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is begin Send (Server, From, Recipients'(1 => To), Subject, Message, Attachments, Status, CC, BCC, To_All); end Send; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : E_Mail_Data; Subject : String; Filename : Message_File; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is Buffer : String (1 .. 2_048); Last : Natural; File : Text_IO.File_Type; Sock : Net.Socket_Access; Answer : Server_Reply; begin -- Open server Open (Server, Sock, Status); if Is_Ok (Status) then if Server.Auth /= null then Server.Auth.Before_Send (Sock.all, Status); end if; if Is_Ok (Status) then Output_Header (Sock.all, From, Recipients'(1 => To), CC, BCC, Subject, Status, To_All => To_All); if Is_Ok (Status) then -- Message body Text_IO.Open (File, Text_IO.In_File, String (Filename)); while not Text_IO.End_Of_File (File) loop Text_IO.Get_Line (File, Buffer, Last); Put_Translated_Line (Sock.all, Buffer (1 .. Last)); end loop; Text_IO.Close (File); Terminate_Mail_Data (Sock.all); Check_Answer (Sock.all, Answer); if Is_Ok (Status) and then Server.Auth /= null then Server.Auth.After_Send (Sock.all, Status); end if; if Answer.Code /= Requested_Action_Ok then Add (Answer, Status); end if; end if; end if; Close (Sock, Status); end if; exception -- Raise Server_Error for all problems encountered when E : others => Shutdown (Sock); if Text_IO.Is_Open (File) then Text_IO.Close (File); end if; raise Server_Error with Ada.Exceptions.Exception_Information (E); end Send; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : Recipients; Subject : String; Message : String; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is Sock : Net.Socket_Access; Answer : Server_Reply; begin Open (Server, Sock, Status); if Is_Ok (Status) then if Server.Auth /= null then Server.Auth.Before_Send (Sock.all, Status); end if; if Is_Ok (Status) then Output_Header (Sock.all, From, To, CC, BCC, Subject, Status, To_All => To_All); if Is_Ok (Status) then -- Message body Put_Translated_Line (Sock.all, Message); Terminate_Mail_Data (Sock.all); Check_Answer (Sock.all, Answer); if Is_Ok (Status) and then Server.Auth /= null then Server.Auth.After_Send (Sock.all, Status); end if; if Answer.Code /= Requested_Action_Ok then Add (Answer, Status); end if; end if; end if; Close (Sock, Status); end if; exception -- Raise Server_Error for all problems encountered when E : others => Shutdown (Sock); raise Server_Error with Ada.Exceptions.Exception_Information (E); end Send; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : Recipients; Source : String; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is Sock : Net.Socket_Access; Answer : Server_Reply; begin Open (Server, Sock, Status); if Is_Ok (Status) then if Server.Auth /= null then Server.Auth.Before_Send (Sock.all, Status); end if; if Is_Ok (Status) then Output_Simple_Header (Sock.all, From, To, CC, BCC, Status, To_All); if Is_Ok (Status) then -- Message body Put_Translated_Line (Sock.all, Source); Terminate_Mail_Data (Sock.all); Check_Answer (Sock.all, Answer); if Is_Ok (Status) and then Server.Auth /= null then Server.Auth.After_Send (Sock.all, Status); end if; if Answer.Code /= Requested_Action_Ok then Add (Answer, Status); end if; end if; end if; Close (Sock, Status); end if; exception -- Raise Server_Error for all problems encountered when E : others => Shutdown (Sock); raise Server_Error with Ada.Exceptions.Exception_Information (E); end Send; ---------- -- Send -- ---------- procedure Send (Server : Receiver; From : E_Mail_Data; To : Recipients; Subject : String; Message : String := ""; Attachments : Attachment_Set; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is Att_List : AWS.Attachments.List; begin -- Fill attachments list if Message /= "" then AWS.Attachments.Add (Att_List, "", AWS.Attachments.Value (Data => Message, Content_Type => MIME.Text_Plain)); end if; for A of Attachments loop declare H : AWS.Headers.List; begin case A.Kind is when File => AWS.Attachments.Add (Att_List, Filename => To_String (A.Name), Content_Id => "", Encode => AWS.Attachments.Base64); when Base64_Data => H.Add (Messages.Content_Transfer_Encoding_Token, "base64"); AWS.Attachments.Add (Att_List, To_String (A.Name), AWS.Attachments.Value (Name => To_String (A.Name), Data => To_String (A.Data)), Headers => H); end case; end; end loop; Send (Server, From, To, Subject, Att_List, Status, CC, BCC, To_All); end Send; procedure Send (Server : Receiver; From : E_Mail_Data; To : Recipients; Subject : String; Attachments : AWS.Attachments.List; Status : out SMTP.Status; CC : Recipients := No_Recipient; BCC : Recipients := No_Recipient; To_All : Boolean := True) is Sock : Net.Socket_Access; Answer : Server_Reply; Boundary : Unbounded_String; begin Open (Server, Sock, Status); if Is_Ok (Status) then if Server.Auth /= null then Server.Auth.Before_Send (Sock.all, Status); end if; if Is_Ok (Status) then Output_Header (Sock.all, From, To, CC, BCC, Subject, Status, Is_MIME => True, To_All => To_All); if Is_Ok (Status) then -- Send MIME header AWS.Attachments.Send_MIME_Header (Sock.all, Attachments, Boundary); -- Message for non-MIME compliant Mail reader Net.Buffered.Put_Line (Sock.all, "This is multipart MIME message"); Net.Buffered.Put_Line (Sock.all, "If you read this, your mailer does not support MIME."); Net.Buffered.New_Line (Sock.all); AWS.Attachments.Send (Sock.all, Attachments, To_String (Boundary)); Terminate_Mail_Data (Sock.all); Check_Answer (Sock.all, Answer); if Is_Ok (Status) and then Server.Auth /= null then Server.Auth.After_Send (Sock.all, Status); end if; if Answer.Code /= Requested_Action_Ok then Add (Answer, Status); end if; end if; end if; Close (Sock, Status); end if; exception -- Raise Server_Error for all problem encountered when E : others => Shutdown (Sock); raise Server_Error with Ada.Exceptions.Exception_Information (E); end Send; -------------- -- Shutdown -- -------------- procedure Shutdown (Sock : in out Net.Socket_Access) is use type Net.Socket_Access; begin if Sock /= null then Net.Buffered.Shutdown (Sock.all); Net.Free (Sock); end if; end Shutdown; ------------------------- -- Terminate_Mail_Data -- ------------------------- procedure Terminate_Mail_Data (Sock : in out Net.Socket_Type'Class) is begin Net.Buffered.New_Line (Sock); Net.Buffered.Put (Sock, "."); Net.Buffered.New_Line (Sock); end Terminate_Mail_Data; end AWS.SMTP.Client;