repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
zhmu/ananas
Ada
2,992
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- B I N D O . E L A B O R A T O R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2019-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. -- -- -- ------------------------------------------------------------------------------ -- For full architecture, see unit Bindo. -- The following unit contains facilities to find the elaboration order of -- units based on various graphs. with Bindo.Graphs; use Bindo.Graphs; use Bindo.Graphs.Invocation_Graphs; use Bindo.Graphs.Library_Graphs; package Bindo.Elaborators is ---------------------------------------------- -- Invocation_And_Library_Graph_Elaborators -- ---------------------------------------------- package Invocation_And_Library_Graph_Elaborators is procedure Elaborate_Units (Order : out Unit_Id_Table; Main_Lib_File : File_Name_Type); -- Find an order of all units in the bind that need to be elaborated -- such that elaboration code flow, pragmas Elaborate, Elaborate_All, -- and Elaborate_Body, and with clause dependencies are all honoured. -- Main_Lib_File is the argument of the bind. If a satisfactory order -- exists, it is returned in Order, otherwise Unrecoverable_Error is -- raised. end Invocation_And_Library_Graph_Elaborators; end Bindo.Elaborators;
AdaCore/training_material
Ada
2,890
ads
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs 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 2 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, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- with Display; use Display; with Display.Basic; use Display.Basic; generic type Bodies_Enum_T is (<>); package Solar_System is -- define type Bodies_Enum_T as an enumeration of Sun, Earth, Moon, -- Satellite ... -- type Bodies_Enum_T is -- (Sun, Earth, Moon, Satellite, Comet, Black_Hole, Asteroid_1, Asteroid_2); type Bodies_Array_T is private; procedure Init_Body (B : Bodies_Enum_T; Bodies : in out Bodies_Array_T; Radius : Float; Color : RGBA_T; Distance : Float; Angle : Float; Speed : Float; Turns_Around : Bodies_Enum_T; Visible : Boolean := True); procedure Set_Center(Bodies : in out Bodies_Array_T; X : Float; Y : Float); procedure Move_All (Bodies : in out Bodies_Array_T); private -- define a type Body_T to store every information about a body -- X, Y, Distance, Speed, Angle, Radius, Color type Body_T is record X : Float := 0.0; Y : Float := 0.0; Distance : Float; Speed : Float; Angle : Float; Radius : Float; Color : RGBA_T; Visible : Boolean := True; Turns_Around : Bodies_Enum_T; end record; -- define type Bodies_Array as an array of Body_Type indexed by bodies enumeration type Bodies_Array_T is array (Bodies_Enum_T) of Body_T; procedure Move (Body_To_Move : in out Body_T; Bodies : Bodies_Array_T); end Solar_System;
alvaromb/Compilemon
Ada
6,249
adb
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE miscellaneous definitions -- AUTHOR: John Self (UCI) -- DESCRIPTION contains all global variables used in aflex. -- also some subprograms which are commonly used. -- NOTES The real purpose of this file is to contain all miscellaneous -- items (functions, MACROS, variables definitions) which were at the -- top level of flex. -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/misc_defsB.a,v 1.5 90/01/12 15:20:21 self Exp Locker: self $ package body misc_defs is -- returns true if an nfa state has an epsilon out-transition slot -- that can be used. This definition is currently not used. function FREE_EPSILON(STATE : in INTEGER) return BOOLEAN is begin return ((TRANSCHAR(STATE) = SYM_EPSILON) and (TRANS2(STATE) = NO_TRANSITION) and (FINALST(STATE) /= STATE)); end FREE_EPSILON; -- returns true if an nfa state has an epsilon out-transition character -- and both slots are free function SUPER_FREE_EPSILON(STATE : in INTEGER) return BOOLEAN is begin return ((TRANSCHAR(STATE) = SYM_EPSILON) and (TRANS1(STATE) = NO_TRANSITION) ); end SUPER_FREE_EPSILON; function ALLOCATE_INTEGER_ARRAY(SIZE : in INTEGER) return INT_PTR is begin return new UNBOUNDED_INT_ARRAY(0 .. SIZE); end ALLOCATE_INTEGER_ARRAY; procedure REALLOCATE_INTEGER_ARRAY(ARR : in out INT_PTR; SIZE : in INTEGER) is NEW_ARR : INT_PTR; begin NEW_ARR := ALLOCATE_INTEGER_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_INTEGER_ARRAY; procedure REALLOCATE_STATE_ENUM_ARRAY(ARR : in out STATE_ENUM_PTR; SIZE : in INTEGER) is NEW_ARR : STATE_ENUM_PTR; begin NEW_ARR := ALLOCATE_STATE_ENUM_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_STATE_ENUM_ARRAY; procedure REALLOCATE_RULE_ENUM_ARRAY(ARR : in out RULE_ENUM_PTR; SIZE : in INTEGER) is NEW_ARR : RULE_ENUM_PTR; begin NEW_ARR := ALLOCATE_RULE_ENUM_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_RULE_ENUM_ARRAY; function ALLOCATE_INT_PTR_ARRAY(SIZE : in INTEGER) return INT_STAR_PTR is begin return new UNBOUNDED_INT_STAR_ARRAY(0 .. SIZE); end ALLOCATE_INT_PTR_ARRAY; function ALLOCATE_RULE_ENUM_ARRAY(SIZE : in INTEGER) return RULE_ENUM_PTR is begin return new UNBOUNDED_RULE_ENUM_ARRAY(0 .. SIZE); end ALLOCATE_RULE_ENUM_ARRAY; function ALLOCATE_STATE_ENUM_ARRAY(SIZE : in INTEGER) return STATE_ENUM_PTR is begin return new UNBOUNDED_STATE_ENUM_ARRAY(0 .. SIZE); end ALLOCATE_STATE_ENUM_ARRAY; function ALLOCATE_BOOLEAN_ARRAY(SIZE : in INTEGER) return BOOLEAN_PTR is begin return new BOOLEAN_ARRAY(0 .. SIZE); end ALLOCATE_BOOLEAN_ARRAY; function ALLOCATE_VSTRING_ARRAY(SIZE : in INTEGER) return VSTRING_PTR is begin return new UNBOUNDED_VSTRING_ARRAY(0 .. SIZE); end ALLOCATE_VSTRING_ARRAY; function ALLOCATE_DFAACC_UNION(SIZE : in INTEGER) return DFAACC_PTR is begin return new UNBOUNDED_DFAACC_ARRAY(0 .. SIZE); end ALLOCATE_DFAACC_UNION; procedure REALLOCATE_INT_PTR_ARRAY(ARR : in out INT_STAR_PTR; SIZE : in INTEGER) is NEW_ARR : INT_STAR_PTR; begin NEW_ARR := ALLOCATE_INT_PTR_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_INT_PTR_ARRAY; procedure REALLOCATE_CHARACTER_ARRAY(ARR : in out CHAR_PTR; SIZE : in INTEGER) is NEW_ARR : CHAR_PTR; begin NEW_ARR := ALLOCATE_CHARACTER_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_CHARACTER_ARRAY; procedure REALLOCATE_VSTRING_ARRAY(ARR : in out VSTRING_PTR; SIZE : in INTEGER) is NEW_ARR : VSTRING_PTR; begin NEW_ARR := ALLOCATE_VSTRING_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_VSTRING_ARRAY; function ALLOCATE_CHARACTER_ARRAY(SIZE : in INTEGER) return CHAR_PTR is begin return new CHAR_ARRAY(0 .. SIZE); end ALLOCATE_CHARACTER_ARRAY; procedure REALLOCATE_DFAACC_UNION(ARR : in out DFAACC_PTR; SIZE : in INTEGER) is NEW_ARR : DFAACC_PTR; begin NEW_ARR := ALLOCATE_DFAACC_UNION(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_DFAACC_UNION; procedure REALLOCATE_BOOLEAN_ARRAY(ARR : in out BOOLEAN_PTR; SIZE : in INTEGER) is NEW_ARR : BOOLEAN_PTR; begin NEW_ARR := ALLOCATE_BOOLEAN_ARRAY(SIZE); NEW_ARR(0 .. ARR'LAST) := ARR(0 .. ARR'LAST); ARR := NEW_ARR; end REALLOCATE_BOOLEAN_ARRAY; function MAX(X, Y : in INTEGER) return INTEGER is begin if (X > Y) then return X; else return Y; end if; end MAX; function MIN(X, Y : in INTEGER) return INTEGER is begin if (X < Y) then return X; else return Y; end if; end MIN; end misc_defs;
AdaCore/gpr
Ada
22,308
adb
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with Ada.Unchecked_Conversion; with Gpr_Parser.Common; with Gpr_Parser.Public_Converters; use Gpr_Parser.Public_Converters; with Gpr_Parser.Rewriting_Implementation; package body Gpr_Parser.Rewriting is package Impl renames Gpr_Parser.Rewriting_Implementation; function Unwrap_RH is new Ada.Unchecked_Conversion (Rewriting_Handle, Impl.Rewriting_Handle); function Wrap_RH is new Ada.Unchecked_Conversion (Impl.Rewriting_Handle, Rewriting_Handle); function Unwrap_Node_RH is new Ada.Unchecked_Conversion (Node_Rewriting_Handle, Impl.Node_Rewriting_Handle); function Wrap_Node_RH is new Ada.Unchecked_Conversion (Impl.Node_Rewriting_Handle, Node_Rewriting_Handle); function Unwrap_Unit_RH is new Ada.Unchecked_Conversion (Unit_Rewriting_Handle, Impl.Unit_Rewriting_Handle); function Wrap_Unit_RH is new Ada.Unchecked_Conversion (Impl.Unit_Rewriting_Handle, Unit_Rewriting_Handle); function Wrap_Apply_Result (Res : Impl.Apply_Result) return Apply_Result; function Wrap_Unit_RH_Array (Arr : Impl.Unit_Rewriting_Handle_Array) return Unit_Rewriting_Handle_Array; function Unwrap_Node_RH_Array (Arr : Node_Rewriting_Handle_Array) return Impl.Node_Rewriting_Handle_Array; function Wrap_Apply_Result (Res : Impl.Apply_Result) return Apply_Result is begin if Res.Success then return (Success => True); else return (Success => False, Unit => Wrap_Unit (Res.Unit), Diagnostics => Res.Diagnostics); end if; end Wrap_Apply_Result; ------------------------ -- Wrap_Unit_RH_Array -- ------------------------ function Wrap_Unit_RH_Array (Arr : Impl.Unit_Rewriting_Handle_Array) return Unit_Rewriting_Handle_Array is Res : Unit_Rewriting_Handle_Array (Arr'Range); begin for I in Arr'Range loop Res (I) := Wrap_Unit_RH (Arr (I)); end loop; return Res; end Wrap_Unit_RH_Array; -------------------------- -- Unwrap_Node_RH_Array -- -------------------------- function Unwrap_Node_RH_Array (Arr : Node_Rewriting_Handle_Array) return Impl.Node_Rewriting_Handle_Array is Res : Impl.Node_Rewriting_Handle_Array (Arr'Range); begin for I in Arr'Range loop Res (I) := Unwrap_Node_RH (Arr (I)); end loop; return Res; end Unwrap_Node_RH_Array; ------------ -- Handle -- ------------ function Handle (Context : Analysis_Context) return Rewriting_Handle is begin return Wrap_RH (Impl.Handle (Unwrap_Context (Context))); end Handle; ------------- -- Context -- ------------- function Context (Handle : Rewriting_Handle) return Analysis_Context is begin return Wrap_Context (Impl.Context (Unwrap_RH (Handle))); end Context; --------------------- -- Start_Rewriting -- --------------------- function Start_Rewriting (Context : Analysis_Context) return Rewriting_Handle is begin return Wrap_RH (Impl.Start_Rewriting (Unwrap_Context (Context))); end Start_Rewriting; --------------------- -- Abort_Rewriting -- --------------------- procedure Abort_Rewriting (Handle : in out Rewriting_Handle) is Internal_Handle : Impl.Rewriting_Handle := Unwrap_RH (Handle); begin Impl.Abort_Rewriting (Internal_Handle); Handle := Wrap_RH (Internal_Handle); end Abort_Rewriting; ----------- -- Apply -- ----------- function Apply (Handle : in out Rewriting_Handle) return Apply_Result is Internal_Handle : Impl.Rewriting_Handle := Unwrap_RH (Handle); Res : Impl.Apply_Result := Impl.Apply (Internal_Handle); begin Handle := Wrap_RH (Internal_Handle); return Wrap_Apply_Result (Res); end Apply; ------------------ -- Unit_Handles -- ------------------ function Unit_Handles (Handle : Rewriting_Handle) return Unit_Rewriting_Handle_Array is begin return Wrap_Unit_RH_Array (Impl.Unit_Handles (Unwrap_RH (Handle))); end Unit_Handles; ------------ -- Handle -- ------------ function Handle (Unit : Analysis_Unit) return Unit_Rewriting_Handle is begin return Wrap_Unit_RH (Impl.Handle (Unwrap_Unit (Unit))); end Handle; ---------- -- Unit -- ---------- function Unit (Handle : Unit_Rewriting_Handle) return Analysis_Unit is begin return Wrap_Unit (Impl.Unit (Unwrap_Unit_RH (Handle))); end Unit; ---------- -- Root -- ---------- function Root (Handle : Unit_Rewriting_Handle) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Root (Unwrap_Unit_RH (Handle))); end Root; -------------- -- Set_Root -- -------------- procedure Set_Root (Handle : Unit_Rewriting_Handle; Root : Node_Rewriting_Handle) is begin Impl.Set_Root (Unwrap_Unit_RH (Handle), Unwrap_Node_RH (Root)); end Set_Root; ------------- -- Unparse -- ------------- function Unparse (Handle : Unit_Rewriting_Handle) return Unbounded_Text_Type is begin return Impl.Unparse (Unwrap_Unit_RH (Handle)); end Unparse; ------------ -- Handle -- ------------ function Handle (Node : Gpr_Node'Class) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Handle (Unwrap_Node (Node))); end Handle; ---------- -- Node -- ---------- function Node (Handle : Node_Rewriting_Handle) return Gpr_Node is begin return Wrap_Node (Impl.Node (Unwrap_Node_RH (Handle))); end Node; ------------- -- Context -- ------------- function Context (Handle : Node_Rewriting_Handle) return Rewriting_Handle is begin return Wrap_RH (Impl.Context (Unwrap_Node_RH (Handle))); end Context; ------------- -- Unparse -- ------------- function Unparse (Handle : Node_Rewriting_Handle) return Text_Type is begin return Impl.Unparse (Unwrap_Node_RH (Handle)); end Unparse; ---------- -- Kind -- ---------- function Kind (Handle : Node_Rewriting_Handle) return Gpr_Node_Kind_Type is begin return Impl.Kind (Unwrap_Node_RH (Handle)); end Kind; ---------- -- Tied -- ---------- function Tied (Handle : Node_Rewriting_Handle) return Boolean is begin return Impl.Tied (Unwrap_Node_RH (Handle)); end Tied; ------------ -- Parent -- ------------ function Parent (Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Parent (Unwrap_Node_RH (Handle))); end Parent; -------------------- -- Children_Count -- -------------------- function Children_Count (Handle : Node_Rewriting_Handle) return Natural is begin return Impl.Children_Count (Unwrap_Node_RH (Handle)); end Children_Count; ----------- -- Child -- ----------- function Child (Handle : Node_Rewriting_Handle; Index : Positive) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Child (Unwrap_Node_RH (Handle), Index)); end Child; ----------- -- Child -- ----------- function Child (Handle : Node_Rewriting_Handle; Field : Struct_Member_Ref) return Node_Rewriting_Handle is begin return Child (Handle, Child_Index (Handle, Field)); end Child; ----------- -- Child -- ----------- function Child (Handle : Node_Rewriting_Handle; Fields : Struct_Member_Ref_Array) return Node_Rewriting_Handle is begin return Result : Node_Rewriting_Handle := Handle do for F of Fields loop Result := Child (Result, F); end loop; end return; end Child; --------------- -- Set_Child -- --------------- procedure Set_Child (Handle : Node_Rewriting_Handle; Index : Positive; Child : Node_Rewriting_Handle) is begin Impl.Set_Child (Unwrap_Node_RH (Handle), Index, Unwrap_Node_RH (Child)); end Set_Child; --------------- -- Set_Child -- --------------- procedure Set_Child (Handle : Node_Rewriting_Handle; Field : Struct_Member_Ref; Child : Node_Rewriting_Handle) is begin Set_Child (Handle, Child_Index (Handle, Field), Child); end Set_Child; ---------- -- Text -- ---------- function Text (Handle : Node_Rewriting_Handle) return Text_Type is begin return Impl.Text (Unwrap_Node_RH (Handle)); end Text; -------------- -- Set_Text -- -------------- procedure Set_Text (Handle : Node_Rewriting_Handle; Text : Text_Type) is begin Impl.Set_Text (Unwrap_Node_RH (Handle), Text); end Set_Text; ------------- -- Replace -- ------------- procedure Replace (Handle, New_Node : Node_Rewriting_Handle) is begin Impl.Replace (Unwrap_Node_RH (Handle), Unwrap_Node_RH (New_Node)); end Replace; ------------------ -- Insert_Child -- ------------------ procedure Insert_Child (Handle : Node_Rewriting_Handle; Index : Positive; Child : Node_Rewriting_Handle) is begin Impl.Insert_Child (Unwrap_Node_RH (Handle), Index, Unwrap_Node_RH (Child)); end Insert_Child; ------------------ -- Append_Child -- ------------------ procedure Append_Child (Handle : Node_Rewriting_Handle; Child : Node_Rewriting_Handle) is begin Impl.Append_Child (Unwrap_Node_RH (Handle), Unwrap_Node_RH (Child)); end Append_Child; ------------------ -- Remove_Child -- ------------------ procedure Remove_Child (Handle : Node_Rewriting_Handle; Index : Positive) is begin Impl.Remove_Child (Unwrap_Node_RH (Handle), Index); end Remove_Child; ----------- -- Clone -- ----------- function Clone (Handle : Node_Rewriting_Handle) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Clone (Unwrap_Node_RH (Handle))); end Clone; ----------------- -- Create_Node -- ----------------- function Create_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Node (Unwrap_RH (Handle), Kind)); end Create_Node; ----------------------- -- Create_Token_Node -- ----------------------- function Create_Token_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type; Text : Text_Type) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Token_Node (Unwrap_RH (Handle), Kind, Text)); end Create_Token_Node; ------------------------- -- Create_Regular_Node -- ------------------------- function Create_Regular_Node (Handle : Rewriting_Handle; Kind : Gpr_Node_Kind_Type; Children : Node_Rewriting_Handle_Array) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Regular_Node (Unwrap_RH (Handle), Kind, Unwrap_Node_RH_Array (Children))); end Create_Regular_Node; -------------------------- -- Create_From_Template -- -------------------------- function Create_From_Template (Handle : Rewriting_Handle; Template : Text_Type; Arguments : Node_Rewriting_Handle_Array; Rule : Grammar_Rule) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_From_Template (Unwrap_RH (Handle), Template, Unwrap_Node_RH_Array (Arguments), Rule)); end Create_From_Template; function Create_Attribute_Decl (Handle : Rewriting_Handle ; F_Attr_Name : Node_Rewriting_Handle ; F_Attr_Index : Node_Rewriting_Handle ; F_Expr : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Attribute_Decl (Unwrap_RH (Handle), Attribute_Decl_F_Attr_Name => Unwrap_Node_RH (F_Attr_Name), Attribute_Decl_F_Attr_Index => Unwrap_Node_RH (F_Attr_Index), Attribute_Decl_F_Expr => Unwrap_Node_RH (F_Expr))); end; function Create_Attribute_Reference (Handle : Rewriting_Handle ; F_Attribute_Name : Node_Rewriting_Handle ; F_Attribute_Index : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Attribute_Reference (Unwrap_RH (Handle), Attribute_Reference_F_Attribute_Name => Unwrap_Node_RH (F_Attribute_Name), Attribute_Reference_F_Attribute_Index => Unwrap_Node_RH (F_Attribute_Index))); end; function Create_Builtin_Function_Call (Handle : Rewriting_Handle ; F_Function_Name : Node_Rewriting_Handle ; F_Parameters : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Builtin_Function_Call (Unwrap_RH (Handle), Builtin_Function_Call_F_Function_Name => Unwrap_Node_RH (F_Function_Name), Builtin_Function_Call_F_Parameters => Unwrap_Node_RH (F_Parameters))); end; function Create_Case_Construction (Handle : Rewriting_Handle ; F_Var_Ref : Node_Rewriting_Handle ; F_Items : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Case_Construction (Unwrap_RH (Handle), Case_Construction_F_Var_Ref => Unwrap_Node_RH (F_Var_Ref), Case_Construction_F_Items => Unwrap_Node_RH (F_Items))); end; function Create_Case_Item (Handle : Rewriting_Handle ; F_Choice : Node_Rewriting_Handle ; F_Decls : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Case_Item (Unwrap_RH (Handle), Case_Item_F_Choice => Unwrap_Node_RH (F_Choice), Case_Item_F_Decls => Unwrap_Node_RH (F_Decls))); end; function Create_Compilation_Unit (Handle : Rewriting_Handle ; F_Project : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Compilation_Unit (Unwrap_RH (Handle), Compilation_Unit_F_Project => Unwrap_Node_RH (F_Project))); end; function Create_Prefix (Handle : Rewriting_Handle ; F_Prefix : Node_Rewriting_Handle ; F_Suffix : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Prefix (Unwrap_RH (Handle), Prefix_F_Prefix => Unwrap_Node_RH (F_Prefix), Prefix_F_Suffix => Unwrap_Node_RH (F_Suffix))); end; function Create_Package_Decl (Handle : Rewriting_Handle ; F_Pkg_Name : Node_Rewriting_Handle ; F_Pkg_Spec : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Package_Decl (Unwrap_RH (Handle), Package_Decl_F_Pkg_Name => Unwrap_Node_RH (F_Pkg_Name), Package_Decl_F_Pkg_Spec => Unwrap_Node_RH (F_Pkg_Spec))); end; function Create_Package_Extension (Handle : Rewriting_Handle ; F_Extended_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Package_Extension (Unwrap_RH (Handle), Package_Extension_F_Extended_Name => Unwrap_Node_RH (F_Extended_Name))); end; function Create_Package_Renaming (Handle : Rewriting_Handle ; F_Renamed_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Package_Renaming (Unwrap_RH (Handle), Package_Renaming_F_Renamed_Name => Unwrap_Node_RH (F_Renamed_Name))); end; function Create_Package_Spec (Handle : Rewriting_Handle ; F_Extension : Node_Rewriting_Handle ; F_Decls : Node_Rewriting_Handle ; F_End_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Package_Spec (Unwrap_RH (Handle), Package_Spec_F_Extension => Unwrap_Node_RH (F_Extension), Package_Spec_F_Decls => Unwrap_Node_RH (F_Decls), Package_Spec_F_End_Name => Unwrap_Node_RH (F_End_Name))); end; function Create_Project (Handle : Rewriting_Handle ; F_Context_Clauses : Node_Rewriting_Handle ; F_Project_Decl : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Project (Unwrap_RH (Handle), Project_F_Context_Clauses => Unwrap_Node_RH (F_Context_Clauses), Project_F_Project_Decl => Unwrap_Node_RH (F_Project_Decl))); end; function Create_Project_Declaration (Handle : Rewriting_Handle ; F_Qualifier : Node_Rewriting_Handle ; F_Project_Name : Node_Rewriting_Handle ; F_Extension : Node_Rewriting_Handle ; F_Decls : Node_Rewriting_Handle ; F_End_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Project_Declaration (Unwrap_RH (Handle), Project_Declaration_F_Qualifier => Unwrap_Node_RH (F_Qualifier), Project_Declaration_F_Project_Name => Unwrap_Node_RH (F_Project_Name), Project_Declaration_F_Extension => Unwrap_Node_RH (F_Extension), Project_Declaration_F_Decls => Unwrap_Node_RH (F_Decls), Project_Declaration_F_End_Name => Unwrap_Node_RH (F_End_Name))); end; function Create_Project_Extension (Handle : Rewriting_Handle ; F_Is_All : Node_Rewriting_Handle ; F_Path_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Project_Extension (Unwrap_RH (Handle), Project_Extension_F_Is_All => Unwrap_Node_RH (F_Is_All), Project_Extension_F_Path_Name => Unwrap_Node_RH (F_Path_Name))); end; function Create_String_Literal_At (Handle : Rewriting_Handle ; F_Str_Lit : Node_Rewriting_Handle ; F_At_Lit : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_String_Literal_At (Unwrap_RH (Handle), String_Literal_At_F_Str_Lit => Unwrap_Node_RH (F_Str_Lit), String_Literal_At_F_At_Lit => Unwrap_Node_RH (F_At_Lit))); end; function Create_Terms (Handle : Rewriting_Handle ; F_Terms : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Terms (Unwrap_RH (Handle), Terms_F_Terms => Unwrap_Node_RH (F_Terms))); end; function Create_Type_Reference (Handle : Rewriting_Handle ; F_Var_Type_Name : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Type_Reference (Unwrap_RH (Handle), Type_Reference_F_Var_Type_Name => Unwrap_Node_RH (F_Var_Type_Name))); end; function Create_Typed_String_Decl (Handle : Rewriting_Handle ; F_Type_Id : Node_Rewriting_Handle ; F_String_Literals : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Typed_String_Decl (Unwrap_RH (Handle), Typed_String_Decl_F_Type_Id => Unwrap_Node_RH (F_Type_Id), Typed_String_Decl_F_String_Literals => Unwrap_Node_RH (F_String_Literals))); end; function Create_Variable_Decl (Handle : Rewriting_Handle ; F_Var_Name : Node_Rewriting_Handle ; F_Var_Type : Node_Rewriting_Handle ; F_Expr : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Variable_Decl (Unwrap_RH (Handle), Variable_Decl_F_Var_Name => Unwrap_Node_RH (F_Var_Name), Variable_Decl_F_Var_Type => Unwrap_Node_RH (F_Var_Type), Variable_Decl_F_Expr => Unwrap_Node_RH (F_Expr))); end; function Create_Variable_Reference (Handle : Rewriting_Handle ; F_Variable_Name : Node_Rewriting_Handle ; F_Attribute_Ref : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_Variable_Reference (Unwrap_RH (Handle), Variable_Reference_F_Variable_Name => Unwrap_Node_RH (F_Variable_Name), Variable_Reference_F_Attribute_Ref => Unwrap_Node_RH (F_Attribute_Ref))); end; function Create_With_Decl (Handle : Rewriting_Handle ; F_Is_Limited : Node_Rewriting_Handle ; F_Path_Names : Node_Rewriting_Handle ) return Node_Rewriting_Handle is begin return Wrap_Node_RH (Impl.Create_With_Decl (Unwrap_RH (Handle), With_Decl_F_Is_Limited => Unwrap_Node_RH (F_Is_Limited), With_Decl_F_Path_Names => Unwrap_Node_RH (F_Path_Names))); end; end Gpr_Parser.Rewriting;
charlie5/cBound
Ada
617
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with gmp_c.a_a_mpq_struct; with Interfaces.C; package gmp_c.mpq_ptr is -- Item -- subtype Item is gmp_c.a_a_mpq_struct.Pointer; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased gmp_c.mpq_ptr.Item; -- Pointer -- type Pointer is access all gmp_c.mpq_ptr.Item; -- Pointers -- type Pointers is array (Interfaces.C.size_t range <>) of aliased gmp_c.mpq_ptr.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all gmp_c.mpq_ptr.Pointer; end gmp_c.mpq_ptr;
AdaCore/training_material
Ada
3,312
adb
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2014-2017, 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. -- -- -- ------------------------------------------------------------------------------ with STM32F4; use STM32F4; with STM32F4.GPIO; use STM32F4.GPIO; with STM32F4.RCC; use STM32F4.RCC; with STM32F4.SYSCFG; use STM32F4.SYSCFG; with STM32F429_Discovery; use STM32F429_Discovery; package body My_Button is Debounce_Time : constant Time_Span := Milliseconds (100); protected body Button is entry Wait_Press when Is_Pressed is begin Is_Pressed := False; end Wait_Press; procedure Interrupt_Handler is Now : constant Time := Clock; begin -- Clear interrupt Clear_External_Interrupt (Pin_0); -- Debouncing if Now - Last_Time >= Debounce_Time then Last_Time := Now; Is_Pressed := True; end if; end Interrupt_Handler; end Button; procedure Initialize is Configuration : GPIO_Port_Configuration; begin Enable_Clock (GPIO_A); Configuration.Mode := Mode_In; Configuration.Resistors := Floating; Configure_IO (Port => GPIO_A, Pin => Pin_0, Config => Configuration); Connect_External_Interrupt (GPIO_A, Pin_0); Configure_Trigger (GPIO_A, Pin_0, Interrupt_Rising_Edge); end Initialize; begin Initialize; end My_Button;
zhmu/ananas
Ada
315
adb
-- { dg-do run } -- { dg-options "-O0" } procedure Fixedpnt6 is type T is delta 0.125 range -2.0 .. 1.875; function Mult (A, B : T) return T is begin return T (A * B); end; R : T; begin R := Mult (T'Last, T'Last); raise Program_Error; exception when Constraint_Error => null; end;
HeisenbugLtd/open_weather_map_api
Ada
5,170
adb
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); with Open_Weather_Map.API.Service.Group; with Open_Weather_Map.API.Service.Location; with Open_Weather_Map.API.Service.Weather; package body Open_Weather_Map.API is use type Client.T_Access; My_Debug : constant not null GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create (Unit_Name => "OWM.API"); ----------------------------------------------------------------------------- -- Create_Current_By_Coordinates ----------------------------------------------------------------------------- function Create_Current_By_Coordinates (Coordinates : in Geo_Coordinates; Configuration : in GNATCOLL.JSON.JSON_Value; Connection : in Client.T_Access := null; Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval; Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit) return API.API_Class is My_Connection : Open_Weather_Map.Client.T_Access; begin My_Debug.all.Trace (Message => "Create_Current_By_Coordinates"); if Connection = null then My_Debug.all.Trace (Message => "Create_Current_By_Coordinates: " & "No HTTP connection specified, creating new one..."); My_Connection := Client.Create (Configuration => Configuration, Rate_Limit => Rate_Limit); else My_Connection := Connection; end if; return Result : Service.Location.T do Result.Initialize (Configuration => Configuration, Connection => My_Connection, Max_Cache_Interval => Cache_Interval, Coordinates => Coordinates); end return; end Create_Current_By_Coordinates; ----------------------------------------------------------------------------- -- Create_Current_By_Group ----------------------------------------------------------------------------- function Create_Current_By_Group (Ids : in Group_List; Configuration : in GNATCOLL.JSON.JSON_Value; Connection : in Client.T_Access := null; Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval; Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit) return API.API_Class is My_Connection : Open_Weather_Map.Client.T_Access; begin My_Debug.all.Trace (Message => "Create_Current_By_Group"); if Connection = null then My_Debug.all.Trace (Message => "Create_Current_By_Group: " & "No HTTP connection specified, creating new one..."); My_Connection := Client.Create (Configuration => Configuration, Rate_Limit => Rate_Limit); else My_Connection := Connection; end if; return Result : Service.Group.T do Result.Initialize (Configuration => Configuration, Connection => My_Connection, Max_Cache_Interval => Cache_Interval, Ids => Ids); end return; end Create_Current_By_Group; ----------------------------------------------------------------------------- -- Create_Current_By_Id ----------------------------------------------------------------------------- function Create_Current_By_Id (Id : in City_Id; Configuration : in GNATCOLL.JSON.JSON_Value; Connection : in Client.T_Access := null; Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval; Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit) return API.API_Class is My_Connection : Open_Weather_Map.Client.T_Access; begin My_Debug.all.Trace (Message => "Create_Current_By_Id"); if Connection = null then My_Debug.all.Trace (Message => "Create_Current_By_Id: " & "No HTTP connection specified, creating new one..."); My_Connection := Client.Create (Configuration => Configuration, Rate_Limit => Rate_Limit); else My_Connection := Connection; end if; return Result : Service.Weather.T do Result.Initialize (Configuration => Configuration, Connection => My_Connection, Max_Cache_Interval => Cache_Interval, Id => Id); end return; end Create_Current_By_Id; end Open_Weather_Map.API;
zhmu/ananas
Ada
480
ads
-- { dg-do compile } -- { dg-skip-if "No Dwarf" { { hppa*-*-hpux* } && { ! lp64 } } } -- { dg-options "-cargs -O0 -g -dA -fgnat-encodings=minimal -margs" } package Debug1 is type Index_T is new Positive range 1 .. 128; type Array_Type is array (Index_T range <>) of Integer; type Record_Type (N : Index_T := 16) is record A : Array_Type (1 .. N); end record; R : Record_Type; end Debug1; -- { dg-final { scan-assembler-times "DW_AT_upper_bound" 4 } }
reznikmm/matreshka
Ada
10,776
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- Optimizations: -- -- 1. Remove subtree starting from the repetition node with bounds {0,0} -- including the repetition node. When the parent node is alternative then -- it is removed also and replaced by filling other path in its place. -- -- 2. Two sequencial anchor nodes merged into the one node. package body Matreshka.Internals.Regexps.Compiler.Optimizer is procedure Analyze_Node (Pattern : not null Shared_Pattern_Access; Node : Natural; Restart : in out Boolean); procedure Remove_Subtree (Pattern : not null Shared_Pattern_Access; Node : Natural); procedure Prepend (Pattern : not null Shared_Pattern_Access; List : Node_List_Index; From : Node_List_Index); ------------------ -- Analyze_Node -- ------------------ procedure Analyze_Node (Pattern : not null Shared_Pattern_Access; Node : Natural; Restart : in out Boolean) is Next : constant Natural := Get_Next_Sibling (Pattern, Node); -- Current node can be removed from the list, so it is safer -- to cache next sibling node. begin case Pattern.AST (Node).Kind is when N_Subexpression => Analyze_Node (Pattern, Get_Expression (Pattern, Node), Restart); when N_Character_Class => Analyze_Node (Pattern, Get_Members (Pattern, Node), Restart); when N_Multiplicity => if Get_Lower_Bound (Pattern, Node) = 0 and then Get_Upper_Bound (Pattern, Node) = 0 then -- Subexpression is never looked in the string, reconstruct -- tree to remove this repetition node and its subtree. Remove_Subtree (Pattern, Node); Restart := True; elsif Get_Lower_Bound (Pattern, Node) = 1 and then Get_Upper_Bound (Pattern, Node) = 1 then -- Subexpression is looked only once, reconstruct tree to -- merge subtree of this repetition node instead on this -- repetition node. null; end if; if not Restart then Analyze_Node (Pattern, Get_Expression (Pattern, Node), Restart); end if; when N_Alternation => Analyze_Node (Pattern, Get_Preferred (Pattern, Node), Restart); if not Restart then Analyze_Node (Pattern, Get_Fallback (Pattern, Node), Restart); end if; when N_Anchor => declare Previous : constant Natural := Get_Previous_Sibling (Pattern, Node); begin if Previous /= 0 and then Pattern.AST (Previous).Kind = N_Anchor then -- Merge two sequencial anchor nodes into one. Pattern.AST (Previous).Start_Of_Line := Pattern.AST (Previous).Start_Of_Line or Pattern.AST (Node).Start_Of_Line; Pattern.AST (Previous).End_Of_Line := Pattern.AST (Previous).End_Of_Line or Pattern.AST (Node).End_Of_Line; Remove_Subtree (Pattern, Node); end if; end; when others => null; end case; if not Restart and then Next /= 0 then Analyze_Node (Pattern, Next, Restart); end if; end Analyze_Node; -------------- -- Optimize -- -------------- procedure Optimize (Pattern : not null Shared_Pattern_Access) is Restart : Boolean; begin loop Restart := False; Analyze_Node (Pattern, Pattern.List (Pattern.Start).Head, Restart); exit when not Restart; end loop; end Optimize; ------------- -- Prepend -- ------------- procedure Prepend (Pattern : not null Shared_Pattern_Access; List : Node_List_Index; From : Node_List_Index) is Current : Natural := Pattern.List (From).Tail; Previous : Natural; begin while Current /= 0 loop Previous := Get_Previous_Sibling (Pattern, Current); Pattern.AST (Current).List := List; Pattern.AST (Current).Previous := 0; Pattern.AST (Current).Next := Pattern.List (List).Head; if Pattern.List (List).Head = 0 then Pattern.List (List).Tail := Current; else Pattern.AST (Pattern.List (List).Head).Previous := Current; end if; Pattern.List (List).Head := Current; Current := Previous; end loop; end Prepend; -------------------- -- Remove_Subtree -- -------------------- procedure Remove_Subtree (Pattern : not null Shared_Pattern_Access; Node : Natural) is List : constant Node_List_Index := Pattern.AST (Node).List; Previous : constant Natural := Get_Previous_Sibling (Pattern, Node); Next : constant Natural := Get_Next_Sibling (Pattern, Node); Parent : constant Natural := Pattern.List (List).Parent; begin if Previous = 0 and then Next = 0 then case Pattern.AST (Parent).Kind is when N_Alternation => declare Previous : constant Natural := Get_Previous_Sibling (Pattern, Parent); Next : constant Natural := Get_Next_Sibling (Pattern, Parent); begin if Previous = 0 and then Next = 0 then Pattern.List (Pattern.AST (Parent).List).Head := 0; Pattern.List (Pattern.AST (Parent).List).Tail := 0; elsif Previous = 0 then Pattern.List (Pattern.AST (Parent).List).Head := Next; Pattern.AST (Next).Previous := 0; elsif Next = 0 then Pattern.List (Pattern.AST (Parent).List).Tail := Previous; Pattern.AST (Previous).Next := 0; else Pattern.AST (Next).Previous := Previous; Pattern.AST (Previous).Next := Next; end if; end; if Pattern.AST (Parent).Preferred = List then Prepend (Pattern, Pattern.AST (Parent).List, Pattern.AST (Parent).Fallback); else Prepend (Pattern, Pattern.AST (Parent).List, Pattern.AST (Parent).Preferred); end if; Pattern.AST (Parent) := (Kind => N_None); when N_Multiplicity => Remove_Subtree (Pattern, Pattern.List (List).Parent); when N_Subexpression => Remove_Subtree (Pattern, Pattern.List (List).Parent); when others => raise Program_Error; end case; elsif Previous = 0 then Pattern.List (List).Head := Next; Pattern.AST (Next).Previous := 0; elsif Next = 0 then Pattern.List (List).Tail := Previous; Pattern.AST (Previous).Next := 0; else Pattern.AST (Next).Previous := Previous; Pattern.AST (Previous).Next := Next; end if; end Remove_Subtree; end Matreshka.Internals.Regexps.Compiler.Optimizer;
OneWingedShark/Byron
Ada
301
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); with Ada.Containers.Indefinite_Vectors; Package Byron.Internals.Expressions.List is new Ada.Containers.Indefinite_Vectors( -- "=" => Index_Type => Positive, Element_Type => Expressions.Expression'Class ) with Preelaborate;
DrenfongWong/tkm-rpc
Ada
405
ads
with Ada.Unchecked_Conversion; package Tkmrpc.Response.Ike.Esa_Create.Convert is function To_Response is new Ada.Unchecked_Conversion ( Source => Esa_Create.Response_Type, Target => Response.Data_Type); function From_Response is new Ada.Unchecked_Conversion ( Source => Response.Data_Type, Target => Esa_Create.Response_Type); end Tkmrpc.Response.Ike.Esa_Create.Convert;
aeszter/lox-spark
Ada
378
ads
package Command_Line with SPARK_Mode is type Exit_Status is new Integer; function Argument_Count return Natural with Global => null; procedure Set_Exit_Status (Code : Exit_Status) with Global => null; function Argument (Number : Positive) return String with Global => null, Pre => Number >= 1 and then Number <= Argument_Count; end Command_Line;
reznikmm/matreshka
Ada
3,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Custom5_Attributes is pragma Preelaborate; type ODF_Text_Custom5_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Custom5_Attribute_Access is access all ODF_Text_Custom5_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Custom5_Attributes;
Rodeo-McCabe/orka
Ada
5,961
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[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 GL.Buffers; with GL.Types.Colors; private with GL.Low_Level; package GL.Blending is pragma Preelaborate; ----------------------------------------------------------------------------- -- Blending -- ----------------------------------------------------------------------------- -- Enable blending by enabling Blend in package GL.Toggles type Blend_Factor is (Zero, One, Src_Color, One_Minus_Src_Color, Src_Alpha, One_Minus_Src_Alpha, Dst_Alpha, One_Minus_Dst_Alpha, Dst_Color, One_Minus_Dst_Color, Src_Alpha_Saturate, Constant_Color, One_Minus_Constant_Color, Constant_Alpha, One_Minus_Constant_Alpha, Src1_Alpha, Src1_Color, One_Minus_Src1_Color, One_Minus_Src1_Alpha); -- Table 17.2 of the OpenGL specification type Blend_Factors is record Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha : Blend_Factor; end record; type Equation is (Func_Add, Min, Max, Func_Subtract, Func_Reverse_Substract); type Blend_Equations is record RGB, Alpha : Equation; end record; procedure Set_Blend_Func (Factors : Blend_Factors); procedure Set_Blend_Func (Draw_Buffer : Buffers.Draw_Buffer_Index; Factors : Blend_Factors); function Blend_Func return Blend_Factors; procedure Set_Blend_Color (Value : Types.Colors.Color); function Blend_Color return Types.Colors.Color; procedure Set_Blend_Equation (Equations : Blend_Equations); procedure Set_Blend_Equation (Draw_Buffer : Buffers.Draw_Buffer_Index; Equations : Blend_Equations); function Blend_Equation return Blend_Equations; ----------------------------------------------------------------------------- -- Logical Operation -- ----------------------------------------------------------------------------- -- Enable logical operations by enabling Color_Logic_Op in -- package GL.Toggles. Enabling logical operation will disable -- blending. The logical operation has no effect if the attached -- textures of the framebuffer are floating-point or sRGB. type Logic_Op is (Clear, And_Op, And_Reverse, Copy, And_Inverted, Noop, Xor_Op, Or_Op, Nor, Equiv, Invert, Or_Reverse, Copy_Inverted, Or_Inverted, Nand, Set); -- Table 17.3 of the OpenGL specification procedure Set_Logic_Op_Mode (Value : Logic_Op); -- Set the logical operation to be applied to the color of the -- fragment and the current colors in the color buffers which -- are enabled for writing function Logic_Op_Mode return Logic_Op; private for Blend_Factor use (Zero => 0, One => 1, Src_Color => 16#0300#, One_Minus_Src_Color => 16#0301#, Src_Alpha => 16#0302#, One_Minus_Src_Alpha => 16#0303#, Dst_Alpha => 16#0304#, One_Minus_Dst_Alpha => 16#0305#, Dst_Color => 16#0306#, One_Minus_Dst_Color => 16#0307#, Src_Alpha_Saturate => 16#0308#, Constant_Color => 16#8001#, One_Minus_Constant_Color => 16#8002#, Constant_Alpha => 16#8003#, One_Minus_Constant_Alpha => 16#8004#, Src1_Alpha => 16#8589#, Src1_Color => 16#88F9#, One_Minus_Src1_Color => 16#88FA#, One_Minus_Src1_Alpha => 16#88FB#); for Blend_Factor'Size use Low_Level.Enum'Size; for Equation use (Func_Add => 16#8006#, Min => 16#8007#, Max => 16#8008#, Func_Subtract => 16#800A#, Func_Reverse_Substract => 16#800B#); for Equation'Size use Low_Level.Enum'Size; ----------------------------------------------------------------------------- for Logic_Op use (Clear => 16#1500#, And_Op => 16#1501#, And_Reverse => 16#1502#, Copy => 16#1503#, And_Inverted => 16#1504#, Noop => 16#1505#, Xor_Op => 16#1506#, Or_Op => 16#1507#, Nor => 16#1508#, Equiv => 16#1509#, Invert => 16#150A#, Or_Reverse => 16#150B#, Copy_Inverted => 16#150C#, Or_Inverted => 16#150D#, Nand => 16#150E#, Set => 16#150F#); for Logic_Op'Size use Low_Level.Enum'Size; end GL.Blending;
charlie5/lace
Ada
1,175
ads
with openGL.Renderer.lean, openGL.Visual, openGL.Frustum; package openGL.Culler -- -- Provides a base class for cullers. -- is type Item is abstract tagged limited private; type View is access all Item'Class; -------------- --- Attributes -- procedure add (Self : in out Item; the_Visual : in Visual.view) is abstract; procedure rid (Self : in out Item; the_Visual : in Visual.view) is abstract; function object_Count (Self : in Item) return Natural is abstract; function Viewer (Self : in Item'Class) return Renderer.lean.view; procedure Viewer_is (Self : in out Item'Class; Now : in Renderer.lean.view); -------------- -- Operations -- function cull (Self : in Item; the_Visuals : in Visual.views; camera_Frustum : in frustum.Plane_array; camera_Site : in Vector_3) return Visual.views is abstract; private type Item is abstract tagged limited record Viewer : Renderer.lean.view; end record; end openGL.Culler;
RREE/ada-util
Ada
4,674
adb
----------------------------------------------------------------------- -- util-streams-raw -- Raw streams for Windows based systems -- Copyright (C) 2011, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with System; package body Util.Streams.Raw is use System; use Util.Systems.Os; use type Util.Systems.Os.HANDLE; -- ----------------------- -- Initialize the raw stream to read and write on the given file descriptor. -- ----------------------- procedure Initialize (Stream : in out Raw_Stream; File : in File_Type) is begin if Stream.File /= NO_FILE then raise Ada.IO_Exceptions.Status_Error; end if; Stream.File := File; end Initialize; -- ----------------------- -- Get the file descriptor associated with the stream. -- ----------------------- function Get_File (Stream : in Raw_Stream) return Util.Systems.Os.File_Type is begin return Stream.File; end Get_File; -- ----------------------- -- Set the file descriptor to be used by the stream. -- ----------------------- procedure Set_File (Stream : in out Raw_Stream; File : in Util.Systems.Os.File_Type) is begin Stream.File := File; end Set_File; -- ----------------------- -- Close the stream. -- ----------------------- overriding procedure Close (Stream : in out Raw_Stream) is Error : Integer; begin if Stream.File /= NO_FILE then if Close_Handle (Stream.File) = 0 then Error := Get_Last_Error; if Error /= ERROR_BROKEN_PIPE then raise Ada.IO_Exceptions.Device_Error with "IO error: " & Integer'Image (Error); end if; end if; Stream.File := NO_FILE; end if; end Close; -- ----------------------- -- Write the buffer array to the output stream. -- ----------------------- procedure Write (Stream : in out Raw_Stream; Buffer : in Ada.Streams.Stream_Element_Array) is Res : aliased DWORD := 0; Status : BOOL; begin Status := Write_File (Stream.File, Buffer'Address, Buffer'Length, Res'Unchecked_Access, System.Null_Address); if Status = 0 then raise Ada.IO_Exceptions.Device_Error; end if; end Write; -- ----------------------- -- Read into the buffer as many bytes as possible and return in -- <b>last</b> the position of the last byte read. -- ----------------------- procedure Read (Stream : in out Raw_Stream; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Res : aliased DWORD := 0; Status : BOOL; Error : Integer; begin Status := Read_File (Stream.File, Into'Address, Into'Length, Res'Unchecked_Access, System.Null_Address); if Status = 0 then Error := Get_Last_Error; if Error /= ERROR_BROKEN_PIPE then raise Ada.IO_Exceptions.Device_Error with "IO error: " & Integer'Image (Error); end if; end if; Last := Into'First + Ada.Streams.Stream_Element_Offset (Res) - 1; end Read; -- ----------------------- -- Reposition the read/write file offset. -- ----------------------- procedure Seek (Stream : in out Raw_Stream; Pos : in Util.Systems.Types.off_t; Mode : in Util.Systems.Types.Seek_Mode) is Res : Util.Systems.Types.off_t; begin Res := Sys_Lseek (Stream.File, Pos, Mode); if Res < 0 then raise Ada.IO_Exceptions.Device_Error; end if; end Seek; -- ----------------------- -- Flush the stream and release the buffer. -- ----------------------- procedure Finalize (Object : in out Raw_Stream) is begin Close (Object); end Finalize; end Util.Streams.Raw;
peterfrankjohnson/kernel
Ada
6,374
ads
with Interfaces; use Interfaces; with Types; use Types; package CPU is type CPUIDType is (CPUID0, CPUID1); subtype VendorString is String (1 .. 12); type X is mod 2**2; type Features (CPUID_Type : CPUIDType := CPUID0) is record case CPUID_Type is when CPUID0 => Vendor : VendorString; MaxID : Double; when CPUID1 => EBX : Double; -- EDX FPU : Boolean; VME : Boolean; DE : Boolean; PSE : Boolean; TSC : Boolean; MSR : Boolean; PAE : Boolean; MCE : Boolean; CX8 : Boolean; APIC : Boolean; Reserved1 : Boolean; SEP : Boolean; MTRR : Boolean; PGE : Boolean; MCA : Boolean; CMOV : Boolean; PAT : Boolean; PSE36 : Boolean; PN : Boolean; CLFLUSH : Boolean; Reserved2 : Boolean; DTS : Boolean; ACPI : Boolean; MMX : Boolean; FXSR : Boolean; SSE : Boolean; SSE2 : Boolean; SS : Boolean; HT : Boolean; TM : Boolean; IA64 : Boolean; PBE : Boolean; -- ECX PNI : Boolean; PCLMULQDQ : Boolean; DTES64 : Boolean; MONITOR : Boolean; DS_CPL : Boolean; VMX : Boolean; SMX : Boolean; EST : Boolean; TM2 : Boolean; SSSE3 : Boolean; CID : Boolean; Reserved3 : Boolean; FMA : Boolean; CX16 : Boolean; XTPR : Boolean; PDCM : Boolean; Reserved4 : Boolean; PCID : Boolean; DCA : Boolean; SSE4_1 : Boolean; SSE4_2 : Boolean; X2APIC : Boolean; MOVBE : Boolean; POPCNT : Boolean; TSCDEAD : Boolean; AES : Boolean; XSAVE : Boolean; OSXSAVE : Boolean; AVX : Boolean; F16C : Boolean; RDRND : Boolean; HYPERVISOR : Boolean; Stepping : Nibble; Model : Nibble; Family : Nibble; ProcessorType : X; ExtendedModel : Nibble; ExtendedFamily : Nibble; Unused : X; end case; end record; for Features'Size use 128; pragma Pack (Features); pragma Unchecked_Union (Features); type Features_Ptr is access Features; procedure SetTrapFlag; procedure ClearInterruptFlag; procedure SetInterruptFlag; procedure Halt; function ID (EAX : Unsigned_32) return Features_Ptr; function InputByte (Port : Word) return Byte; function InputWord (Port : Word) return Word; function InputDouble (Port : Word) return Double; procedure OutputByte (Port : Word; Data : Byte); procedure OutputWord (Port : Word; Data : Word); procedure OutputDouble (Port : Word; Data : Double); function ReadCR0 return Double; function ReadCR2 return Double; function ReadCR3 return Double; function ReadCR4 return Double; function ReadDR0 return Double; function ReadDR1 return Double; function ReadDR2 return Double; function ReadDR3 return Double; function ReadDR6 return Double; function ReadDR7 return Double; function ReadFlags return Double; procedure WriteCR0 (CR0 : Double); procedure WriteCR2 (CR2 : Double); procedure WriteCR3 (CR3 : Double); procedure WriteCR4 (CR4 : Double); procedure WriteDR0 (DR0 : Double); procedure WriteDR1 (DR1 : Double); procedure WriteDR2 (DR2 : Double); procedure WriteDR3 (DR3 : Double); procedure WriteDR6 (DR6 : Double); procedure WriteDR7 (DR7 : Double); procedure WriteFlags (Flags : Double); pragma Import (C, ClearInterruptFlag, "opcode_cli"); pragma Import (C, SetInterruptFlag, "opcode_sti"); pragma Import (C, Halt, "opcode_hlt"); pragma Import (C, ID, "proc_cpuid"); pragma Import (C, InputByte, "input_byte"); pragma Import (C, InputWord, "input_word"); pragma Import (C, InputDouble, "input_double"); pragma Import (C, OutputByte, "output_byte"); pragma Import (C, OutputWord, "output_word"); pragma Import (C, OutputDouble, "output_double"); pragma Import (C, ReadCR0, "read_cr0"); pragma Import (C, ReadCR2, "read_cr2"); pragma Import (C, ReadCR3, "read_cr3"); pragma Import (C, ReadCR4, "read_cr4"); pragma Import (C, ReadDR0, "read_dr0"); pragma Import (C, ReadDR1, "read_dr1"); pragma Import (C, ReadDR2, "read_dr2"); pragma Import (C, ReadDR3, "read_dr3"); pragma Import (C, ReadDR6, "read_dr6"); pragma Import (C, ReadDR7, "read_dr7"); pragma Import (C, ReadFlags, "read_flags"); pragma Import (C, WriteCR0, "write_cr0"); pragma Import (C, WriteCR2, "write_cr2"); pragma Import (C, WriteCR3, "write_cr3"); pragma Import (C, WriteCR4, "write_cr4"); pragma Import (C, WriteDR0, "write_dr0"); pragma Import (C, WriteDR1, "write_dr1"); pragma Import (C, WriteDR2, "write_dr2"); pragma Import (C, WriteDR3, "write_dr3"); pragma Import (C, WriteDR6, "write_dr6"); pragma Import (C, WriteDR7, "write_dr7"); pragma Import (C, WriteFlags, "write_flags"); end CPU;
tum-ei-rcs/StratoX
Ada
14,598
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . T H R E A D S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2005 The European Space Agency -- -- Copyright (C) 2003-2016, AdaCore -- -- -- -- 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. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- 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. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); with System.Parameters; with System.BB.Parameters; with System.BB.Board_Support; with System.BB.Protection; with System.BB.Threads.Queues; with Ada.Unchecked_Conversion; package body System.BB.Threads is use System.Multiprocessors; use System.BB.CPU_Primitives; use System.BB.CPU_Primitives.Multiprocessors; use System.BB.Time; use System.BB.Parameters; use Board_Support; use type System.Address; use type System.Parameters.Size_Type; use type System.Storage_Elements.Storage_Offset; procedure Initialize_Thread (Id : Thread_Id; Code : System.Address; Arg : System.Address; Priority : Integer; This_CPU : System.Multiprocessors.CPU_Range; Stack_Top : System.Address; Stack_Bottom : System.Address); ----------------------- -- Stack information -- ----------------------- -- Boundaries of the stack for the environment task, defined by the linker -- script file. Top_Of_Environment_Stack : constant System.Address; pragma Import (Asm, Top_Of_Environment_Stack, "__stack_end"); -- Top of the stack to be used by the environment task Bottom_Of_Environment_Stack : constant System.Address; pragma Import (Asm, Bottom_Of_Environment_Stack, "__stack_start"); -- Bottom of the stack to be used by the environment task ------------------ -- Get_Affinity -- ------------------ function Get_Affinity (Thread : Thread_Id) return CPU_Range is begin return Thread.Base_CPU; end Get_Affinity; ------------- -- Get_CPU -- ------------- function Get_CPU (Thread : Thread_Id) return CPU is begin if Thread.Base_CPU = Not_A_Specific_CPU then -- Return the implementation specific default CPU return CPU'First; else return CPU (Thread.Base_CPU); end if; end Get_CPU; -------------- -- Get_ATCB -- -------------- function Get_ATCB return System.Address is begin -- This is not a light operation as there is a function call return Queues.Running_Thread.ATCB; end Get_ATCB; ------------------ -- Get_Priority -- ------------------ function Get_Priority (Id : Thread_Id) return Integer is begin -- This function does not need to be protected by Enter_Kernel and -- Leave_Kernel, because the Active_Priority value is only updated by -- Set_Priority (atomically). Moreover, Active_Priority is marked as -- Volatile. return Id.Active_Priority; end Get_Priority; ----------------------------- -- Initialize_Thread -- ----------------------------- procedure Initialize_Thread (Id : Thread_Id; Code : System.Address; Arg : System.Address; Priority : Integer; This_CPU : System.Multiprocessors.CPU_Range; Stack_Top : System.Address; Stack_Bottom : System.Address) is begin -- The environment thread executes the main procedure of the program -- CPU of the environment thread is current one (initialization CPU) Id.Base_CPU := This_CPU; -- The active priority is initially equal to the base priority Id.Base_Priority := Priority; Id.Active_Priority := Priority; -- Insert in the global list -- ??? Not thread safe. Id.Global_List := Queues.Global_List; Queues.Global_List := Id; -- Insert task inside the ready list (as last within its priority) Queues.Insert (Id); -- Store stack information Id.Top_Of_Stack := Stack_Top; Id.Bottom_Of_Stack := Stack_Bottom; -- The initial state is Runnable Id.State := Runnable; -- Not currently in an interrupt handler Id.In_Interrupt := False; -- No wakeup has been yet signaled Id.Wakeup_Signaled := False; -- Initialize alarm status Id.Alarm_Time := System.BB.Time.Time'Last; Id.Next_Alarm := Null_Thread_Id; -- Reset execution time Id.Execution_Time := System.BB.Time.Initial_Composite_Execution_Time; -- Initialize the saved registers. We can ignore the stack and code to -- execute because the environment task is already executing. We are -- interested in the initialization of the rest of the state, such as -- the interrupt nesting level and the cache state. Initialize_Context (Buffer => Id.Context'Access, Program_Counter => Code, Argument => Arg, Stack_Pointer => (if System.Parameters.Stack_Grows_Down then Id.Top_Of_Stack else Id.Bottom_Of_Stack)); end Initialize_Thread; ---------------- -- Initialize -- ---------------- procedure Initialize (Environment_Thread : Thread_Id; Main_Priority : System.Any_Priority) is Main_CPU : constant System.Multiprocessors.CPU := Current_CPU; begin -- Perform some basic hardware initialization (clock, timer, and -- interrupt handlers). -- First initialize interrupt stacks Interrupts.Initialize_Interrupts; -- Then the CPU (which set interrupt stack pointer) Initialize_CPU; -- Then the devices Board_Support.Initialize_Board; Time.Initialize_Timers; -- Initialize internal queues and the environment task Protection.Enter_Kernel; -- The environment thread executes the main procedure of the program Initialize_Thread (Environment_Thread, Null_Address, Null_Address, Main_Priority, Main_CPU, Top_Of_Environment_Stack'Address, Bottom_Of_Environment_Stack'Address); Queues.Running_Thread_Table (Main_CPU) := Environment_Thread; -- The tasking executive is initialized Initialized := True; Protection.Leave_Kernel; end Initialize; ---------------------- -- Initialize_Slave -- ---------------------- procedure Initialize_Slave (Idle_Thread : Thread_Id; Idle_Priority : Integer; Stack_Address : System.Address; Stack_Size : System.Storage_Elements.Storage_Offset) is CPU_Id : constant System.Multiprocessors.CPU := Current_CPU; begin Initialize_Thread (Idle_Thread, Null_Address, Null_Address, Idle_Priority, CPU_Id, Stack_Address + Stack_Size, Stack_Address); Queues.Running_Thread_Table (CPU_Id) := Idle_Thread; end Initialize_Slave; -------------- -- Set_ATCB -- -------------- procedure Set_ATCB (Id : Thread_Id; ATCB : System.Address) is begin -- Set_ATCB is only called in the initialization of the task Id.ATCB := ATCB; end Set_ATCB; ------------------ -- Set_Priority -- ------------------ procedure Set_Priority (Priority : Integer) is begin Protection.Enter_Kernel; -- The Ravenscar profile does not allow dynamic priority changes. Tasks -- change their priority only when they inherit the ceiling priority of -- a PO (Ceiling Locking policy). Hence, the task must be running when -- changing the priority. It is not possible to change the priority of -- another thread within the Ravenscar profile, so that is why -- Running_Thread is used. -- Priority changes are only possible as a result of inheriting the -- ceiling priority of a protected object. Hence, it can never be set -- a priority which is lower than the base priority of the thread. pragma Assert (Queues.Running_Thread /= Null_Thread_Id and then Priority >= Queues.Running_Thread.Base_Priority); Queues.Change_Priority (Queues.Running_Thread, Priority); Protection.Leave_Kernel; end Set_Priority; ----------- -- Sleep -- ----------- procedure Sleep is Self_Id : constant Thread_Id := Queues.Running_Thread; begin Protection.Enter_Kernel; -- It can only suspend if it is executing pragma Assert (Self_Id /= Null_Thread_Id and then Self_Id.State = Runnable); if Self_Id.Wakeup_Signaled then -- Another thread has already executed a Wakeup on this thread so -- that we just consume the token and continue execution. It means -- that just before this call to Sleep the task has been preempted -- by the task that is awaking it. Hence the Sleep/Wakeup calls do -- not happen in the expected order, and we use the Wakeup_Signaled -- to flag this event so it is not lost. -- The situation is the following: -- 1) a task A is going to wait in an entry for a barrier -- 2) task A releases the lock associated to the protected object -- 3) task A calls Sleep to suspend itself -- 4) a task B opens the barrier and awakes task A (calls Wakeup) -- This is the expected sequence of events, but 4) may happen -- before 3) because task A decreases its priority in step 2) as a -- consequence of releasing the lock (Ceiling_Locking). Hence, task -- A may be preempted by task B in the window between releasing the -- protected object and actually suspending itself, and the Wakeup -- call by task B in 4) can happen before the Sleep call in 3). Self_Id.Wakeup_Signaled := False; else -- Update status Self_Id.State := Suspended; -- Extract from the list of ready threads Queues.Extract (Self_Id); -- The currently executing thread is now blocked, and it will leave -- the CPU when executing the Leave_Kernel procedure. end if; Protection.Leave_Kernel; -- Now the thread has been awaken again and it is executing end Sleep; ------------------- -- Thread_Create -- ------------------- procedure Thread_Create (Id : Thread_Id; Code : System.Address; Arg : System.Address; Priority : Integer; Base_CPU : System.Multiprocessors.CPU_Range; Stack_Address : System.Address; Stack_Size : System.Storage_Elements.Storage_Offset) is begin Protection.Enter_Kernel; Initialize_Thread (Id, Code, Arg, Priority, Base_CPU, ((Stack_Address + Stack_Size) / Standard'Maximum_Alignment) * Standard'Maximum_Alignment, Stack_Address); Protection.Leave_Kernel; end Thread_Create; ----------------- -- Thread_Self -- ----------------- function Thread_Self return Thread_Id is begin -- Return the thread that is currently executing return Queues.Running_Thread; end Thread_Self; ------------ -- Wakeup -- ------------ procedure Wakeup (Id : Thread_Id) is begin Protection.Enter_Kernel; if Id.State = Suspended then -- The thread is already waiting so that we awake it -- Update status Id.State := Runnable; -- Insert the thread at the tail of its active priority so that the -- thread will resume execution. Queues.Insert (Id); else -- The thread is not yet waiting so that we just signal that the -- Wakeup command has been executed. We are waking up a task that -- is going to wait in an entry for a barrier, but before calling -- Sleep it has been preempted by the task awaking it. Id.Wakeup_Signaled := True; end if; pragma Assert (Id.State = Runnable); Protection.Leave_Kernel; end Wakeup; end System.BB.Threads;
persan/A-gst
Ada
3,197
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with System; with glib; with glib.Values; with System; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gst_h is -- GStreamer -- * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]> -- * 2000 Wim Taymans <[email protected]> -- * -- * gst.h: Main header for GStreamer, apps should include this -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, 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. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- -- API compatibility stuff procedure gst_init (argc : access int; argv : System.Address); -- gst/gst.h:86 pragma Import (C, gst_init, "gst_init"); function gst_init_check (argc : access int; argv : System.Address; err : System.Address) return GLIB.gboolean; -- gst/gst.h:87 pragma Import (C, gst_init_check, "gst_init_check"); function gst_is_initialized return GLIB.gboolean; -- gst/gst.h:89 pragma Import (C, gst_is_initialized, "gst_is_initialized"); function gst_init_get_option_group return System.Address; -- gst/gst.h:90 pragma Import (C, gst_init_get_option_group, "gst_init_get_option_group"); procedure gst_deinit; -- gst/gst.h:91 pragma Import (C, gst_deinit, "gst_deinit"); procedure gst_version (major : access GLIB.guint; minor : access GLIB.guint; micro : access GLIB.guint; nano : access GLIB.guint); -- gst/gst.h:93 pragma Import (C, gst_version, "gst_version"); function gst_version_string return access GLIB.gchar; -- gst/gst.h:95 pragma Import (C, gst_version_string, "gst_version_string"); function gst_segtrap_is_enabled return GLIB.gboolean; -- gst/gst.h:97 pragma Import (C, gst_segtrap_is_enabled, "gst_segtrap_is_enabled"); procedure gst_segtrap_set_enabled (enabled : GLIB.gboolean); -- gst/gst.h:98 pragma Import (C, gst_segtrap_set_enabled, "gst_segtrap_set_enabled"); function gst_registry_fork_is_enabled return GLIB.gboolean; -- gst/gst.h:100 pragma Import (C, gst_registry_fork_is_enabled, "gst_registry_fork_is_enabled"); procedure gst_registry_fork_set_enabled (enabled : GLIB.gboolean); -- gst/gst.h:101 pragma Import (C, gst_registry_fork_set_enabled, "gst_registry_fork_set_enabled"); function gst_update_registry return GLIB.gboolean; -- gst/gst.h:103 pragma Import (C, gst_update_registry, "gst_update_registry"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gst_h;
wookey-project/ewok-legacy
Ada
1,507
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks; use ewok.tasks; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.perm; use ewok.perm; with ewok.debug; with m4.scb; package body ewok.syscalls.reset with spark_mode => off is procedure sys_reset (caller_id : in ewok.tasks_shared.t_task_id; mode : in ewok.tasks_shared.t_task_mode) is begin if not ewok.perm.ressource_is_granted (PERM_RES_TSK_RESET, caller_id) then set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end if; m4.scb.reset; debug.panic ("soc.nvic.reset failed !?!"); end sys_reset; end ewok.syscalls.reset;
reznikmm/matreshka
Ada
4,663
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Restart_Numbering_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Restart_Numbering_Attribute_Node is begin return Self : Text_Restart_Numbering_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Restart_Numbering_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Restart_Numbering_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Restart_Numbering_Attribute, Text_Restart_Numbering_Attribute_Node'Tag); end Matreshka.ODF_Text.Restart_Numbering_Attributes;
flyx/OpenGLAda
Ada
2,161
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" package Glfw.Windows.Context is type OpenGL_Profile_Kind is (System_Default, Core_Profile, Compat_Profile); type API_Kind is (OpenGL, OpenGL_ES); type Robustness_Kind is (No_Robustness, No_Reset_Notification, Lose_Context_On_Reset); subtype Swap_Interval is Interfaces.C.int; procedure Make_Current (Window : access Glfw.Windows.Window'Class); function Current return access Glfw.Windows.Window'Class; procedure Swap_Buffers (Window : not null access Glfw.Windows.Window'Class); procedure Set_Swap_Interval (Value : Swap_Interval); function Client_API (Window : not null access Glfw.Windows.Window'Class) return API_Kind; function Profile (Window : not null access Glfw.Windows.Window'Class) return OpenGL_Profile_Kind; procedure Get_Context_Version (Window : not null access Glfw.Windows.Window'Class; Major : out Positive; Minor, Revision : out Natural); function Is_Forward_Compat (Window : not null access Glfw.Windows.Window'Class) return Boolean; function Is_Debug_Context (Window : not null access Glfw.Windows.Window'Class) return Boolean; function Robustness (Window : not null access Glfw.Windows.Window'Class) return Robustness_Kind; private for OpenGL_Profile_Kind use (System_Default => 0, Core_Profile => 16#32001#, Compat_Profile => 16#32002#); for OpenGL_Profile_Kind'Size use Interfaces.C.int'Size; for API_Kind use (OpenGL => 16#30001#, OpenGL_ES => 16#30002#); for API_Kind'Size use Interfaces.C.int'Size; for Robustness_Kind use (No_Robustness => 0, No_Reset_Notification => 16#31001#, Lose_Context_On_Reset => 16#31002#); for Robustness_Kind'Size use Interfaces.C.int'Size; -- implemented with renames pragma Convention (C, Set_Swap_Interval); end Glfw.Windows.Context;
charlie5/lace
Ada
1,904
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with c_math_c.Pointers; with Interfaces.C; package c_math_c.Matrix_4x4 is -- Item -- type Item is record m00 : aliased c_math_c.Real; m01 : aliased c_math_c.Real; m02 : aliased c_math_c.Real; m03 : aliased c_math_c.Real; m10 : aliased c_math_c.Real; m11 : aliased c_math_c.Real; m12 : aliased c_math_c.Real; m13 : aliased c_math_c.Real; m20 : aliased c_math_c.Real; m21 : aliased c_math_c.Real; m22 : aliased c_math_c.Real; m23 : aliased c_math_c.Real; m30 : aliased c_math_c.Real; m31 : aliased c_math_c.Real; m32 : aliased c_math_c.Real; m33 : aliased c_math_c.Real; end record; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased c_math_c.Matrix_4x4.Item; -- Pointer -- type Pointer is access all c_math_c.Matrix_4x4.Item; -- Pointers -- type Pointers is array (Interfaces.C.size_t range <>) of aliased c_math_c.Matrix_4x4.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all c_math_c.Matrix_4x4.Pointer; function construct return c_math_c.Matrix_4x4.Item; function construct (First : in c_math_c.Pointers.Real_Pointer) return c_math_c.Matrix_4x4.Item; private function construct_v1 return c_math_c.Matrix_4x4.Item; function construct return c_math_c.Matrix_4x4.Item renames construct_v1; pragma Import (C, construct_v1, "Ada_new_Matrix_4x4__SWIG_0"); function construct_v2 (First : in c_math_c.Pointers.Real_Pointer) return c_math_c.Matrix_4x4.Item; function construct (First : in c_math_c.Pointers.Real_Pointer) return c_math_c.Matrix_4x4.Item renames construct_v2; pragma Import (C, construct_v2, "Ada_new_Matrix_4x4__SWIG_1"); end c_math_c.Matrix_4x4;
riccardo-bernardini/eugen
Ada
464
adb
pragma Ada_2012; package body Line_Parsers.Receivers.Parsed_Receivers is ------------- -- Receive -- ------------- procedure Receive (Handler : in out Receiver_Type; Name : String; Value : String; Position : Natural) is pragma Unreferenced (Name, Position); begin Handler.Value := Parse (Value); Handler.Set := True; end Receive; end Line_Parsers.Receivers.Parsed_Receivers;
sungyeon/drake
Ada
5,317
adb
with Ada.Unchecked_Conversion; package body Ada.Numerics.SFMT.Generating is -- SSE2 version type v4si is array (1 .. 4) of Unsigned_32; for v4si'Alignment use 16; pragma Machine_Attribute (v4si, "vector_type"); pragma Machine_Attribute (v4si, "may_alias"); pragma Suppress_Initialization (v4si); type m128i is array (1 .. 2) of Unsigned_64; for m128i'Alignment use 16; pragma Machine_Attribute (m128i, "vector_type"); pragma Machine_Attribute (m128i, "may_alias"); pragma Suppress_Initialization (m128i); function To_v4si is new Unchecked_Conversion (m128i, v4si); function To_m128i is new Unchecked_Conversion (v4si, m128i); function ia32_psrldi128 (A : v4si; B : Integer) return v4si with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrldi128"; function ia32_pslldi128 (A : v4si; B : Integer) return v4si with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pslldi128"; function mm_srli_si128 (A : m128i; B : Integer) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrldqi128"; function mm_slli_si128 (A : m128i; B : Integer) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pslldqi128"; function mm_and_si128 (A, B : m128i) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pand128"; function mm_xor_si128 (A, B : m128i) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pxor128"; procedure mm_recursion (r : out m128i; a, b, c, d : m128i) with Convention => Intrinsic; pragma Inline_Always (mm_recursion); -- This function represents the recursion formula. procedure mm_recursion (r : out m128i; a, b, c, d : m128i) is -- parameters used by sse2. sse2_param_mask : constant v4si := (MSK1, MSK2, MSK3, MSK4); v, x, y, z : m128i; begin y := To_m128i (ia32_psrldi128 (To_v4si (b), SR1)); -- mm_srli_epi32 z := mm_srli_si128 (c, SR2 * 8); v := To_m128i (ia32_pslldi128 (To_v4si (d), SL1)); -- mm_slli_epi32 z := mm_xor_si128 (z, a); z := mm_xor_si128 (z, v); x := mm_slli_si128 (a, SL2 * 8); y := mm_and_si128 (y, To_m128i (sse2_param_mask)); z := mm_xor_si128 (z, x); z := mm_xor_si128 (z, y); r := z; end mm_recursion; -- implementation -- This function fills the internal state array with pseudorandom -- integers. procedure gen_rand_all ( sfmt : in out w128_t_Array_N) is i : Integer; r1, r2 : m128i; pstate_si : array (0 .. sfmt'Size / 128 - 1) of aliased m128i; for pstate_si'Address use sfmt'Address; begin r1 := pstate_si (N - 2); r2 := pstate_si (N - 1); i := 0; while i < N - POS1 loop mm_recursion ( pstate_si (i), pstate_si (i), pstate_si (i + POS1), r1, r2); r1 := r2; r2 := pstate_si (i); i := i + 1; end loop; while i < N loop mm_recursion ( pstate_si (i), pstate_si (i), pstate_si (i - (N - POS1)), r1, r2); r1 := r2; r2 := pstate_si (i); i := i + 1; end loop; end gen_rand_all; -- This function fills the user-specified array with pseudorandom -- integers. procedure gen_rand_array ( sfmt : in out w128_t_Array_N; Item : in out w128_t_Array_1; size : Integer) is i, j : Integer; r1, r2 : m128i; pstate_si : array (0 .. sfmt'Size / 128 - 1) of aliased m128i; for pstate_si'Address use sfmt'Address; array_si : array (0 .. size - 1) of aliased m128i; for array_si'Address use Item'Address; begin r1 := pstate_si (N - 2); r2 := pstate_si (N - 1); i := 0; while i < N - POS1 loop mm_recursion ( array_si (i), pstate_si (i), pstate_si (i + POS1), r1, r2); r1 := r2; r2 := array_si (i); i := i + 1; end loop; while i < N loop mm_recursion ( array_si (i), pstate_si (i), array_si (i - (N - POS1)), r1, r2); r1 := r2; r2 := array_si (i); i := i + 1; end loop; -- main loop while i < size - N loop mm_recursion ( array_si (i), array_si (i - N), array_si (i - (N - POS1)), r1, r2); r1 := r2; r2 := array_si (i); i := i + 1; end loop; j := 0; while j < N - (size - N) loop pstate_si (j) := array_si (j + (size - N)); j := j + 1; end loop; while i < size loop mm_recursion ( array_si (i), array_si (i - N), array_si (i - (N - POS1)), r1, r2); r1 := r2; r2 := array_si (i); pstate_si (j) := array_si (i); i := i + 1; j := j + 1; end loop; end gen_rand_array; end Ada.Numerics.SFMT.Generating;
stcarrez/ada-keystore
Ada
16,870
ads
----------------------------------------------------------------------- -- keystore -- Ada keystore -- Copyright (C) 2019, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Encoders; with Util.Streams; with Ada.Streams; with Ada.Calendar; with Ada.Containers.Indefinite_Ordered_Maps; with Interfaces; with GNAT.Regpat; private with Ada.Exceptions; private with Ada.Finalization; private with Util.Executors; -- == Keystore == -- The `Keystore` package provides operations to store information in secure wallets and -- protect the stored information by encrypting the content. It is necessary to know one -- of the wallet password to access its content. Wallets are protected by a master key -- using AES-256 and the wallet master key is protected by a user password. The wallet -- defines up to 7 slots that identify a password key that is able to unlock the master key. -- To open a wallet, it is necessary to unlock one of the 7 slots by providing the correct -- password. Wallet key slots are protected by the user's password and the PBKDF2-HMAC-256 -- algorithm, a random salt, a random counter and they are encrypted using AES-256. -- -- === Creation === -- To create a keystore you will first declare a `Wallet_File` instance. You will also need -- a password that will be used to protect the wallet master key. -- -- with Keystore.Files; -- ... -- WS : Keystore.Files.Wallet_File; -- Pass : Keystore.Secret_Key := Keystore.Create ("There was no choice but to be pioneers"); -- -- You can then create the keystore file by using the `Create` operation: -- -- WS.Create ("secure.akt", Pass); -- -- === Storing === -- Values stored in the wallet are protected by their own encryption keys using AES-256. -- The encryption key is generated when the value is added to the wallet by using the `Add` -- operation. -- -- WS.Add ("Grace Hopper", "If it's a good idea, go ahead and do it."); -- -- The `Get` function allows to retrieve the value. The value is decrypted only when the `Get` -- operation is called. -- -- Citation : constant String := WS.Get ("Grace Hopper"); -- -- The `Delete` procedure can be used to remove the value. When the value is removed, -- the encryption key and the data are erased. -- -- WS.Delete ("Grace Hopper"); -- package Keystore is subtype Secret_Key is Util.Encoders.Secret_Key; subtype Key_Length is Util.Encoders.Key_Length; function Create (Password : in String) return Secret_Key renames Util.Encoders.Create; -- Exception raised when a keystore entry was not found. Not_Found : exception; -- Exception raised when a keystore entry already exist. Name_Exist : exception; -- Exception raised when the wallet cannot be opened with the given password. Bad_Password : exception; -- Exception raised by Set_Key when there is no available free slot to add a new key. No_Key_Slot : exception; -- Exception raised by Set_Header_Data when the slot index is out of range. No_Header_Slot : exception; -- Exception raised when trying to get/set an item which is a wallet. No_Content : exception; -- The key slot is used (it cannot be erased unless the operation is forced). Used_Key_Slot : exception; -- Exception raised when the wallet is corrupted. Corrupted : exception; -- Exception raised when opening the keystore and the header is invalid. Invalid_Keystore : exception; -- Exception raised when there is a configuration issue. Invalid_Config : exception; -- Invalid data block when reading the wallet. Invalid_Block : exception; -- Invalid HMAC signature when reading a block. Invalid_Signature : exception; -- Invalid storage identifier when loading a wallet data block. Invalid_Storage : exception; -- The wallet state. type State_Type is (S_INVALID, S_PROTECTED, S_OPEN, S_CLOSED); -- Identifies the type of data stored for a named entry in the wallet. type Entry_Type is (T_INVALID, T_STRING, T_FILE, T_DIRECTORY, T_BINARY, T_WALLET); type Filter_Type is array (Entry_Type) of Boolean; -- Defines the key operation mode. type Mode_Type is (KEY_ADD, KEY_REPLACE, KEY_REMOVE); -- Defines the key slot number. type Key_Slot is new Positive range 1 .. 7; -- Defines which key slot is used. type Key_Slot_Allocation is array (Key_Slot) of Boolean; type Header_Slot_Count_Type is new Natural range 0 .. 32; subtype Header_Slot_Index_Type is Header_Slot_Count_Type range 1 .. Header_Slot_Count_Type'Last; -- Header slot type is a 16-bit values that identifies the data type slot. type Header_Slot_Type is new Interfaces.Unsigned_16; SLOT_EMPTY : constant Header_Slot_Type := 0; SLOT_KEY_GPG1 : constant Header_Slot_Type := 1; -- Contains key encrypted using GPG1 SLOT_KEY_GPG2 : constant Header_Slot_Type := 2; -- Contains key encrypted using GPG2 type UUID_Type is private; function To_String (UUID : in UUID_Type) return String; type Wallet_Info is record UUID : UUID_Type; Header_Count : Header_Slot_Count_Type := 0; Storage_Count : Natural := 0; end record; -- Information about a keystore entry. type Entry_Info is record Size : Interfaces.Unsigned_64 := 0; Kind : Entry_Type := T_INVALID; Create_Date : Ada.Calendar.Time; Update_Date : Ada.Calendar.Time; Block_Count : Natural := 0; end record; package Entry_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String, Element_Type => Entry_Info); subtype Entry_Map is Entry_Maps.Map; subtype Entry_Cursor is Entry_Maps.Cursor; -- Task manager to run encryption and decryption work. -- It can be assigned to the wallet through the `Set_Task_Manager` procedure. type Task_Manager (Count : Positive) is limited private; type Task_Manager_Access is access all Task_Manager; -- Start the tasks of the task manager. procedure Start (Manager : in Task_Manager_Access); -- Stop the tasks. procedure Stop (Manager : in Task_Manager_Access); -- Configuration to create or open a keystore. type Wallet_Config is record Randomize : Boolean := True; Overwrite : Boolean := False; Cache_Directory : Boolean := True; Max_Counter : Positive := 300_000; Min_Counter : Positive := 100_000; Max_File_Size : Positive := Positive'Last; Storage_Count : Positive := 1; end record; -- Fast configuration but less secure. Unsecure_Config : constant Wallet_Config := (Randomize => False, Overwrite => False, Cache_Directory => True, Min_Counter => 10_000, Max_Counter => 100_000, Max_File_Size => Positive'Last, Storage_Count => 1); -- Slow configuration but more secure. Secure_Config : constant Wallet_Config := (Randomize => True, Overwrite => False, Cache_Directory => True, Min_Counter => 500_000, Max_Counter => 1_000_000, Max_File_Size => Positive'Last, Storage_Count => 1); type Wallet_Stats is record UUID : UUID_Type; Keys : Key_Slot_Allocation := (others => False); Entry_Count : Natural := 0; Total_Size : Natural := 0; Block_Count : Natural := 0; Free_Block_Count : Natural := 0; Storage_Count : Natural := 0; end record; -- The wallet base type. type Wallet is abstract tagged limited private; -- Return True if the container was configured. function Is_Configured (Container : in Wallet) return Boolean is abstract; -- Return True if the container can be accessed. function Is_Open (Container : in Wallet) return Boolean is abstract; -- Get the wallet state. function State (Container : in Wallet) return State_Type is abstract; -- Set the key to encrypt and decrypt the container meta data. procedure Set_Key (Container : in out Wallet; Secret : in Secret_Key; New_Secret : in Secret_Key; Config : in Wallet_Config := Secure_Config; Mode : in Mode_Type := KEY_REPLACE) is abstract with Pre'Class => Container.Is_Open; -- Return True if the container contains the given named entry. function Contains (Container : in Wallet; Name : in String) return Boolean is abstract with Pre'Class => Container.Is_Open; -- Add in the wallet the named entry and associate it the content. -- The content is encrypted in AES-CBC with a secret key and an IV vector -- that is created randomly for the new named entry. procedure Add (Container : in out Wallet; Name : in String; Content : in String) with Pre => Wallet'Class (Container).Is_Open, Post => Wallet'Class (Container).Contains (Name); -- Add in the wallet the named entry and associate it the content. -- The content is encrypted in AES-CBC with a secret key and an IV vector -- that is created randomly for the new named entry. procedure Add (Container : in out Wallet; Name : in String; Kind : in Entry_Type := T_BINARY; Content : in Ada.Streams.Stream_Element_Array) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); procedure Add (Container : in out Wallet; Name : in String; Kind : in Entry_Type := T_BINARY; Input : in out Util.Streams.Input_Stream'Class) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Add or update in the wallet the named entry and associate it the content. -- The content is encrypted in AES-CBC with a secret key and an IV vector -- that is created randomly for the new or updated named entry. procedure Set (Container : in out Wallet; Name : in String; Kind : in Entry_Type := T_BINARY; Content : in Ada.Streams.Stream_Element_Array) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Add or update in the wallet the named entry and associate it the content. -- The content is encrypted in AES-CBC with a secret key and an IV vector -- that is created randomly for the new or updated named entry. procedure Set (Container : in out Wallet; Name : in String; Content : in String) with Pre => Wallet'Class (Container).Is_Open, Post => Wallet'Class (Container).Contains (Name); procedure Set (Container : in out Wallet; Name : in String; Kind : in Entry_Type := T_BINARY; Input : in out Util.Streams.Input_Stream'Class) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Update in the wallet the named entry and associate it the new content. -- The secret key and IV vectors are not changed. procedure Update (Container : in out Wallet; Name : in String; Content : in String) with Pre => Wallet'Class (Container).Is_Open, Post => Wallet'Class (Container).Contains (Name); -- Update in the wallet the named entry and associate it the new content. -- The secret key and IV vectors are not changed. procedure Update (Container : in out Wallet; Name : in String; Kind : in Entry_Type := T_BINARY; Content : in Ada.Streams.Stream_Element_Array) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Read from the wallet the named entry starting at the given position. -- Upon successful completion, Last will indicate the last valid position of -- the Content array. procedure Read (Container : in out Wallet; Name : in String; Offset : in Ada.Streams.Stream_Element_Offset; Content : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Write in the wallet the named entry starting at the given position. -- The existing content is overwritten or new content is appended. procedure Write (Container : in out Wallet; Name : in String; Offset : in Ada.Streams.Stream_Element_Offset; Content : in Ada.Streams.Stream_Element_Array) is abstract with Pre'Class => Container.Is_Open, Post'Class => Container.Contains (Name); -- Delete from the wallet the named entry. procedure Delete (Container : in out Wallet; Name : in String) is abstract with Pre'Class => Container.Is_Open, Post'Class => not Container.Contains (Name); -- Get from the wallet the named entry. function Get (Container : in out Wallet; Name : in String) return String with Pre => Wallet'Class (Container).Is_Open; procedure Get (Container : in out Wallet; Name : in String; Info : out Entry_Info; Content : out Ada.Streams.Stream_Element_Array) is abstract with Pre'Class => Wallet'Class (Container).Is_Open; -- Write in the output stream the named entry value from the wallet. procedure Get (Container : in out Wallet; Name : in String; Output : in out Util.Streams.Output_Stream'Class) is abstract with Pre'Class => Container.Is_Open; -- Get the list of entries contained in the wallet that correspond to the optional filter. procedure List (Container : in out Wallet; Filter : in Filter_Type := (others => True); Content : out Entry_Map) is abstract with Pre'Class => Container.Is_Open; -- Get the list of entries contained in the wallet that correspond to the optiona filter -- and whose name matches the pattern. procedure List (Container : in out Wallet; Pattern : in GNAT.Regpat.Pattern_Matcher; Filter : in Filter_Type := (others => True); Content : out Entry_Map) is abstract with Pre'Class => Container.Is_Open; function Find (Container : in out Wallet; Name : in String) return Entry_Info is abstract with Pre'Class => Container.Is_Open; DEFAULT_WALLET_KEY : constant String := "If you can't give me poetry, can't you give me poetical science?"; private type UUID_Type is array (1 .. 4) of Interfaces.Unsigned_32; type Wallet_Identifier is new Positive; type Wallet_Entry_Index is new Interfaces.Unsigned_32 range 1 .. Interfaces.Unsigned_32'Last; type Wallet is abstract limited new Ada.Finalization.Limited_Controlled with null record; type Work_Type is limited interface; type Work_Type_Access is access all Work_Type'Class; procedure Execute (Work : in out Work_Type) is abstract; procedure Execute (Work : in out Work_Type_Access); procedure Error (Work : in out Work_Type_Access; Ex : in Ada.Exceptions.Exception_Occurrence); package Executors is new Util.Executors (Work_Type => Work_Type_Access, Execute => Execute, Error => Error); type Task_Manager (Count : Positive) is limited new Executors.Executor_Manager (Count) with null record; overriding procedure Execute (Manager : in out Task_Manager; Work : in Work_Type_Access); end Keystore;
OneWingedShark/Byron
Ada
265
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Byron.Generics.Vector; Package Lexington.Token_Vector_Pkg.Tie_In is new Byron.Generics.Vector( Vector => Vector, Index_Type => Positive, Element_Type => Lexington.Aux.Token );
Rodeo-McCabe/orka
Ada
6,814
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[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 System.Address_To_Access_Conversions; with Interfaces.C.Strings; with Ada.Task_Identification; with Glfw.API; package body Glfw.Monitors is package Conversions is new System.Address_To_Access_Conversions (Monitor'Class); function Monitor_Ptr (Raw : System.Address) return not null access Monitor'Class is begin return Conversions.To_Pointer (API.Get_Monitor_User_Pointer (Raw)); end Monitor_Ptr; function No_Monitor return Monitor is ((Handle => System.Null_Address)); function "=" (Left, Right : Monitor) return Boolean is use type System.Address; begin return Left.Handle = Right.Handle; end "="; function Monitors return Monitor_List is use type API.Address_List_Pointers.Pointer; Count : aliased Interfaces.C.int; Raw : constant API.Address_List_Pointers.Pointer := API.Get_Monitors (Count'Access); begin if Raw /= null then declare List : constant API.Address_List := API.Address_List_Pointers.Value (Raw, Interfaces.C.ptrdiff_t (Count)); begin return Ret : Monitor_List (List'Range) do for I in List'Range loop Ret (I).Handle := List (I); API.Set_Monitor_User_Pointer (Ret (I).Handle, Conversions.To_Address (Conversions.Object_Pointer'(Ret (I)'Unchecked_Access))); end loop; end return; end; else raise Operation_Exception; end if; end Monitors; function To_Monitor (Raw : System.Address) return Monitor is use type System.Address; begin if Raw /= System.Null_Address then return Result : Monitor := Monitor'(Handle => Raw) do API.Set_Monitor_User_Pointer (Result.Handle, Conversions.To_Address (Conversions.Object_Pointer'(Result'Unchecked_Access))); end return; else raise Operation_Exception; end if; end To_Monitor; function Primary_Monitor return Monitor is (To_Monitor (API.Get_Primary_Monitor)); procedure Get_Position (Object : Monitor; X, Y : out Integer) is X_Raw, Y_Raw : Interfaces.C.int; begin API.Get_Monitor_Pos (Object.Handle, X_Raw, Y_Raw); X := Integer (X_Raw); Y := Integer (Y_Raw); end Get_Position; procedure Get_Physical_Size (Object : Monitor; Width, Height : out Integer) is Width_Raw, Height_Raw : Interfaces.C.int; begin API.Get_Monitor_Physical_Size (Object.Handle, Width_Raw, Height_Raw); Width := Integer (Width_Raw); Height := Integer (Height_Raw); end Get_Physical_Size; procedure Get_Content_Scale (Object : Monitor; X, Y : out Float) is X_Raw, Y_Raw : Interfaces.C.C_float; begin API.Get_Monitor_Content_Scale (Object.Handle, X_Raw, Y_Raw); X := Float (X_Raw); Y := Float (Y_Raw); end Get_Content_Scale; procedure Get_Workarea (Object : Monitor; X, Y, Width, Height : out Integer) is X_Raw, Y_Raw, Width_Raw, Height_Raw : Interfaces.C.int; begin API.Get_Monitor_Workarea (Object.Handle, X_Raw, Y_Raw, Width_Raw, Height_Raw); X := Integer (X_Raw); Y := Integer (Y_Raw); Width := Integer (Width_Raw); Height := Integer (Height_Raw); end Get_Workarea; function Name (Object : Monitor) return String is begin return Interfaces.C.Strings.Value (API.Get_Monitor_Name (Object.Handle)); end Name; function Video_Modes (Object : Monitor) return Video_Mode_List is use type API.VMode_List_Pointers.Pointer; Count : aliased Interfaces.C.int; Raw : constant API.VMode_List_Pointers.Pointer := API.Get_Video_Modes (Object.Handle, Count'Access); begin if Raw /= null then return API.VMode_List_Pointers.Value (Raw, Interfaces.C.ptrdiff_t (Count)); else raise Operation_Exception; end if; end Video_Modes; function Current_Video_Mode (Object : Monitor) return Video_Mode is begin return API.Get_Video_Mode (Object.Handle).all; end Current_Video_Mode; procedure Set_Gamma (Object : Monitor; Gamma : Float) is begin API.Set_Gamma (Object.Handle, Interfaces.C.C_float (Gamma)); end Set_Gamma; function Current_Gamma_Ramp (Object : Monitor) return Gamma_Ramp is Raw : constant access constant API.Raw_Gamma_Ramp := API.Get_Gamma_Ramp (Object.Handle); begin return Ret : Gamma_Ramp (Integer (Raw.Size)) do Ret.Red := API.Unsigned_Short_List_Pointers.Value (Raw.Red, Interfaces.C.ptrdiff_t (Raw.Size)); Ret.Green := API.Unsigned_Short_List_Pointers.Value (Raw.Green, Interfaces.C.ptrdiff_t (Raw.Size)); Ret.Blue := API.Unsigned_Short_List_Pointers.Value (Raw.Blue, Interfaces.C.ptrdiff_t (Raw.Size)); end return; end Current_Gamma_Ramp; procedure Set_Gamma_Ramp (Object : Monitor; Value : Gamma_Ramp) is Raw : aliased API.Raw_Gamma_Ramp; Ramp : Gamma_Ramp := Value; begin Raw.Size := Interfaces.C.unsigned (Ramp.Size); Raw.Red := Ramp.Red (Ramp.Red'First)'Unchecked_Access; Raw.Green := Ramp.Green (Ramp.Green'First)'Unchecked_Access; Raw.Blue := Ramp.Blue (Ramp.Blue'First)'Unchecked_Access; API.Set_Gamma_Ramp (Object.Handle, Raw'Access); end Set_Gamma_Ramp; function Raw_Pointer (Object : Monitor) return System.Address is begin return Object.Handle; end Raw_Pointer; procedure Raw_Handler (Monitor : System.Address; State : Event) with Convention => C; procedure Raw_Handler (Monitor : System.Address; State : Event) is begin Monitor_Ptr (Monitor).Event_Occurred (State); end Raw_Handler; use Ada.Task_Identification; procedure Set_Callback (Object : Monitor; Enable : Boolean) is pragma Assert (Current_Task = Environment_Task); begin API.Set_Monitor_Callback (Object.Handle, (if Enable then Raw_Handler'Access else null)); end Set_Callback; end Glfw.Monitors;
charlie5/cBound
Ada
157
adb
with GMP.discrete; procedure Minimal is use GMP, gmp.Discrete; Distance : discrete.Integer; begin define (Distance); destroy (Distance); end;
charlie5/cBound
Ada
1,617
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_gen_textures_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; n : aliased Interfaces.Integer_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_gen_textures_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_gen_textures_request_t.Item, Element_Array => xcb.xcb_glx_gen_textures_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_gen_textures_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_gen_textures_request_t.Pointer, Element_Array => xcb.xcb_glx_gen_textures_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_gen_textures_request_t;
jhumphry/Ada_BinToAsc
Ada
9,600
adb
-- BinToAsc_Suite.Base16_Tests -- Unit tests for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Ada.Assertions; with AUnit.Assertions; with System.Storage_Elements; with String_To_Storage_Array; package body BinToAsc_Suite.Base16_Tests is use AUnit.Assertions; use System.Storage_Elements; use RFC4648; use type RFC4648.Codec_State; function STSA (X : String) return Storage_Array renames String_To_Storage_Array; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out Base16_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Symmetry'Access, "Check the Encoder and Decoder are a symmetrical pair"); Register_Routine (T, Check_Length'Access, "Check the Encoder and Decoder handle variable-length input successfully"); Register_Routine (T, Check_Test_Vectors_To_String'Access, "Check test vectors from RFC4648, binary -> string"); Register_Routine (T, Check_Test_Vectors_To_Bin'Access, "Check test vectors from RFC4648, string -> binary"); Register_Routine (T, Check_Test_Vectors_Incremental_To_String'Access, "Check test vectors from RFC4648, incrementally, binary -> string"); Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin'Access, "Check test vectors from RFC4648, incrementally, string -> binary"); Register_Routine (T, Check_Test_Vectors_By_Char_To_String'Access, "Check test vectors from RFC4648, character-by-character, binary -> string"); Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin'Access, "Check test vectors from RFC4648, character-by-character, string -> binary"); Register_Routine (T, Check_Junk_Rejection'Access, "Check Base16 decoder will reject junk input"); Register_Routine (T, Check_Junk_Rejection_By_Char'Access, "Check Base16 decoder will reject junk input (single character)"); Register_Routine (T, Check_Incomplete_Group_Rejection'Access, "Check Base16 decoder will reject incomplete groups in input"); Register_Routine (T, Check_Case_Insensitive'Access, "Check Base16_Case_Insensitive decoder will accept mixed-case input"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : Base16_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Base16 codec from RFC4648"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Base16_Test) is begin null; end Set_Up; -------------------------- -- Check_Junk_Rejection -- -------------------------- -- This procedure cannot be nested inside Check_Junk_Rejection due to access -- level restrictions procedure Should_Raise_Exception_From_Junk is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base16.To_Bin("666F6F6Z6172"); end; procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_From_Junk'Access, "Base16 decoder did not reject junk input."); Base16_Decoder.Reset; Base16_Decoder.Process(Input => "666F6F6Z6172", Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not reject junk input."); Assert(Result_Length = 0, "Base16 decoder rejected junk input but did not return 0 " & "length output."); begin Base16_Decoder.Process(Input => "66", Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder reset its state on valid input after junk input."); Assert(Result_Length = 0, "Base16 decoder rejected input after a junk input but did " & "not return 0 length output."); begin Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input."); Assert(Result_Length = 0, "Base16 decoder completed after a junk input did " & "not return 0 length output."); end Check_Junk_Rejection; ---------------------------------- -- Check_Junk_Rejection_By_Char -- ---------------------------------- procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Base16_Decoder.Reset; Base16_Decoder.Process(Input => 'Y', Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not reject junk input character."); Assert(Result_Length = 0, "Base16 decoder rejected junk input but did not return 0 " & "length output."); begin Base16_Decoder.Process(Input => '6', Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder reset its state on valid input after junk input " & "character."); Assert(Result_Length = 0, "Base16 decoder rejected input after a junk input char but did " & "not return 0 length output."); begin Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input " & "char."); Assert(Result_Length = 0, "Base16 decoder completed after a junk input char did " & "not return 0 length output."); end Check_Junk_Rejection_By_Char; -------------------------------------- -- Check_Incomplete_Group_Rejection -- -------------------------------------- procedure Check_Incomplete_Group_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array (1..20); Result_Length : Storage_Offset; begin Base16_Decoder.Reset; Base16_Decoder.Process(Input => "666F6F6", Output => Result_Bin, Output_Length => Result_Length); Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not complain " & "about receiving an incomplete group."); end Check_Incomplete_Group_Rejection; ---------------------------- -- Check_Case_Insensitive -- ---------------------------- procedure Check_Case_Insensitive (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); Test_Input : constant Storage_Array := STSA("foobar"); Encoded : constant String := "666F6F626172"; Encoded_Mixed_Case : constant String := "666F6f626172"; Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Buffer : Storage_Array(1..7); Buffer_Used : Storage_Offset; begin Assert(Test_Input = RFC4648.Base16.To_Bin(Encoded), "Base16 case-sensitive decoder not working"); Base16_Decoder.Reset; Base16_Decoder.Process(Encoded_Mixed_Case, Buffer, Buffer_Used); Assert(Base16_Decoder.State = Failed and Buffer_Used = 0, "Base16 case-sensitive decoder did not reject mixed-case input"); Assert(Test_Input = RFC4648.Base16_Case_Insensitive.To_Bin(Encoded_Mixed_Case), "Base16 case-insensitive decoder not working"); end Check_Case_Insensitive; end BinToAsc_Suite.Base16_Tests;
godunko/adagl
Ada
3,363
ads
------------------------------------------------------------------------------ -- -- -- Ada binding for OpenGL/WebGL -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2018, 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. -- -- -- ------------------------------------------------------------------------------ with WebAPI.WebGL.Renderbuffers; package OpenGL.Renderbuffers.Internals is pragma Preelaborate; function Get_WebGL_Renderbuffer (Self : OpenGL_Renderbuffer'Class) return WebAPI.WebGL.Renderbuffers.WebGL_Renderbuffer_Access; end OpenGL.Renderbuffers.Internals;
Gabriel-Degret/adalib
Ada
8,086
ads
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Iterator_Interfaces; generic type Element_Type (<>) is private; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Indefinite_Multiway_Trees is pragma Preelaborate(Indefinite_Multiway_Trees); pragma Remote_Types(Indefinite_Multiway_Trees); type Tree is tagged private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; pragma Preelaborable_Initialization(Tree); type Cursor is private; pragma Preelaborable_Initialization(Cursor); Empty_Tree : constant Tree; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package Tree_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); function Equal_Subtree (Left_Position : Cursor; Right_Position: Cursor) return Boolean; function "=" (Left, Right : Tree) return Boolean; function Is_Empty (Container : Tree) return Boolean; function Node_Count (Container : Tree) return Count_Type; function Subtree_Node_Count (Position : Cursor) return Count_Type; function Depth (Position : Cursor) return Count_Type; function Is_Root (Position : Cursor) return Boolean; function Is_Leaf (Position : Cursor) return Boolean; function Root (Container : Tree) return Cursor; procedure Clear (Container : in out Tree); function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Tree; Position : in Cursor; New_Item : in Element_Type); procedure Query_Element (Position : in Cursor; Process : not null access procedure (Element : in Element_Type)); procedure Update_Element (Container : in out Tree; Position : in Cursor; Process : not null access procedure (Element : in out Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased in Tree; Position : in Cursor) return Constant_Reference_Type; function Reference (Container : aliased in out Tree; Position : in Cursor) return Reference_Type; procedure Assign (Target : in out Tree; Source : in Tree); function Copy (Source : Tree) return Tree; procedure Move (Target : in out Tree; Source : in out Tree); procedure Delete_Leaf (Container : in out Tree; Position : in out Cursor); procedure Delete_Subtree (Container : in out Tree; Position : in out Cursor); procedure Swap (Container : in out Tree; I, J : in Cursor); function Find (Container : Tree; Item : Element_Type) return Cursor; function Find_In_Subtree (Position : Cursor; Item : Element_Type) return Cursor; function Ancestor_Find (Position : Cursor; Item : Element_Type) return Cursor; function Contains (Container : Tree; Item : Element_Type) return Boolean; procedure Iterate (Container : in Tree; Process : not null access procedure (Position : in Cursor)); procedure Iterate_Subtree (Position : in Cursor; Process : not null access procedure (Position : in Cursor)); function Iterate (Container : in Tree) return Tree_Iterator_Interfaces.Forward_Iterator'Class; function Iterate_Subtree (Position : in Cursor) return Tree_Iterator_Interfaces.Forward_Iterator'Class; function Child_Count (Parent : Cursor) return Count_Type; function Child_Depth (Parent, Child : Cursor) return Count_Type; procedure Insert_Child (Container : in out Tree; Parent : in Cursor; Before : in Cursor; New_Item : in Element_Type; Count : in Count_Type := 1); procedure Insert_Child (Container : in out Tree; Parent : in Cursor; Before : in Cursor; New_Item : in Element_Type; Position : out Cursor; Count : in Count_Type := 1); procedure Prepend_Child (Container : in out Tree; Parent : in Cursor; New_Item : in Element_Type; Count : in Count_Type := 1); procedure Append_Child (Container : in out Tree; Parent : in Cursor; New_Item : in Element_Type; Count : in Count_Type := 1); procedure Delete_Children (Container : in out Tree; Parent : in Cursor); procedure Copy_Subtree (Target : in out Tree; Parent : in Cursor; Before : in Cursor; Source : in Cursor); procedure Splice_Subtree (Target : in out Tree; Parent : in Cursor; Before : in Cursor; Source : in out Tree; Position : in out Cursor); procedure Splice_Subtree (Container: in out Tree; Parent : in Cursor; Before : in Cursor; Position : in Cursor); procedure Splice_Children (Target : in out Tree; Target_Parent : in Cursor; Before : in Cursor; Source : in out Tree; Source_Parent : in Cursor); procedure Splice_Children (Container : in out Tree; Target_Parent : in Cursor; Before : in Cursor; Source_Parent : in Cursor); function Parent (Position : Cursor) return Cursor; function First_Child (Parent : Cursor) return Cursor; function First_Child_Element (Parent : Cursor) return Element_Type; function Last_Child (Parent : Cursor) return Cursor; function Last_Child_Element (Parent : Cursor) return Element_Type; function Next_Sibling (Position : Cursor) return Cursor; function Previous_Sibling (Position : Cursor) return Cursor; procedure Next_Sibling (Position : in out Cursor); procedure Previous_Sibling (Position : in out Cursor); procedure Iterate_Children (Parent : in Cursor; Process : not null access procedure (Position : in Cursor)); procedure Reverse_Iterate_Children (Parent : in Cursor; Process : not null access procedure (Position : in Cursor)); function Iterate_Children (Container : in Tree; Parent : in Cursor) return Tree_Iterator_Interfaces.Reversible_Iterator'Class; private -- not specified by the language end Ada.Containers.Indefinite_Multiway_Trees;
AdaCore/libadalang
Ada
506
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Derived_Aggregate is type Float is delta 0.01 digits 10; type Integer is range 1 .. 10; type Rec is tagged record A, B : Float; end record; type Rec_2 is new Rec with record C, D : Integer; R : Rec; end record; R : Rec_2; function Foo return Integer is (2); function Foo return Float is (2.0); begin R := (A => 1.0, B => 2.0, C => 3, D => 4, R => (1.0, Foo)); pragma Test_Statement; end Derived_Aggregate;
iyan22/AprendeAda
Ada
1,264
adb
with ada.text_io, ada.integer_text_io; use ada.text_io, ada.integer_text_io; with multporsumas; procedure prueba_multporsumas is numero, multiplicador, resultado: integer; begin -- Caso de prueba 1: multiplicación estándar numero:=3; multiplicador:=4; put("El resultado de la multiplicacion es 12"); new_line; put("Y tu programa dice que es:"); resultado:=multporsumas(numero, multiplicador); put(resultado); new_line; -- Caso de prueba 2: numero 0 numero:=0; multiplicador:=4; put("El resultado de la multiplicacion es 0"); new_line; put("Y tu programa dice que es:"); resultado:=multporsumas(numero, multiplicador); put(resultado); new_line; -- Caso de prueba 3: multiplicador 0 numero:=5; multiplicador:=0; put("El resultado de la multiplicacion es 0"); new_line; put("Y tu programa dice que es:"); resultado:=multporsumas(numero, multiplicador); put(resultado); new_line; -- Caso de prueba 4: 2 números altos numero:=10; multiplicador:=10; put("El resultado de la multiplicacion es 100"); new_line; put("Y tu programa dice que es:"); resultado:=multporsumas(numero, multiplicador); put(resultado); new_line; end prueba_multporsumas;
charlie5/cBound
Ada
1,440
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_tex_parameterfv_cookie_t is -- Item -- type Item is record sequence : aliased Interfaces.C.unsigned; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_tex_parameterfv_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_parameterfv_cookie_t.Item, Element_Array => xcb.xcb_glx_get_tex_parameterfv_cookie_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_tex_parameterfv_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_parameterfv_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_tex_parameterfv_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_tex_parameterfv_cookie_t;
msrLi/portingSources
Ada
769
ads
-- Copyright 2008-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is Watch : Integer := 4874; end Pck;
zhmu/ananas
Ada
157
adb
with Text_IO; use Text_IO; package body Ifaces is procedure op1 (this : Root) is begin null; end; procedure op2 (this : DT) is begin null; end; end;
stcarrez/hestia
Ada
1,080
ads
----------------------------------------------------------------------- -- hestia-config -- Hestia configuration -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Hestia.Config is -- Maximum number of zones to control. MAX_ZONES : constant := 3; -- Simple timezone correction (+1 hour, not DST support yet). TIME_ZONE_CORRECTION : constant := 60; end Hestia.Config;
micahwelf/FLTK-Ada
Ada
845
ads
package FLTK.Widgets.Buttons.Radio is type Radio_Button is new Button with private; type Radio_Button_Reference (Data : not null access Radio_Button'Class) is limited null record with Implicit_Dereference => Data; package Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Radio_Button; end Forge; procedure Draw (This : in out Radio_Button); function Handle (This : in out Radio_Button; Event : in Event_Kind) return Event_Outcome; private type Radio_Button is new Button with null record; overriding procedure Finalize (This : in out Radio_Button); pragma Inline (Draw); pragma Inline (Handle); end FLTK.Widgets.Buttons.Radio;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
3,908
ads
-- This spec has been automatically generated from STM32F072x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.PWR is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_LPDS_Field is STM32_SVD.Bit; subtype CR_PDDS_Field is STM32_SVD.Bit; subtype CR_CWUF_Field is STM32_SVD.Bit; subtype CR_CSBF_Field is STM32_SVD.Bit; subtype CR_PVDE_Field is STM32_SVD.Bit; subtype CR_PLS_Field is STM32_SVD.UInt3; subtype CR_DBP_Field is STM32_SVD.Bit; subtype CR_FPDS_Field is STM32_SVD.Bit; -- power control register type CR_Register is record -- Low-power deep sleep LPDS : CR_LPDS_Field := 16#0#; -- Power down deepsleep PDDS : CR_PDDS_Field := 16#0#; -- Clear wakeup flag CWUF : CR_CWUF_Field := 16#0#; -- Clear standby flag CSBF : CR_CSBF_Field := 16#0#; -- Power voltage detector enable PVDE : CR_PVDE_Field := 16#0#; -- PVD level selection PLS : CR_PLS_Field := 16#0#; -- Disable backup domain write protection DBP : CR_DBP_Field := 16#0#; -- Flash power down in Stop mode FPDS : CR_FPDS_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record LPDS at 0 range 0 .. 0; PDDS at 0 range 1 .. 1; CWUF at 0 range 2 .. 2; CSBF at 0 range 3 .. 3; PVDE at 0 range 4 .. 4; PLS at 0 range 5 .. 7; DBP at 0 range 8 .. 8; FPDS at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype CSR_WUF_Field is STM32_SVD.Bit; subtype CSR_SBF_Field is STM32_SVD.Bit; subtype CSR_PVDO_Field is STM32_SVD.Bit; subtype CSR_BRR_Field is STM32_SVD.Bit; subtype CSR_EWUP_Field is STM32_SVD.Bit; subtype CSR_BRE_Field is STM32_SVD.Bit; -- power control/status register type CSR_Register is record -- Read-only. Wakeup flag WUF : CSR_WUF_Field := 16#0#; -- Read-only. Standby flag SBF : CSR_SBF_Field := 16#0#; -- Read-only. PVD output PVDO : CSR_PVDO_Field := 16#0#; -- Read-only. Backup regulator ready BRR : CSR_BRR_Field := 16#0#; -- unspecified Reserved_4_7 : STM32_SVD.UInt4 := 16#0#; -- Enable WKUP pin EWUP : CSR_EWUP_Field := 16#0#; -- Backup regulator enable BRE : CSR_BRE_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record WUF at 0 range 0 .. 0; SBF at 0 range 1 .. 1; PVDO at 0 range 2 .. 2; BRR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; EWUP at 0 range 8 .. 8; BRE at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Power control type PWR_Peripheral is record -- power control register CR : aliased CR_Register; -- power control/status register CSR : aliased CSR_Register; end record with Volatile; for PWR_Peripheral use record CR at 16#0# range 0 .. 31; CSR at 16#4# range 0 .. 31; end record; -- Power control PWR_Periph : aliased PWR_Peripheral with Import, Address => System'To_Address (16#40007000#); end STM32_SVD.PWR;
reznikmm/matreshka
Ada
9,375
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$ ------------------------------------------------------------------------------ with AMF.CMOF.Classifiers.Collections; with AMF.CMOF.Classes.Collections; with AMF.CMOF.Elements.Collections; with AMF.CMOF.Features.Collections; with AMF.CMOF.Named_Elements.Collections; with AMF.CMOF.Namespaces; with AMF.CMOF.Operations.Collections; with AMF.CMOF.Packageable_Elements.Collections; with AMF.CMOF.Packages; with AMF.CMOF.Properties.Collections; with AMF.Internals.CMOF_Classifiers; with AMF.String_Collections; with AMF.Visitors; package AMF.Internals.CMOF_Classes is type CMOF_Class_Proxy is limited new AMF.Internals.CMOF_Classifiers.CMOF_Classifier_Proxy and AMF.CMOF.Classes.CMOF_Class with null record; -- XXX These subprograms are stubs overriding function All_Owned_Elements (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element; overriding function Get_Qualified_Name (Self : not null access constant CMOF_Class_Proxy) return Optional_String; overriding function Is_Distinguishable_From (Self : not null access constant CMOF_Class_Proxy; N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access; Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access) return Boolean; overriding procedure Set_Package (Self : not null access CMOF_Class_Proxy; To : AMF.CMOF.Packages.CMOF_Package_Access); overriding function Imported_Member (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element; overriding function Get_Names_Of_Member (Self : not null access constant CMOF_Class_Proxy; Element : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access) return AMF.String_Collections.Set_Of_String; overriding function Import_Members (Self : not null access constant CMOF_Class_Proxy; Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element; overriding function Exclude_Collisions (Self : not null access constant CMOF_Class_Proxy; Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element; overriding function Members_Are_Distinguishable (Self : not null access constant CMOF_Class_Proxy) return Boolean; overriding procedure Set_Is_Final_Specialization (Self : not null access CMOF_Class_Proxy; To : Boolean); overriding function Conforms_To (Self : not null access constant CMOF_Class_Proxy; Other : AMF.CMOF.Classifiers.CMOF_Classifier_Access) return Boolean; overriding function All_Features (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Features.Collections.Set_Of_CMOF_Feature; overriding function General (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier; overriding function Parents (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier; overriding function Inherited_Member (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element; overriding function All_Parents (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier; overriding function Inheritable_Members (Self : not null access constant CMOF_Class_Proxy; C : AMF.CMOF.Classifiers.CMOF_Classifier_Access) return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element; overriding function Has_Visibility_Of (Self : not null access constant CMOF_Class_Proxy; N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access) return Boolean; overriding function Inherit (Self : not null access constant CMOF_Class_Proxy; Inhs : AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element) return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element; overriding function May_Specialize_Type (Self : not null access constant CMOF_Class_Proxy; C : AMF.CMOF.Classifiers.CMOF_Classifier_Access) return Boolean; overriding function Get_Is_Abstract (Self : not null access constant CMOF_Class_Proxy) return Boolean; overriding procedure Set_Is_Abstract (Self : not null access CMOF_Class_Proxy; To : Boolean); overriding function Get_Owned_Attribute (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property; overriding function Get_Owned_Operation (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Operations.Collections.Ordered_Set_Of_CMOF_Operation; overriding function Get_Super_Class (Self : not null access constant CMOF_Class_Proxy) return AMF.CMOF.Classes.Collections.Set_Of_CMOF_Class; overriding procedure Enter_Element (Self : not null access constant CMOF_Class_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant CMOF_Class_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant CMOF_Class_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.CMOF_Classes;
tum-ei-rcs/StratoX
Ada
3,524
adb
------------------------------------------------------------------------------ -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ package body STM32.Board is ------------------ -- All_LEDs_Off -- ------------------ procedure All_LEDs_Off is begin Set (All_LEDs); end All_LEDs_Off; ----------------- -- All_LEDs_On -- ----------------- procedure All_LEDs_On is begin Clear (All_LEDs); end All_LEDs_On; --------------------- -- Initialize_LEDs -- --------------------- procedure Initialize_LEDs is Conf : GPIO_Port_Configuration; begin Enable_Clock (All_LEDs); Conf.Mode := Mode_Out; Conf.Output_Type := Push_Pull; Conf.Speed := Speed_100MHz; Conf.Resistors := Floating; Configure_IO (All_LEDs, Conf); All_LEDs_Off; end Initialize_LEDs; -------------------------------- -- Configure_User_Button_GPIO -- -------------------------------- procedure Configure_User_Button_GPIO is Config : GPIO_Port_Configuration; begin Enable_Clock (User_Button_Point); Config.Mode := Mode_In; Config.Resistors := Floating; Configure_IO (User_Button_Point, Config); end Configure_User_Button_GPIO; end STM32.Board;
AdaCore/libadalang
Ada
2,676
adb
procedure Test is type T is null record with Value_Size => 10; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") type New_T_1 is new T with Value_Size => 8; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") type New_T_2 is new T; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") type New_T_3 is new T; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") for New_T_3'Value_Size use 7; subtype Sub_T_1 is T with Value_Size => 6; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") subtype Sub_T_2 is T; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") subtype Sub_T_3 is T; --% node.p_get_aspect("Value_Size") --% node.p_has_aspect("Value_Size") for Sub_T_3'Value_Size use 5; type A is array (1 .. 10) of Integer with Pack; --% node.p_get_aspect("Pack") --% node.p_has_aspect("Pack") type New_A is new A; --% node.p_get_aspect("Pack") --% node.p_has_aspect("Pack") subtype Sub_A is A; --% node.p_get_aspect("Pack") --% node.p_has_aspect("Pack") type New_S is new String; --% node.p_get_aspect("Pack") --% node.p_has_aspect("Pack") --% node.p_get_pragma("Pack") --% node.p_root_type().p_get_aspect("Pack") type TG is tagged null record with Value_Size => 128; --% node.p_get_aspect("Value_Size") type New_TG_1 is new TG with record X : Boolean; end record with Value_Size => 192; --% node.p_get_aspect("Value_Size") type New_TG_2 is new TG with record X : Boolean; end record; --% node.p_get_aspect("Value_Size") for New_TG_2'Value_Size use 192; type New_TG_3 is new TG with record X : Boolean; end record; --% node.p_get_aspect("Value_Size") subtype Sub_TG_1 is TG with Value_Size => 256; --% node.p_get_aspect("Value_Size") subtype Sub_TG_2 is TG; --% node.p_get_aspect("Value_Size") for Sub_TG_2'Value_Size use 192; subtype Sub_TG_3 is TG; --% node.p_get_aspect("Value_Size") type I is new T with Value_Size => 13; subtype J is I; type K is new J with Value_Size => 14; subtype Sub_T_4 is J; --% node.p_get_aspect("Value_Size") subtype Sub_T_5 is K; --% node.p_get_aspect("Value_Size") type New_New_T_1 is new New_T_1; --% node.p_get_aspect("Value_Size") type New_New_T_2 is new New_T_2; --% node.p_get_aspect("Value_Size") type New_New_T_3 is new New_T_3; --% node.p_get_aspect("Value_Size") type New_New_New_T_3 is new New_New_T_3 with Value_Size => 1024; --% node.p_get_aspect("Value_Size") begin null; end Test;
reznikmm/matreshka
Ada
3,606
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.Elements.Generic_Hash; function AMF.Utp.Log_Actions.Hash is new AMF.Elements.Generic_Hash (Utp_Log_Action, Utp_Log_Action_Access);
reznikmm/gela
Ada
2,545
ads
-- This package provides Compilation_Unit interfaces and their methods. with League.Calendars; with League.String_Vectors; with League.Strings; with Gela.Contexts; with Gela.Element_Factories; with Gela.Lexical_Types; package Gela.Compilations is pragma Preelaborate; type Compilation is limited interface; -- This type represent single compilation from some context type Compilation_Access is access all Compilation'Class; for Compilation_Access'Storage_Size use 0; not overriding function Context (Self : Compilation) return Gela.Contexts.Context_Access is abstract; -- Return corresponding context not overriding function Text_Name (Self : Compilation) return League.Strings.Universal_String is abstract; -- Return name of compilation source not overriding function Object_Name (Self : Compilation) return League.Strings.Universal_String is abstract; -- Return name of compilation result not overriding function Compilation_Command_Line_Options (Self : Compilation) return League.String_Vectors.Universal_String_Vector is abstract; -- Return compilation options not overriding function Time_Of_Last_Update (Self : Compilation) return League.Calendars.Date_Time is abstract; -- Return time of compilation not overriding function Compilation_CPU_Duration (Self : Compilation) return Duration is abstract; -- Return duration of compilation not overriding function Source (Self : Compilation) return League.Strings.Universal_String is abstract; -- Return source test of compilation not overriding function Line_Count (Self : Compilation) return Gela.Lexical_Types.Line_Count is abstract; -- Return line count of compilation source not overriding function Get_Line_Span (Self : Compilation; Index : Gela.Lexical_Types.Line_Index) return Gela.Lexical_Types.Line_Span is abstract; -- Return indexes in source of begin, end and comment for given line not overriding function Token_Count (Self : Compilation) return Gela.Lexical_Types.Token_Count is abstract; -- Return token count of compilation source not overriding function Get_Token (Self : Compilation; Index : Gela.Lexical_Types.Token_Index) return Gela.Lexical_Types.Token is abstract; -- Return token information for given token not overriding function Factory (Self : Compilation) return Gela.Element_Factories.Element_Factory_Access is abstract; end Gela.Compilations;
reznikmm/matreshka
Ada
3,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Subtotal_Rules_Elements is pragma Preelaborate; type ODF_Table_Subtotal_Rules is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Subtotal_Rules_Access is access all ODF_Table_Subtotal_Rules'Class with Storage_Size => 0; end ODF.DOM.Table_Subtotal_Rules_Elements;
reznikmm/matreshka
Ada
4,882
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides implementation of string handling subprograms for -- generic platform. Package has two implementations: for 32-bit and for -- 64-bit platform. ------------------------------------------------------------------------------ package Matreshka.Internals.Strings.Handlers.Portable is pragma Preelaborate; type Portable_String_Handler is new Abstract_String_Handler with null record; overriding procedure Fill_Null_Terminator (Self : Portable_String_Handler; Item : not null Shared_String_Access); overriding function Is_Equal (Self : Portable_String_Handler; Left : not null Shared_String_Access; Right : not null Shared_String_Access) return Boolean; overriding function Is_Less (Self : Portable_String_Handler; Left : not null Shared_String_Access; Right : not null Shared_String_Access) return Boolean; overriding function Is_Greater (Self : Portable_String_Handler; Left : not null Shared_String_Access; Right : not null Shared_String_Access) return Boolean; overriding function Is_Less_Or_Equal (Self : Portable_String_Handler; Left : not null Shared_String_Access; Right : not null Shared_String_Access) return Boolean; overriding function Is_Greater_Or_Equal (Self : Portable_String_Handler; Left : not null Shared_String_Access; Right : not null Shared_String_Access) return Boolean; Handler : aliased Portable_String_Handler; end Matreshka.Internals.Strings.Handlers.Portable;
redparavoz/ada-wiki
Ada
1,312
adb
----------------------------------------------------------------------- -- Wiki testsuite - Ada Wiki Test suite -- Copyright (C) 2015, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Parsers.Tests; with Wiki.Tests; with Wiki.Filters.Html.Tests; package body Wiki.Testsuite is Tests : aliased Util.Tests.Test_Suite; function Suite return Util.Tests.Access_Test_Suite is Ret : constant Util.Tests.Access_Test_Suite := Tests'Access; begin Wiki.Filters.Html.Tests.Add_Tests (Ret); Wiki.Parsers.Tests.Add_Tests (Ret); Wiki.Tests.Add_Tests (Ret); return Ret; end Suite; end Wiki.Testsuite;
reznikmm/matreshka
Ada
17,797
adb
------------------------------------------------------------------------------ -- -- -- 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.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.OCL_Attributes; with AMF.UML.Classifiers; with AMF.UML.Comments.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces.Collections; with AMF.UML.Packages.Collections; with AMF.UML.String_Expressions; with AMF.UML.Types; with AMF.Visitors.OCL_Iterators; with AMF.Visitors.OCL_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.OCL_Type_Exps is ----------------------- -- Get_Referred_Type -- ----------------------- overriding function Get_Referred_Type (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access is begin return AMF.UML.Classifiers.UML_Classifier_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Referred_Type (Self.Element))); end Get_Referred_Type; ----------------------- -- Set_Referred_Type -- ----------------------- overriding procedure Set_Referred_Type (Self : not null access OCL_Type_Exp_Proxy; To : AMF.UML.Classifiers.UML_Classifier_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Referred_Type (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Referred_Type; -------------- -- Get_Type -- -------------- overriding function Get_Type (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Types.UML_Type_Access is begin return AMF.UML.Types.UML_Type_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Type (Self.Element))); end Get_Type; -------------- -- Set_Type -- -------------- overriding procedure Set_Type (Self : not null access OCL_Type_Exp_Proxy; To : AMF.UML.Types.UML_Type_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Type (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Type; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Name; -------------- -- Set_Name -- -------------- overriding procedure Set_Name (Self : not null access OCL_Type_Exp_Proxy; To : AMF.Optional_String) is begin if To.Is_Empty then AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, null); else AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, League.Strings.Internals.Internal (To.Value)); end if; end Set_Name; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access OCL_Type_Exp_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; -------------------- -- Get_Visibility -- -------------------- overriding function Get_Visibility (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Optional_UML_Visibility_Kind is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility (Self.Element); end Get_Visibility; -------------------- -- Set_Visibility -- -------------------- overriding procedure Set_Visibility (Self : not null access OCL_Type_Exp_Proxy; To : AMF.UML.Optional_UML_Visibility_Kind) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility (Self.Element, To); end Set_Visibility; ----------------------- -- Get_Owned_Comment -- ----------------------- overriding function Get_Owned_Comment (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Comments.Collections.Set_Of_UML_Comment is begin return AMF.UML.Comments.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment (Self.Element))); end Get_Owned_Comment; ----------------------- -- Get_Owned_Element -- ----------------------- overriding function Get_Owned_Element (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element (Self.Element))); end Get_Owned_Element; --------------- -- Get_Owner -- --------------- overriding function Get_Owner (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Elements.UML_Element_Access is begin return AMF.UML.Elements.UML_Element_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner (Self.Element))); end Get_Owner; -------------------- -- All_Namespaces -- -------------------- overriding function All_Namespaces (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.All_Namespaces"; return All_Namespaces (Self); end All_Namespaces; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant OCL_Type_Exp_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.Namespace"; return Namespace (Self); end Namespace; -------------------- -- Qualified_Name -- -------------------- overriding function Qualified_Name (Self : not null access constant OCL_Type_Exp_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.Qualified_Name"; return Qualified_Name (Self); end Qualified_Name; --------------- -- Separator -- --------------- overriding function Separator (Self : not null access constant OCL_Type_Exp_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Separator unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.Separator"; return Separator (Self); end Separator; ------------------------ -- All_Owned_Elements -- ------------------------ overriding function All_Owned_Elements (Self : not null access constant OCL_Type_Exp_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.All_Owned_Elements"; return All_Owned_Elements (Self); end All_Owned_Elements; ------------------- -- Must_Be_Owned -- ------------------- overriding function Must_Be_Owned (Self : not null access constant OCL_Type_Exp_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Type_Exp_Proxy.Must_Be_Owned"; return Must_Be_Owned (Self); end Must_Be_Owned; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant OCL_Type_Exp_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Enter_Type_Exp (AMF.OCL.Type_Exps.OCL_Type_Exp_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant OCL_Type_Exp_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Leave_Type_Exp (AMF.OCL.Type_Exps.OCL_Type_Exp_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant OCL_Type_Exp_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.OCL_Iterators.OCL_Iterator'Class then AMF.Visitors.OCL_Iterators.OCL_Iterator'Class (Iterator).Visit_Type_Exp (Visitor, AMF.OCL.Type_Exps.OCL_Type_Exp_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.OCL_Type_Exps;
zhmu/ananas
Ada
26,291
ads
------------------------------------------------------------------------------ -- -- -- GNU ADA 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 -- -- -- -- S p e c -- -- -- -- 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 package contains all the GNULL primitives that interface directly with -- the underlying OS. with System.Parameters; with System.Tasking; with System.OS_Interface; package System.Task_Primitives.Operations is pragma Preelaborate; package ST renames System.Tasking; package OSI renames System.OS_Interface; procedure Initialize (Environment_Task : ST.Task_Id); -- Perform initialization and set up of the environment task for proper -- operation of the tasking run-time. This must be called once, before any -- other subprograms of this package are called. procedure Create_Task (T : ST.Task_Id; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean); pragma Inline (Create_Task); -- Create a new low-level task with ST.Task_Id T and place other needed -- information in the ATCB. -- -- A new thread of control is created, with a stack of at least Stack_Size -- storage units, and the procedure Wrapper is called by this new thread -- of control. If Stack_Size = Unspecified_Storage_Size, choose a default -- stack size; this may be effectively "unbounded" on some systems. -- -- The newly created low-level task is associated with the ST.Task_Id T -- such that any subsequent call to Self from within the context of the -- low-level task returns T. -- -- The caller is responsible for ensuring that the storage of the Ada -- task control block object pointed to by T persists for the lifetime -- of the new task. -- -- Succeeded is set to true unless creation of the task failed, -- as it may if there are insufficient resources to create another task. procedure Enter_Task (Self_ID : ST.Task_Id); pragma Inline (Enter_Task); -- Initialize data structures specific to the calling task. Self must be -- the ID of the calling task. It must be called (once) by the task -- immediately after creation, while abort is still deferred. The effects -- of other operations defined below are not defined unless the caller has -- previously called Initialize_Task. procedure Exit_Task; pragma Inline (Exit_Task); -- Destroy the thread of control. Self must be the ID of the calling task. -- The effects of further calls to operations defined below on the task -- are undefined thereafter. ---------------------------------- -- ATCB allocation/deallocation -- ---------------------------------- package ATCB_Allocation is function New_ATCB (Entry_Num : ST.Task_Entry_Index) return ST.Task_Id; pragma Inline (New_ATCB); -- Allocate a new ATCB with the specified number of entries procedure Free_ATCB (T : ST.Task_Id); pragma Inline (Free_ATCB); -- Deallocate an ATCB previously allocated by New_ATCB end ATCB_Allocation; function New_ATCB (Entry_Num : ST.Task_Entry_Index) return ST.Task_Id renames ATCB_Allocation.New_ATCB; procedure Initialize_TCB (Self_ID : ST.Task_Id; Succeeded : out Boolean); pragma Inline (Initialize_TCB); -- Initialize all fields of the TCB procedure Finalize_TCB (T : ST.Task_Id); pragma Inline (Finalize_TCB); -- Finalizes Private_Data of ATCB, and then deallocates it. This is also -- responsible for recovering any storage or other resources that were -- allocated by Create_Task (the one in this package). This should only be -- called from Free_Task. After it is called there should be no further -- reference to the ATCB that corresponds to T. procedure Abort_Task (T : ST.Task_Id); pragma Inline (Abort_Task); -- Abort the task specified by T (the target task). This causes the target -- task to asynchronously raise Abort_Signal if abort is not deferred, or -- if it is blocked on an interruptible system call. -- -- precondition: -- the calling task is holding T's lock and has abort deferred -- -- postcondition: -- the calling task is holding T's lock and has abort deferred. -- ??? modify GNARL to skip wakeup and always call Abort_Task function Self return ST.Task_Id; pragma Inline (Self); -- Return a pointer to the Ada Task Control Block of the calling task type Lock_Level is (PO_Level, Global_Task_Level, RTS_Lock_Level, ATCB_Level); -- Type used to describe kind of lock for second form of Initialize_Lock -- call specified below. See locking rules in System.Tasking (spec) for -- more details. procedure Initialize_Lock (Prio : System.Any_Priority; L : not null access Lock); procedure Initialize_Lock (L : not null access RTS_Lock; Level : Lock_Level); pragma Inline (Initialize_Lock); -- Initialize a lock object -- -- For Lock, Prio is the ceiling priority associated with the lock. For -- RTS_Lock, the ceiling is implicitly Priority'Last. -- -- If the underlying system does not support priority ceiling -- locking, the Prio parameter is ignored. -- -- The effect of either initialize operation is undefined unless is a lock -- object that has not been initialized, or which has been finalized since -- it was last initialized. -- -- The effects of the other operations on lock objects are undefined -- unless the lock object has been initialized and has not since been -- finalized. -- -- Initialization of the per-task lock is implicit in Create_Task -- -- These operations raise Storage_Error if a lack of storage is detected procedure Finalize_Lock (L : not null access Lock); procedure Finalize_Lock (L : not null access RTS_Lock); pragma Inline (Finalize_Lock); -- Finalize a lock object, freeing any resources allocated by the -- corresponding Initialize_Lock operation. procedure Write_Lock (L : not null access Lock; Ceiling_Violation : out Boolean); procedure Write_Lock (L : not null access RTS_Lock); procedure Write_Lock (T : ST.Task_Id); pragma Inline (Write_Lock); -- Lock a lock object for write access. After this operation returns, -- the calling task holds write permission for the lock object. No other -- Write_Lock or Read_Lock operation on the same lock object will return -- until this task executes an Unlock operation on the same object. The -- effect is undefined if the calling task already holds read or write -- permission for the lock object L. -- -- For the operation on Lock, Ceiling_Violation is set to true iff the -- operation failed, which will happen if there is a priority ceiling -- violation. -- -- For the operation on ST.Task_Id, the lock is the special lock object -- associated with that task's ATCB. This lock has effective ceiling -- priority high enough that it is safe to call by a task with any -- priority in the range System.Priority. It is implicitly initialized -- by task creation. The effect is undefined if the calling task already -- holds T's lock, or has interrupt-level priority. Finalization of the -- per-task lock is implicit in Exit_Task. procedure Read_Lock (L : not null access Lock; Ceiling_Violation : out Boolean); pragma Inline (Read_Lock); -- Lock a lock object for read access. After this operation returns, -- the calling task has non-exclusive read permission for the logical -- resources that are protected by the lock. No other Write_Lock operation -- on the same object will return until this task and any other tasks with -- read permission for this lock have executed Unlock operation(s) on the -- lock object. A Read_Lock for a lock object may return immediately while -- there are tasks holding read permission, provided there are no tasks -- holding write permission for the object. The effect is undefined if -- the calling task already holds read or write permission for L. -- -- Alternatively: An implementation may treat Read_Lock identically to -- Write_Lock. This simplifies the implementation, but reduces the level -- of concurrency that can be achieved. -- -- Note that Read_Lock is not defined for RT_Lock and ST.Task_Id. -- That is because (1) so far Read_Lock has always been implemented -- the same as Write_Lock, (2) most lock usage inside the RTS involves -- potential write access, and (3) implementations of priority ceiling -- locking that make a reader-writer distinction have higher overhead. procedure Unlock (L : not null access Lock); procedure Unlock (L : not null access RTS_Lock); procedure Unlock (T : ST.Task_Id); pragma Inline (Unlock); -- Unlock a locked lock object -- -- The effect is undefined unless the calling task holds read or write -- permission for the lock L, and L is the lock object most recently -- locked by the calling task for which the calling task still holds -- read or write permission. (That is, matching pairs of Lock and Unlock -- operations on each lock object must be properly nested.) -- Note that Write_Lock for RTS_Lock does not have an out-parameter. -- RTS_Locks are used in situations where we have not made provision for -- recovery from ceiling violations. We do not expect them to occur inside -- the runtime system, because all RTS locks have ceiling Priority'Last. -- There is one way there can be a ceiling violation. That is if the -- runtime system is called from a task that is executing in the -- Interrupt_Priority range. -- It is not clear what to do about ceiling violations due to RTS calls -- done at interrupt priority. In general, it is not acceptable to give -- all RTS locks interrupt priority, since that would give terrible -- performance on systems where this has the effect of masking hardware -- interrupts, though we could get away allowing Interrupt_Priority'last -- where we are layered on an OS that does not allow us to mask interrupts. -- Ideally, we would like to raise Program_Error back at the original point -- of the RTS call, but this would require a lot of detailed analysis and -- recoding, with almost certain performance penalties. -- For POSIX systems, we considered just skipping setting priority ceiling -- on RTS locks. This would mean there is no ceiling violation, but we -- would end up with priority inversions inside the runtime system, -- resulting in failure to satisfy the Ada priority rules, and possible -- missed validation tests. This could be compensated-for by explicit -- priority-change calls to raise the caller to Priority'Last whenever it -- first enters the runtime system, but the expected overhead seems high, -- though it might be lower than using locks with ceilings if the -- underlying implementation of ceiling locks is an inefficient one. -- This issue should be reconsidered whenever we get around to checking -- for calls to potentially blocking operations from within protected -- operations. If we check for such calls and catch them on entry to the -- OS, it may be that we can eliminate the possibility of ceiling -- violations inside the RTS. For this to work, we would have to forbid -- explicitly setting the priority of a task to anything in the -- Interrupt_Priority range, at least. We would also have to check that -- there are no RTS-lock operations done inside any operations that are -- not treated as potentially blocking. -- The latter approach seems to be the best, i.e. to check on entry to RTS -- calls that may need to use locks that the priority is not in the -- interrupt range. If there are RTS operations that NEED to be called -- from interrupt handlers, those few RTS locks should then be converted -- to PO-type locks, with ceiling Interrupt_Priority'Last. -- For now, we will just shut down the system if there is ceiling violation procedure Set_Ceiling (L : not null access Lock; Prio : System.Any_Priority); pragma Inline (Set_Ceiling); -- Change the ceiling priority associated to the lock -- -- The effect is undefined unless the calling task holds read or write -- permission for the lock L, and L is the lock object most recently -- locked by the calling task for which the calling task still holds -- read or write permission. (That is, matching pairs of Lock and Unlock -- operations on each lock object must be properly nested.) procedure Yield (Do_Yield : Boolean := True); pragma Inline (Yield); -- Yield the processor. Add the calling task to the tail of the ready queue -- for its active_priority. On most platforms, Yield is a no-op if Do_Yield -- is False. But on some platforms (notably VxWorks), Do_Yield is ignored. -- This is only used in some very rare cases where a Yield should have an -- effect on a specific target and not on regular ones. procedure Set_Priority (T : ST.Task_Id; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False); pragma Inline (Set_Priority); -- Set the priority of the task specified by T to Prio. The priority set -- is what would correspond to the Ada concept of "base priority" in the -- terms of the lower layer system, but the operation may be used by the -- upper layer to implement changes in "active priority" that are not due -- to lock effects. The effect should be consistent with the Ada Reference -- Manual. In particular, when a task lowers its priority due to the loss -- of inherited priority, it goes at the head of the queue for its new -- priority (RM D.2.2 par 9). Loss_Of_Inheritance helps the underlying -- implementation to do it right when the OS doesn't. function Get_Priority (T : ST.Task_Id) return System.Any_Priority; pragma Inline (Get_Priority); -- Returns the priority last set by Set_Priority for this task function Monotonic_Clock return Duration; pragma Inline (Monotonic_Clock); -- Returns "absolute" time, represented as an offset relative to an -- unspecified Epoch. This clock implementation is immune to the -- system's clock changes. function RT_Resolution return Duration; pragma Inline (RT_Resolution); -- Returns resolution of the underlying clock used to implement RT_Clock ---------------- -- Extensions -- ---------------- -- Whoever calls either of the Sleep routines is responsible for checking -- for pending aborts before the call. Pending priority changes are handled -- internally. procedure Sleep (Self_ID : ST.Task_Id; Reason : System.Tasking.Task_States); pragma Inline (Sleep); -- Wait until the current task, T, is signaled to wake up -- -- precondition: -- The calling task is holding its own ATCB lock -- and has abort deferred -- -- postcondition: -- The calling task is holding its own ATCB lock and has abort deferred. -- The effect is to atomically unlock T's lock and wait, so that another -- task that is able to lock T's lock can be assured that the wait has -- actually commenced, and that a Wakeup operation will cause the waiting -- task to become ready for execution once again. When Sleep returns, the -- waiting task will again hold its own ATCB lock. The waiting task may -- become ready for execution at any time (that is, spurious wakeups are -- permitted), but it will definitely become ready for execution when a -- Wakeup operation is performed for the same task. 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. procedure Wakeup (T : ST.Task_Id; Reason : System.Tasking.Task_States); pragma Inline (Wakeup); -- Wake up task T if it is waiting on a Sleep call (of ordinary -- or timed variety), making it ready for execution once again. -- If the task T is not waiting on a Sleep, the operation has no effect. function Environment_Task return ST.Task_Id; pragma Inline (Environment_Task); -- Return the task ID of the environment task -- Consider putting this into a variable visible directly -- by the rest of the runtime system. ??? function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id; -- Return the thread id of the specified task function Is_Valid_Task return Boolean; pragma Inline (Is_Valid_Task); -- Does the calling thread have an ATCB? function Register_Foreign_Thread return ST.Task_Id; -- Allocate and initialize a new ATCB for the current thread ----------------------- -- RTS Entrance/Exit -- ----------------------- -- Following two routines are used for possible operations needed to be -- setup/cleared upon entrance/exit of RTS while maintaining a single -- thread of control in the RTS. -- -- These routines also replace the functions Lock/Unlock_All_Tasks_List procedure Lock_RTS; -- Take the global RTS lock procedure Unlock_RTS; -- Release the global RTS lock -------------------- -- Stack Checking -- -------------------- -- Stack checking in GNAT is done using the concept of stack probes. A -- stack probe is an operation that will generate a storage error if -- an insufficient amount of stack space remains in the current task. -- The exact mechanism for a stack probe is target dependent. Typical -- possibilities are to use a load from a non-existent page, a store to a -- read-only page, or a comparison with some stack limit constant. Where -- possible we prefer to use a trap on a bad page access, since this has -- less overhead. The generation of stack probes is either automatic if -- the ABI requires it (as on for example DEC Unix), or is controlled by -- the gcc parameter -fstack-check. -- When we are using bad-page accesses, we need a bad page, called guard -- page, at the end of each task stack. On some systems, this is provided -- automatically, but on other systems, we need to create the guard page -- ourselves, and the procedure Stack_Guard is provided for this purpose. procedure Stack_Guard (T : ST.Task_Id; On : Boolean); -- Ensure guard page is set if one is needed and the underlying thread -- system does not provide it. The procedure is as follows: -- -- 1. When we create a task adjust its size so a guard page can -- safely be set at the bottom of the stack. -- -- 2. When the thread is created (and its stack allocated by the -- underlying thread system), get the stack base (and size, depending -- how the stack is growing), and create the guard page taking care -- of page boundaries issues. -- -- 3. When the task is destroyed, remove the guard page. -- -- If On is true then protect the stack bottom (i.e make it read only) -- else unprotect it (i.e. On is True for the call when creating a task, -- and False when a task is destroyed). -- -- The call to Stack_Guard has no effect if guard pages are not used on -- the target, or if guard pages are automatically provided by the system. ------------------------ -- Suspension objects -- ------------------------ -- These subprograms provide the functionality required for synchronizing -- on a suspension object. Tasks can suspend execution and relinquish the -- processors until the condition is signaled. function Current_State (S : Suspension_Object) return Boolean; -- Return the state of the suspension object procedure Set_False (S : in out Suspension_Object); -- Set the state of the suspension object to False procedure Set_True (S : in out Suspension_Object); -- Set the state of the suspension object to True. If a task were -- suspended on the protected object then this task is released (and -- the state of the suspension object remains set to False). procedure Suspend_Until_True (S : in out Suspension_Object); -- If the state of the suspension object is True then the calling task -- continues its execution, and the state is set to False. If the state -- of the object is False then the task is suspended on the suspension -- object until a Set_True operation is executed. Program_Error is raised -- if another task is already waiting on that suspension object. procedure Initialize (S : in out Suspension_Object); -- Initialize the suspension object procedure Finalize (S : in out Suspension_Object); -- Finalize the suspension object ----------------------------------------- -- Runtime System Debugging Interfaces -- ----------------------------------------- -- These interfaces have been added to assist in debugging the -- tasking runtime system. function Check_Exit (Self_ID : ST.Task_Id) return Boolean; pragma Inline (Check_Exit); -- Check that the current task is holding only Global_Task_Lock function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean; pragma Inline (Check_No_Locks); -- Check that current task is holding no locks function Suspend_Task (T : ST.Task_Id; Thread_Self : OSI.Thread_Id) return Boolean; -- Suspend a specific task when the underlying thread library provides this -- functionality, unless the thread associated with T is Thread_Self. Such -- functionality is needed by gdb on some targets (e.g VxWorks) Return True -- is the operation is successful. On targets where this operation is not -- available, a dummy body is present which always returns False. function Resume_Task (T : ST.Task_Id; Thread_Self : OSI.Thread_Id) return Boolean; -- Resume a specific task when the underlying thread library provides -- such functionality, unless the thread associated with T is Thread_Self. -- Such functionality is needed by gdb on some targets (e.g VxWorks) -- Return True is the operation is successful procedure Stop_All_Tasks; -- Stop all tasks when the underlying thread library provides such -- functionality. Such functionality is needed by gdb on some targets (e.g -- VxWorks) This function can be run from an interrupt handler. Return True -- is the operation is successful function Stop_Task (T : ST.Task_Id) return Boolean; -- Stop a specific task when the underlying thread library provides -- such functionality. Such functionality is needed by gdb on some targets -- (e.g VxWorks). Return True is the operation is successful. function Continue_Task (T : ST.Task_Id) return Boolean; -- Continue a specific task when the underlying thread library provides -- such functionality. Such functionality is needed by gdb on some targets -- (e.g VxWorks) Return True is the operation is successful ------------------- -- Task affinity -- ------------------- procedure Set_Task_Affinity (T : ST.Task_Id); -- Enforce at the operating system level the task affinity defined in the -- Ada Task Control Block. Has no effect if the underlying operating system -- does not support this capability. end System.Task_Primitives.Operations;
stcarrez/ada-servlet
Ada
4,090
ads
----------------------------------------------------------------------- -- servlet-responses.web -- Servlet Responses with AWS server -- Copyright (C) 2009, 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with AWS.Response; with Util.Streams; with Util.Streams.Texts; package Servlet.Responses.Web is type Response is new Servlet.Responses.Response and Util.Streams.Output_Stream with private; -- Write the buffer array to the output stream. overriding procedure Write (Stream : in out Response; Buffer : in Ada.Streams.Stream_Element_Array); -- Flush the buffer (if any) to the sink. overriding procedure Flush (Stream : in out Response); -- Iterate over the response headers and executes the <b>Process</b> procedure. overriding procedure Iterate_Headers (Resp : in Response; Process : not null access procedure (Name : in String; Value : in String)); -- Returns a boolean indicating whether the named response header has already -- been set. overriding function Contains_Header (Resp : in Response; Name : in String) return Boolean; -- Sets a response header with the given name and value. If the header had already -- been set, the new value overwrites the previous one. The containsHeader -- method can be used to test for the presence of a header before setting its value. overriding procedure Set_Header (Resp : in out Response; Name : in String; Value : in String); -- Adds a response header with the given name and value. -- This method allows response headers to have multiple values. overriding procedure Add_Header (Resp : in out Response; Name : in String; Value : in String); -- Sends a temporary redirect response to the client using the specified redirect -- location URL. This method can accept relative URLs; the servlet container must -- convert the relative URL to an absolute URL before sending the response to the -- client. If the location is relative without a leading '/' the container -- interprets it as relative to the current request URI. If the location is relative -- with a leading '/' the container interprets it as relative to the servlet -- container root. -- -- If the response has already been committed, this method throws an -- IllegalStateException. After using this method, the response should be -- considered to be committed and should not be written to. overriding procedure Send_Redirect (Resp : in out Response; Location : in String); -- Prepare the response data by collecting the status, content type and message body. procedure Build (Resp : in out Response); -- Get the response data function Get_Data (Resp : in Response) return AWS.Response.Data; private overriding procedure Initialize (Resp : in out Response); type Response is new Servlet.Responses.Response and Util.Streams.Output_Stream with record Data : AWS.Response.Data; Content : aliased Util.Streams.Texts.Print_Stream; Redirect : Boolean := False; end record; end Servlet.Responses.Web;
vpodzime/ada-util
Ada
4,381
ads
----------------------------------------------------------------------- -- Util.Beans.Objects.Maps -- Object maps -- Copyright (C) 2010, 2011, 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 Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash; with Util.Beans.Basic; package Util.Beans.Objects.Maps is package Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Object, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); subtype Cursor is Maps.Cursor; subtype Map is Maps.Map; -- Make all the Maps operations available (a kind of 'use Maps' for anybody). function Length (Container : in Map) return Ada.Containers.Count_Type renames Maps.Length; function Is_Empty (Container : in Map) return Boolean renames Maps.Is_Empty; procedure Clear (Container : in out Map) renames Maps.Clear; function Key (Position : Cursor) return String renames Maps.Key; procedure Include (Container : in out Map; Key : in String; New_Item : in Object) renames Maps.Include; procedure Query_Element (Position : in Cursor; Process : not null access procedure (Key : String; Element : Object)) renames Maps.Query_Element; function Has_Element (Position : Cursor) return Boolean renames Maps.Has_Element; function Element (Position : Cursor) return Object renames Maps.Element; procedure Next (Position : in out Cursor) renames Maps.Next; function Next (Position : Cursor) return Cursor renames Maps.Next; function Equivalent_Keys (Left, Right : Cursor) return Boolean renames Maps.Equivalent_Keys; function Equivalent_Keys (Left : Cursor; Right : String) return Boolean renames Maps.Equivalent_Keys; function Equivalent_Keys (Left : String; Right : Cursor) return Boolean renames Maps.Equivalent_Keys; function Copy (Source : Maps.Map; Capacity : in Ada.Containers.Count_Type) return Maps.Map renames Maps.Copy; -- ------------------------------ -- Map Bean -- ------------------------------ -- The <b>Map_Bean</b> is a map of objects that also exposes the <b>Bean</b> interface. -- This allows the map to be available and accessed from an Object instance. type Map_Bean is new Maps.Map and Util.Beans.Basic.Bean with private; type Map_Bean_Access is access all Map_Bean'Class; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. function Get_Value (From : in Map_Bean; Name : in String) return Object; -- Set the value identified by the name. -- If the map contains the given name, the value changed. -- Otherwise name is added to the map and the value associated with it. procedure Set_Value (From : in out Map_Bean; Name : in String; Value : in Object); -- Create an object that contains a <tt>Map_Bean</tt> instance. function Create return Object; -- Iterate over the members of the map. procedure Iterate (From : in Object; Process : not null access procedure (Name : in String; Item : in Object)); private type Map_Bean is new Maps.Map and Util.Beans.Basic.Bean with null record; end Util.Beans.Objects.Maps;
reznikmm/matreshka
Ada
7,021
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_Chart.Stock_Gain_Marker_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Chart_Stock_Gain_Marker_Element_Node is begin return Self : Chart_Stock_Gain_Marker_Element_Node do Matreshka.ODF_Chart.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Chart_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Chart_Stock_Gain_Marker_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Chart_Stock_Gain_Marker (ODF.DOM.Chart_Stock_Gain_Marker_Elements.ODF_Chart_Stock_Gain_Marker_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Chart_Stock_Gain_Marker_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Stock_Gain_Marker_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Chart_Stock_Gain_Marker_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Chart_Stock_Gain_Marker (ODF.DOM.Chart_Stock_Gain_Marker_Elements.ODF_Chart_Stock_Gain_Marker_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Chart_Stock_Gain_Marker_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Chart_Stock_Gain_Marker (Visitor, ODF.DOM.Chart_Stock_Gain_Marker_Elements.ODF_Chart_Stock_Gain_Marker_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Chart_URI, Matreshka.ODF_String_Constants.Stock_Gain_Marker_Element, Chart_Stock_Gain_Marker_Element_Node'Tag); end Matreshka.ODF_Chart.Stock_Gain_Marker_Elements;
reznikmm/matreshka
Ada
5,183
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with AWF.Utilities; package body AWF.Push_Buttons is ----------------- -- Click_Event -- ----------------- overriding procedure Click_Event (Self : not null access AWF_Push_Button) is begin Self.Clicked.Emit; end Click_Event; ------------- -- Clicked -- ------------- not overriding function Clicked (Self : not null access AWF_Push_Button) return League.Signals.Signal is begin return Self.Clicked.Signal; end Clicked; ------------ -- Create -- ------------ function Create (Parent : access AWF.Widgets.AWF_Widget'Class := null) return not null AWF_Push_Button_Access is Result : AWF_Push_Button_Access := new AWF_Push_Button; begin AWF.Internals.AWF_Widgets.Constructors.Initialize (Result, Parent); return Result; end Create; ----------------- -- Render_Body -- ----------------- overriding procedure Render_Body (Self : not null access AWF_Push_Button; Context : in out AWF.HTML_Writers.HTML_Writer'Class) is begin Context.Start_Div (Id => AWF.Utilities.Image (Self.Id), On_Click => League.Strings.To_Universal_String ("AWFWidgetOnEvent(this,""onclick"")")); Context.Characters (Self.Text); Context.End_Div; end Render_Body; -------------- -- Set_Text -- -------------- not overriding procedure Set_Text (Self : not null access AWF_Push_Button; Text : League.Strings.Universal_String) is use type League.Strings.Universal_String; begin Self.Text := Text; Self.Append_Payload ("document.getElementById('" & AWF.Utilities.Image (Self.Id) & "').innerHTML = '" & Self.Text & "';"); end Set_Text; end AWF.Push_Buttons;
reznikmm/matreshka
Ada
5,130
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Executable_Nodes.Collections is pragma Preelaborate; package UML_Executable_Node_Collections is new AMF.Generic_Collections (UML_Executable_Node, UML_Executable_Node_Access); type Set_Of_UML_Executable_Node is new UML_Executable_Node_Collections.Set with null record; Empty_Set_Of_UML_Executable_Node : constant Set_Of_UML_Executable_Node; type Ordered_Set_Of_UML_Executable_Node is new UML_Executable_Node_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Executable_Node : constant Ordered_Set_Of_UML_Executable_Node; type Bag_Of_UML_Executable_Node is new UML_Executable_Node_Collections.Bag with null record; Empty_Bag_Of_UML_Executable_Node : constant Bag_Of_UML_Executable_Node; type Sequence_Of_UML_Executable_Node is new UML_Executable_Node_Collections.Sequence with null record; Empty_Sequence_Of_UML_Executable_Node : constant Sequence_Of_UML_Executable_Node; private Empty_Set_Of_UML_Executable_Node : constant Set_Of_UML_Executable_Node := (UML_Executable_Node_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Executable_Node : constant Ordered_Set_Of_UML_Executable_Node := (UML_Executable_Node_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Executable_Node : constant Bag_Of_UML_Executable_Node := (UML_Executable_Node_Collections.Bag with null record); Empty_Sequence_Of_UML_Executable_Node : constant Sequence_Of_UML_Executable_Node := (UML_Executable_Node_Collections.Sequence with null record); end AMF.UML.Executable_Nodes.Collections;
clairvoyant/anagram
Ada
8,148
adb
-- Copyright (c) 2010-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Wide_Wide_Text_IO; with Anagram.Grammars.LR; package body Anagram.Grammars_Debug is ----------- -- Print -- ----------- procedure Print (Self : Anagram.Grammars.Grammar) is use Ada.Wide_Wide_Text_IO; use Anagram.Grammars; procedure Print_Attr (Attr : Attribute_Index); procedure Print_Productions (First, Last : Production_Count); procedure Print_Declarations (First, Last : Attribute_Declaration_Count); function Is_List (X : Boolean) return Wide_Wide_String; procedure Print_Attr (Attr : Attribute_Index) is begin if Self.Attribute (Attr).Is_Left_Hand_Side then Put ("LHS."); else Put (Self.Part (Self.Attribute (Attr).Origin).Name. To_Wide_Wide_String & "."); end if; Put_Line (Self.Declaration (Self.Attribute (Attr).Declaration).Name. To_Wide_Wide_String); end Print_Attr; procedure Print_Declarations (First, Last : Attribute_Declaration_Count) is begin for D in First .. Last loop Put_Line (" Attr: " & Self.Declaration (D).Name.To_Wide_Wide_String & " inherited=" & Boolean'Wide_Wide_Image (Self.Declaration (D).Is_Inherited)); end loop; end Print_Declarations; procedure Print_Productions (First, Last : Production_Count) is begin for P in First .. Last loop Put_Line (" Production: " & Self.Production (P).Name.To_Wide_Wide_String & " (" & Production_Index'Wide_Wide_Image (P) & ")"); for R in Part_Count'(Self.Production (P).First) .. Self.Production (P).Last loop Put (" " & Self.Part (R).Name.To_Wide_Wide_String); if Self.Part (R).Is_Terminal_Reference then Put_Line (" refs " & Self.Terminal (Self.Part (R).Denote) .Image.To_Wide_Wide_String); elsif Self.Part (R).Is_Non_Terminal_Reference then Put_Line (" refs " & Self.Non_Terminal (Self.Part (R).Denote) .Name.To_Wide_Wide_String); else if Self.Part (R).Is_List_Reference then Put_Line (" List:" & Self.Non_Terminal (Self.Part (R).Denote) .Name.To_Wide_Wide_String); else Put_Line (" Option:"); Print_Productions (Self.Part (R).First, Self.Part (R).Last); Put_Line (" End"); end if; end if; end loop; for R in Self.Production (P).First_Rule .. Self.Production (P).Last_Rule loop Put_Line ("Rule: "); Put (" Result: "); Print_Attr (Self.Rule (R).Result); for A in Self.Rule (R).First_Argument .. Self.Rule (R).Last_Argument loop Put (" Arg: "); Print_Attr (A); end loop; end loop; end loop; end Print_Productions; function Is_List (X : Boolean) return Wide_Wide_String is begin if X then return " (List)"; else return ""; end if; end Is_List; begin Put_Line ("Terminals:"); for J in 1 .. Self.Last_Terminal loop Put_Line (Terminal_Count'Wide_Wide_Image (J) & " " & Self.Terminal (J).Image.To_Wide_Wide_String); Print_Declarations (Self.Terminal (J).First_Attribute, Self.Terminal (J).Last_Attribute); end loop; Put_Line ("Non Terminals:"); for J in 1 .. Self.Last_Non_Terminal loop Put_Line (Non_Terminal_Count'Wide_Wide_Image (J) & " " & Self.Non_Terminal (J).Name.To_Wide_Wide_String & Is_List (Self.Non_Terminal (J).Is_List)); Print_Declarations (Self.Non_Terminal (J).First_Attribute, Self.Non_Terminal (J).Last_Attribute); Print_Productions (Self.Non_Terminal (J).First, Self.Non_Terminal (J).Last); end loop; end Print; --------------------- -- Print_Conflicts -- --------------------- procedure Print_Conflicts (Self : Anagram.Grammars.Grammar; Table : Anagram.Grammars.LR_Tables.Table) is use Ada.Wide_Wide_Text_IO; use Anagram.Grammars.LR_Tables; use type Anagram.Grammars.LR.State_Count; procedure Print_State (State : Anagram.Grammars.LR.State_Index); procedure Print_Reduce (Prefix : Wide_Wide_String; R : in out Reduce_Iterator); procedure Print_Conflict (Prefix : Wide_Wide_String; T : Anagram.Grammars.Terminal_Count); ------------------ -- Print_Reduce -- ------------------ procedure Print_Reduce (Prefix : Wide_Wide_String; R : in out Reduce_Iterator) is P : Anagram.Grammars.Production_Index; NT : Anagram.Grammars.Non_Terminal_Index; begin while not Is_Empty (R) loop P := Production (R); NT := Self.Production (P).Parent; Put_Line (Prefix & "Non terminal " & Self.Non_Terminal (NT).Name.To_Wide_Wide_String & " production " & Self.Production (P).Name.To_Wide_Wide_String); Next (Table, R); end loop; end Print_Reduce; ----------------- -- Print_State -- ----------------- procedure Print_State (State : Anagram.Grammars.LR.State_Index) is begin Put_Line ("State:" & Anagram.Grammars.LR.State_Index'Wide_Wide_Image (State)); end Print_State; procedure Print_Conflict (Prefix : Wide_Wide_String; T : Anagram.Grammars.Terminal_Count) is use type Anagram.Grammars.Terminal_Count; begin if T = 0 then Put_Line (Prefix & " conflict on token End_Of_File"); else Put_Line (Prefix & " conflict on token '" & Self.Terminal (T).Image.To_Wide_Wide_String & "'"); end if; end Print_Conflict; State_Printed : Boolean; S : Anagram.Grammars.LR.State_Count; R : Reduce_Iterator; begin for State in 1 .. Last_State (Table) loop State_Printed := False; for T in 0 .. Self.Last_Terminal loop S := Shift (Table, State, T); R := Reduce (Table, State, T); if S /= 0 then if not Is_Empty (R) then if not State_Printed then State_Printed := True; Print_State (State); end if; Print_Conflict ("Shift/Reduce", T); Put ("Shift to "); Print_State (S); Print_Reduce ("Shift/Reduce ", R); end if; elsif not Is_Empty (R) then declare Save : Reduce_Iterator := R; begin Next (Table, R); if not Is_Empty (R) then if not State_Printed then State_Printed := True; Print_State (State); end if; Print_Conflict ("Reduce/Reduce", T); Print_Reduce ("Reduce/Reduce ", Save); end if; end; end if; end loop; end loop; end Print_Conflicts; end Anagram.Grammars_Debug;
reznikmm/matreshka
Ada
3,604
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.CMOF.Properties.Hash is new AMF.Elements.Generic_Hash (CMOF_Property, CMOF_Property_Access);
LionelDraghi/List_Image
Ada
16,666
adb
-- ----------------------------------------------------------------------------- -- Copyright 2018 Lionel Draghi -- -- 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. -- ----------------------------------------------------------------------------- -- This file is part of the List_Image project -- available at https://github.com/LionelDraghi/List_Image -- ----------------------------------------------------------------------------- with List_Image; with List_Image.Windows_Predefined_Styles; with List_Image.Unix_Predefined_Styles; with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers.Indefinite_Doubly_Linked_Lists; with Ada.Containers.Indefinite_Hashed_Sets; with Ada.Command_Line; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Hash_Case_Insensitive; with Ada.Text_IO; use Ada.Text_IO; procedure Test_List_Image is Failure_Count : Natural := 0; Check_Idx : Positive := 1; Prefix : Character := Character'Pred ('A'); Rule : constant String := 80 * '-'; -- -------------------------------------------------------------------------- procedure New_Test (Title : String) is -- Print a test separator of the form : -- A. $Title test --------- -- and increment A at each call begin Prefix := Character'Succ (Prefix); Check_Idx := 1; New_Line; Put_Line (Overwrite (Source => Rule, Position => Rule'First, New_Item => Prefix & ". " & Title & " test ")); end New_Test; -- -------------------------------------------------------------------------- procedure Check (Title : String; Image : String; Expected : String) is -- Print a test sequence of the form : -- A.1. $Title -- Expected "$Expected" -- then, -- OK -- if Image = Expected, or -- ** Failed ** -- if not. -- Tmp : constant String := Positive'Image (Check_Idx); Idx : constant String := Tmp (2 .. Tmp'Last); begin New_Line; Put_Line (Prefix & '.' & Idx & ". " & Title); Put_Line ("Expected :"); Put_Line ("""" & Expected & """"); if Image = Expected then Put_Line ("OK"); else Put_Line ("**Failed**, got """ & Image & """"); Failure_Count := Failure_Count + 1; end if; Check_Idx := Check_Idx + 1; end Check; -- container 1 package Integer_Lists is new Ada.Containers.Doubly_Linked_Lists (Integer); -- container 2 package Id_Sets is new Ada.Containers.Indefinite_Hashed_Sets (String, Ada.Strings.Hash_Case_Insensitive, "="); -- container 3 package Tests_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String); begin -- -------------------------------------------------------------------------- New_Test ("Bracketed_List_Style instanciation test on a List"); declare Int_List : Integer_Lists.List; use Integer_Lists; package Integer_Lists_Cursors is new List_Image.Cursors_Signature (Container => List, Cursor => Cursor); function Image (C : Cursor) return String is (Integer'Image (Element (C))); function Integer_List_Image is new List_Image.Image (Cursors => Integer_Lists_Cursors, Style => List_Image.Bracketed_List_Style); begin Int_List.Clear; Check (Title => "Empty list", Image => Integer_List_Image (Int_List), Expected => "[]"); Int_List.Append (1); Check (Title => "One item", Image => Integer_List_Image (Int_List), Expected => "[ 1]"); Int_List.Append (2); Check (Title => "Two items", Image => Integer_List_Image (Int_List), Expected => "[ 1, 2]"); Int_List.Append (3); Check (Title => "More items", Image => Integer_List_Image (Int_List), Expected => "[ 1, 2, 3]"); end; -- -------------------------------------------------------------------------- New_Test ("Bracketed_List_Style instantiation test on a Set"); declare Id_Set : Id_Sets.Set; use Id_Sets; package Id_Sets_Cursors is new List_Image.Cursors_Signature (Container => Id_Sets.Set, Cursor => Id_Sets.Cursor); function Image (C : Cursor) return String is (Element (C)); function Id_Set_Image is new List_Image.Image (Cursors => Id_Sets_Cursors, Style => List_Image.Bracketed_List_Style); begin Id_Set.Clear; Check (Title => "Empty list", Image => Id_Set_Image (Id_Set), Expected => "[]"); Id_Set.Insert ("Hyperion"); Check (Title => "One item", Image => Id_Set_Image (Id_Set), Expected => "[Hyperion]"); Id_Set.Insert ("Endymion"); Check (Title => "Two items", Image => Id_Set_Image (Id_Set), Expected => "[Hyperion, Endymion]"); Id_Set.Insert ("TechnoCore"); Check (Title => "More items", Image => Id_Set_Image (Id_Set), Expected => "[TechnoCore, Hyperion, Endymion]"); end; -- -------------------------------------------------------------------------- New_Test ("Minimal default style instantiation test on a List"); declare Int_List : Integer_Lists.List; use Integer_Lists; package Integer_Lists_Cursors is new List_Image.Cursors_Signature (Container => Integer_Lists.List, Cursor => Integer_Lists.Cursor); function Image (C : Cursor) return String is (Integer'Image (Element (C))); function Integer_List_Image_2 is new List_Image.Image (Cursors => Integer_Lists_Cursors, Image => Image, Style => List_Image.Default_Style); begin Int_List.Clear; Check (Title => "Empty list", Image => Integer_List_Image_2 (Int_List), Expected => ""); Int_List.Append (1); Check (Title => "One item", Image => Integer_List_Image_2 (Int_List), Expected => " 1"); Int_List.Append (2); Check (Title => "Two items", Image => Integer_List_Image_2 (Int_List), Expected => " 1, 2"); Int_List.Append (3); Check (Title => "More items", Image => Integer_List_Image_2 (Int_List), Expected => " 1, 2, 3"); end; -- -------------------------------------------------------------------------- New_Test ("Sentences"); declare package Failed_Image_Style is new List_Image.Image_Style (Prefix => "Tests ", Separator => ", ", Last_Separator => " and ", Postfix => " fail", Prefix_If_Empty => "No test failed", Postfix_If_Empty => "", Prefix_If_Single => "Test ", Postfix_If_Single => " fails"); Tests_List : Tests_Lists.List; use Tests_Lists; package Tests_Lists_Cursors is new List_Image.Cursors_Signature (Container => Tests_Lists.List, Cursor => Tests_Lists.Cursor); function Image (C : Cursor) return String is (Element (C)); function Test_List_Image_1 is new List_Image.Image (Cursors => Tests_Lists_Cursors, Style => Failed_Image_Style); begin Tests_List.Clear; Check (Title => "Empty list", Image => Test_List_Image_1 (Tests_List), Expected => "No test failed"); Tests_List.Append ("test_1"); Check (Title => "One item", Image => Test_List_Image_1 (Tests_List), Expected => "Test test_1 fails"); Tests_List.Append ("test_2"); Check (Title => "Two items", Image => Test_List_Image_1 (Tests_List), Expected => "Tests test_1 and test_2 fail"); Tests_List.Append ("test_3"); Check (Title => "More items", Image => Test_List_Image_1 (Tests_List), Expected => "Tests test_1, test_2 and test_3 fail"); end; -- -------------------------------------------------------------------------- New_Test ("Simple bulleted list"); declare Tests_List : Tests_Lists.List; use Tests_Lists; package Tests_Lists_Cursors is new List_Image.Cursors_Signature (Container => Tests_Lists.List, Cursor => Tests_Lists.Cursor); function Image (C : Cursor) return String is (Element (C)); function Test_List_Image_1 is new List_Image.Image (Cursors => Tests_Lists_Cursors, Style => List_Image.Unix_Predefined_Styles.Bulleted_List_Style); EOL : constant String := (1 => ASCII.LF); begin Tests_List.Clear; Check (Title => "Empty list", Image => Test_List_Image_1 (Tests_List), Expected => ""); Tests_List.Append ("test_1"); Check (Title => "One item", Image => Test_List_Image_1 (Tests_List), Expected => EOL & "- test_1" & EOL); Tests_List.Append ("test_2"); Check (Title => "Two items", Image => Test_List_Image_1 (Tests_List), Expected => EOL & "- test_1" & EOL & "- test_2" & EOL); Tests_List.Append ("test_3"); Check (Title => "More items", Image => Test_List_Image_1 (Tests_List), Expected => EOL & "- test_1" & EOL & "- test_2" & EOL & "- test_3" & EOL); end; -- -------------------------------------------------------------------------- New_Test ("Markdown bulleted list"); declare Tests_List : Tests_Lists.List; use Tests_Lists; package Tests_Lists_Cursors is new List_Image.Cursors_Signature (Container => Tests_Lists.List, Cursor => Tests_Lists.Cursor); function Image (C : Cursor) return String is (Element (C)); use List_Image; package Unix_Markdown_Bulleted_List_Style is new Image_Style (Prefix => Unix_EOL & Unix_EOL & "- ", Separator => Unix_EOL & "- ", Postfix => Unix_EOL & Unix_EOL, Prefix_If_Empty => Unix_EOL, Postfix_If_Empty => ""); function Test_List_Image_1 is new List_Image.Image (Cursors => Tests_Lists_Cursors, Style => Unix_Markdown_Bulleted_List_Style); EOL : constant String := LF_EOL; begin Tests_List.Clear; Check (Title => "Empty list", Image => Test_List_Image_1 (Tests_List), Expected => EOL); Tests_List.Append ("test_1"); Check (Title => "One item", Image => Test_List_Image_1 (Tests_List), Expected => EOL & EOL & "- test_1" & EOL & EOL); Tests_List.Append ("test_2"); Check (Title => "Two items", Image => Test_List_Image_1 (Tests_List), Expected => EOL & EOL & "- test_1" & EOL & "- test_2" & EOL & EOL); Tests_List.Append ("test_3"); Check (Title => "More items", Image => Test_List_Image_1 (Tests_List), Expected => EOL & EOL & "- test_1" & EOL & "- test_2" & EOL & "- test_3" & EOL & EOL); end; -- -------------------------------------------------------------------------- New_Test ("Markdown table lines"); declare L1, L2, L3, L4, L5 : Tests_Lists.List; package Markdown_Table_Style is new List_Image.Image_Style (Prefix => "|", Separator => "|", Postfix => "|", Prefix_If_Empty => "", Postfix_If_Empty => ""); -- Should be named Github Flavored Markdown, as Markdown -- don't define tables. use Tests_Lists; package Tests_Lists_Cursors is new List_Image.Cursors_Signature (Container => Tests_Lists.List, Cursor => Tests_Lists.Cursor); function Image (C : Cursor) return String is (Element (C)); function List_Image is new List_Image.Image (Cursors => Tests_Lists_Cursors, Style => Markdown_Table_Style); begin Put_Line ("Example From http://www.tablesgenerator.com/markdown_tables"); L1.Append ("Tables"); L1.Append ("Are"); L1.Append ("Cool"); L2.Append ("----------"); L2.Append (":-------------:"); L2.Append ("------:"); L3.Append ("col 1 is"); L3.Append ("left-aligned"); L3.Append ("$1600"); L4.Append ("col 2 is"); L4.Append ("centered"); L4.Append ("$12"); L5.Append ("col 3 is"); L5.Append ("right - aligned"); L5.Append ("$1"); Check (Title => "Line 1", Image => List_Image (L1), Expected => "|Tables|Are|Cool|"); Check (Title => "Line 2", Image => List_Image (L2), Expected => "|----------|:-------------:|------:|"); Check (Title => "Line 3", Image => List_Image (L3), Expected => "|col 1 is|left-aligned|$1600|"); Check (Title => "Line 4", Image => List_Image (L4), Expected => "|col 2 is|centered|$12|"); Check (Title => "Line 5", Image => List_Image (L5), Expected => "|col 3 is|right - aligned|$1|"); end; -- -------------------------------------------------------------------------- New_Test ("html bulleted list"); declare L : Tests_Lists.List; use Tests_Lists; package Tests_Lists_Cursors is new List_Image.Cursors_Signature (Container => List, Cursor => Cursor); function Image (C : Cursor) return String is (Element (C)); EOL : constant String := List_Image.Windows_EOL; function List_Image is new List_Image.Image (Cursors => Tests_Lists_Cursors, Style => List_Image.Windows_Predefined_Styles.HTML_Bulleted_List_Style); begin Check (Title => "Empty list", Image => List_Image (L), Expected => ""); L.Append ("salt"); declare Expected : constant String := "<ul>" & EOL & " <li>salt</li>" & EOL & "</ul>"; begin Check (Title => "One item", Image => List_Image (L), Expected => Expected); end; L.Append ("pepper"); declare Expected : constant String := "<ul>" & EOL & " <li>salt</li>" & EOL & " <li>pepper</li>" & EOL & "</ul>"; begin Check (Title => "Two items", Image => List_Image (L), Expected => Expected); end; L.Append ("sugar"); declare Expected : constant String := "<ul>" & EOL & " <li>salt</li>" & EOL & " <li>pepper</li>" & EOL & " <li>sugar</li>" & EOL & "</ul>"; begin Check (Title => "More items", Image => List_Image (L), Expected => Expected); end; end; -- -------------------------------------------------------------------------- New_Line; if Failure_Count /= 0 then Put_Line (Natural'Image (Failure_Count) & " tests fails."); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); else Put_Line (Rule); Put_Line ("All tests OK."); end if; end Test_List_Image;
zhmu/ananas
Ada
4,486
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . 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.Text_IO.Generic_Aux; use Ada.Text_IO.Generic_Aux; package body Ada.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.Text_IO.Integer_Aux;
onox/orka
Ada
1,595
ads
-- 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 Orka.Cameras.Look_From_Cameras is pragma Preelaborate; type Look_From_Camera is new First_Person_Camera with private; procedure Set_Orientation (Object : in out Look_From_Camera; Roll, Pitch, Yaw : Angle); procedure Change_Orientation (Object : in out Look_From_Camera; Value : Vector4); overriding function View_Matrix (Object : Look_From_Camera) return Transforms.Matrix4; overriding function View_Matrix_Inverse (Object : Look_From_Camera) return Transforms.Matrix4; overriding procedure Update (Object : in out Look_From_Camera; Delta_Time : Duration); overriding function Create_Camera (Lens : Camera_Lens) return Look_From_Camera; private type Look_From_Camera is new First_Person_Camera with record Roll, Pitch, Yaw : Angle := 0.0; Updater : Change_Updater_Ptr := new Change_Updater; end record; end Orka.Cameras.Look_From_Cameras;
charlie5/aIDE
Ada
1,436
ads
with adam.a_Type, gtk.Widget; with Gtk.Button; with Gtk.Window; with Gtk.Notebook; with Gtk.Table; package aIDE.Palette.of_types is type Item is new Palette.item with private; type View is access all Item'Class; -- Forge -- function to_types_Palette --(the_Attribute : in adam.Attribute.view; --the_Class : in adam.Class.view) return View; -- Attributes -- function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; -- Operations -- procedure show (Self : in out Item; Invoked_by : in gtk.Button.gtk_Button; Target : access adam.a_Type.view); procedure choice_is (Self : in out Item; Now : in String; package_Name : in String); procedure freshen (Self : in out Item); private use gtk.Window, gtk.Button, gtk.Notebook, Gtk.Table; type Item is new Palette.item with record Invoked_by : gtk_Button; Target : access adam.a_Type.view; recent_Table : gtk_Table; top_Notebook, all_Notebook : gtk_Notebook; Top : gtk_Window; close_Button : gtk_Button; end record; procedure build_recent_List (Self : in out Item); end aIDE.Palette.of_types;
AdaCore/gpr
Ada
50
ads
package Pack1 is procedure Dummy; end Pack1;
reznikmm/matreshka
Ada
3,781
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Style.Vertical_Align is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Vertical_Align_Node) return League.Strings.Universal_String is begin return ODF.Constants.Vertical_Align_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Vertical_Align;
stcarrez/ada-awa
Ada
6,913
adb
----------------------------------------------------------------------- -- awa-index_arrays -- Static index arrays -- Copyright (C) 2015, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log.Loggers; with Ada.Unchecked_Deallocation; package body AWA.Index_Arrays is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Index_Arrays"); type Name_Pair is record Name : Element_Type_Access := null; Index : Index_Type := Index_Type'First; end record; type Name_Pair_Array is array (Index_Type range <>) of Name_Pair; type Name_Pair_Array_Access is access all Name_Pair_Array; type Name_Array is array (Index_Type range <>) of Element_Type_Access; type Name_Array_Access is access all Name_Array; -- Register a definition by its name and allocate a unique runtime index. procedure Add_Index (Name : in Element_Type_Access; Index : out Index_Type); -- A static list of names. This array is created during the elaboration -- of definitions. It is sorted on names. Indexes : Name_Pair_Array_Access; -- A static list of names indexed by the index. Names : Name_Array_Access; -- The index of the last definition. Last_Index : Index_Type := Index_Type'First; -- ------------------------------ -- Register a definition by its name and allocate a unique runtime index. -- ------------------------------ procedure Add_Index (Name : in Element_Type_Access; Index : out Index_Type) is procedure Free is new Ada.Unchecked_Deallocation (Object => Name_Pair_Array, Name => Name_Pair_Array_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Name_Array, Name => Name_Array_Access); Left : Index_Type := Index_Type'First + 1; Right : Index_Type := Last_Index; begin -- Check the storage and allocate it if necessary. if Indexes = null then Indexes := new Name_Pair_Array (Index_Type'First + 1 .. Index_Type'First + 10); Names := new Name_Array (Index_Type'First + 1 .. Index_Type'First + 10); elsif Indexes'Last = Last_Index then declare E : constant Name_Pair_Array_Access := new Name_Pair_Array (1 .. Last_Index + 10); N : constant Name_Array_Access := new Name_Array (1 .. Last_Index + 10); begin E (Indexes'Range) := Indexes.all; N (Names'Range) := Names.all; Free (Indexes); Free (Names); Names := N; Indexes := E; end; end if; -- Find the definition position within the sorted table. -- If a definition is already registered, bark and re-use the previous index. while Left <= Right loop declare Pos : constant Index_Type := (Left + Right + 1) / 2; Item : constant Element_Type_Access := Indexes (Pos).Name; begin if Name.all = Item.all then Log.Error ("Definition " & Name.all & " is already registered."); Index := Indexes (Pos).Index; return; elsif Name.all < Item.all then Right := Pos - 1; else Left := Pos + 1; end if; end; end loop; -- Insert the new definition at the good position now. if Left = 0 then Left := Left + 1; end if; if Left <= Last_Index then Indexes (Left + 1 .. Last_Index + 1) := Indexes (Left .. Last_Index); end if; Last_Index := Last_Index + 1; Indexes (Left).Name := Name; Indexes (Left).Index := Last_Index; Names (Last_Index) := Name; Index := Last_Index; Log.Debug ("Definition " & Name.all & " index is {0}", Index_Type'Image (Index)); end Add_Index; -- ------------------------------ -- Declare a new definition -- ------------------------------ package body Definition is Index : Index_Type; Index_Name : aliased constant Element_Type := Name; function Kind return Index_Type is begin return Index; end Kind; begin Add_Index (Index_Name'Access, Index); end Definition; -- ------------------------------ -- Find the runtime index given the name. -- Raises Not_Found exception if the name is not recognized. -- ------------------------------ function Find (Name : in Element_Type) return Index_Type is Left : Index_Type := 1; Right : Index_Type := Last_Index; begin while Left <= Right loop declare Pos : constant Index_Type := (Left + Right + 1) / 2; Item : constant Element_Type_Access := Indexes (Pos).Name; begin if Name = Item.all then return Indexes (Pos).Index; elsif Name < Item.all then Right := Pos - 1; else Left := Pos + 1; end if; end; end loop; Log.Error ("Definition " & Name & " not recognized."); raise Not_Found with "Definition " & Name & " not found"; end Find; -- ------------------------------ -- Get the element associated with the index. -- ------------------------------ function Get_Element (Index : in Index_Type) return Element_Type_Access is begin if Index = Invalid_Index or else Index > Last_Index then Log.Error ("Index {0} is out of bounds", Index_Type'Image (Index)); raise Not_Found; end if; return Names (Index); end Get_Element; -- ------------------------------ -- Check if the index is a valid index. -- ------------------------------ function Is_Valid (Index : in Index_Type) return Boolean is begin return Index > Invalid_Index and then Index <= Last_Index; end Is_Valid; -- ------------------------------ -- Get the last valid index. -- ------------------------------ function Get_Last return Index_Type is begin return Last_Index; end Get_Last; end AWA.Index_Arrays;
strenkml/EE368
Ada
89
ads
with Memory.Super; package Memory.Super_Time is new Memory.Super(Time_Type, Get_Time);
PThierry/ewok-kernel
Ada
26
ads
../stm32f439/soc-flash.ads
darkestkhan/cbap
Ada
6,936
ads
------------------------------------------------------------------------------ -- EMAIL: <[email protected]> -- -- License: ISC License (see COPYING file) -- -- -- -- Copyright © 2015 darkestkhan -- ------------------------------------------------------------------------------ -- 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 Ada.Containers.Indefinite_Vectors; ------------------------------------------------------------------------------ -- Small and simple callback based library for processing program arguments -- ------------------------------------------------------------------------------ --------------------------------------------------------------------------- -- U S A G E -- --------------------------------------------------------------------------- -- First register all callbacks you are interested in, then call -- Process_Arguments. -- -- NOTE: "=" sign can't be part of argument name for registered callback. -- -- Only one callback can be registered per argument, otherwise -- Constraint_Error is propagated. --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- Leading single hyphen and double hyphen are stripped (if present) when -- processing arguments that are placed before first "--" argument, -- so e.g. "--help", "-help" and "help" are functionally -- equivalent, treated as if "help" was actually passed in all 3 cases. -- (you should register callback just for "help", if you register it for -- "--help" then actually passed argument would have to be "----help" in order -- for it to trigger said callback) -- -- In addition if you registered callback as case insensitive, then -- (using above example) "Help", "HELP", "help" and "HeLp" all would result in -- call to said callback. -- -- If Argument_Type is Variable then callback will receive part of argument -- that is after "=" sign. (ie. "OS=Linux" argument would result in callback -- receiving only "Linux" as its argument), otherwise actual argument will be -- passed. -- -- For Variable, case insensitive callbacks simple rule applies: -- only variable name is case insensitive, with actual value (when passed to -- program) being unchanged. -- -- If argument for which callback is registered is passed few times -- (ie. ./program help help help) then callback is triggered however many -- times said argument is detected. -- -- NOTE that Check for case insensitive callback is being performed first, -- thus if you happen to register callback for "help" (case insensitive) and -- "HeLp" (case sensitive) then only the case insensitive one will be called -- (i.e. "help"). -- -- All arguments with no associated callback are added to Unknown_Arguments -- vector as long as they appear before first "--" argument. -- -- All arguments after first "--" (standalone double hyphen) are added to -- Input_Argument vector (this includes another "--"), w/o any kind of -- hyphen stripping being performed on them. -- -- NOTE: No care is taken to ensure that all Input_Arguments -- (or Unknown_Arguments) are unique. --------------------------------------------------------------------------- package CBAP is --------------------------------------------------------------------------- -- Yes, I do realize this is actually vector... package Argument_Lists is new Ada.Containers.Indefinite_Vectors (Positive, String); -- List of all arguments (before first "--" argument) for which callbacks -- where not registered. Unknown_Arguments : Argument_Lists.Vector := Argument_Lists.Empty_Vector; -- List of all arguments after first "--" argument. Input_Arguments : Argument_Lists.Vector := Argument_Lists.Empty_Vector; -- Argument_Types decides if argument is just a simple value, or a variable -- with value assigned to it (difference between "--val" and "--var=val") type Argument_Types is (Value, Variable); -- Argument is useful mostly for Variable type of arguments. type Callbacks is not null access procedure (Argument: in String); --------------------------------------------------------------------------- -- Register callbacks for processing arguments. -- @Callback : Action to be performed in case appropriate argument is -- detected. -- @Called_On : Argument for which callback is to be performed. -- @Argument_Type : {Value, Variable}. Value is simple argument that needs no -- additional parsing. Variable is argument of "Arg_Name=Some_Val" form. -- When callback is triggered, Value is passed to callback as input, in -- case of Variable it is content of argument after first "=" that is -- passed to callback. -- @Case_Sensitive: Whether or not case is significant. When False all forms -- of argument are treated as if written in lower case. procedure Register ( Callback : in Callbacks; Called_On : in String; Argument_Type : in Argument_Types := Value; Case_Sensitive: in Boolean := True ); -- Raised if Called_On contains "=". Incorrect_Called_On: exception; --------------------------------------------------------------------------- -- Parse arguments supplied to program, calling callbacks when argument with -- associated callback is detected. -- NOTE: Process_Arguments will call callbacks however many times argument -- with associated callback is called. So if you have callback for "help", -- then ./program help help help -- will result in 3 calls to said callback. procedure Process_Arguments; --------------------------------------------------------------------------- end CBAP;
docandrew/troodon
Ada
1,484
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; package bits_types_struct_tm_h is -- ISO C `broken-down time' structure. -- Seconds. [0-60] (1 leap second) type tm is record tm_sec : aliased int; -- /usr/include/bits/types/struct_tm.h:9 tm_min : aliased int; -- /usr/include/bits/types/struct_tm.h:10 tm_hour : aliased int; -- /usr/include/bits/types/struct_tm.h:11 tm_mday : aliased int; -- /usr/include/bits/types/struct_tm.h:12 tm_mon : aliased int; -- /usr/include/bits/types/struct_tm.h:13 tm_year : aliased int; -- /usr/include/bits/types/struct_tm.h:14 tm_wday : aliased int; -- /usr/include/bits/types/struct_tm.h:15 tm_yday : aliased int; -- /usr/include/bits/types/struct_tm.h:16 tm_isdst : aliased int; -- /usr/include/bits/types/struct_tm.h:17 tm_gmtoff : aliased long; -- /usr/include/bits/types/struct_tm.h:20 tm_zone : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_tm.h:21 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/struct_tm.h:7 -- Minutes. [0-59] -- Hours. [0-23] -- Day. [1-31] -- Month. [0-11] -- Year - 1900. -- Day of week. [0-6] -- Days in year.[0-365] -- DST. [-1/0/1] -- Seconds east of UTC. -- Timezone abbreviation. -- Seconds east of UTC. -- Timezone abbreviation. end bits_types_struct_tm_h;
charlie5/cBound
Ada
1,591
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_poly_rectangle_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; drawable : aliased xcb.xcb_drawable_t; gc : aliased xcb.xcb_gcontext_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_poly_rectangle_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_poly_rectangle_request_t.Item, Element_Array => xcb.xcb_poly_rectangle_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_poly_rectangle_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_poly_rectangle_request_t.Pointer, Element_Array => xcb.xcb_poly_rectangle_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_poly_rectangle_request_t;
Gabriel-Degret/adalib
Ada
1,361
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Strings.Wide_Unbounded; package Ada.Wide_Text_IO.Unbounded_IO is procedure Put (File : in File_Type; Item : in Strings.Wide_Unbounded.Wide_Unbounded_String); procedure Put (Item : in Strings.Wide_Unbounded.Wide_Unbounded_String); procedure Put_Line (File : in File_Type; Item : in Strings.Wide_Unbounded.Wide_Unbounded_String); procedure Put_Line (Item : in Strings.Wide_Unbounded.Wide_Unbounded_String); function Get_Line (File : in File_Type) return Strings.Wide_Unbounded.Wide_Unbounded_String; function Get_Line return Strings.Wide_Unbounded.Wide_Unbounded_String; procedure Get_Line (File : in File_Type; Item : out Strings.Wide_Unbounded.Wide_Unbounded_String); procedure Get_Line (Item : out Strings.Wide_Unbounded.Wide_Unbounded_String); end Ada.Wide_Text_IO.Unbounded_IO;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Highlighted_Range_Elements is pragma Preelaborate; type ODF_Table_Highlighted_Range is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Highlighted_Range_Access is access all ODF_Table_Highlighted_Range'Class with Storage_Size => 0; end ODF.DOM.Table_Highlighted_Range_Elements;
tum-ei-rcs/StratoX
Ada
27,540
ads
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with HAL; with System; package STM32_SVD.ADC is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- SR_Register -- ----------------- -- status register type SR_Register is record -- Analog watchdog flag AWD : Boolean := False; -- Regular channel end of conversion EOC : Boolean := False; -- Injected channel end of conversion JEOC : Boolean := False; -- Injected channel start flag JSTRT : Boolean := False; -- Regular channel start flag STRT : Boolean := False; -- Overrun OVR : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record AWD at 0 range 0 .. 0; EOC at 0 range 1 .. 1; JEOC at 0 range 2 .. 2; JSTRT at 0 range 3 .. 3; STRT at 0 range 4 .. 4; OVR at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; ------------------ -- CR1_Register -- ------------------ subtype CR1_AWDCH_Field is HAL.UInt5; subtype CR1_DISCNUM_Field is HAL.UInt3; subtype CR1_RES_Field is HAL.UInt2; -- control register 1 type CR1_Register is record -- Analog watchdog channel select bits AWDCH : CR1_AWDCH_Field := 16#0#; -- Interrupt enable for EOC EOCIE : Boolean := False; -- Analog watchdog interrupt enable AWDIE : Boolean := False; -- Interrupt enable for injected channels JEOCIE : Boolean := False; -- Scan mode SCAN : Boolean := False; -- Enable the watchdog on a single channel in scan mode AWDSGL : Boolean := False; -- Automatic injected group conversion JAUTO : Boolean := False; -- Discontinuous mode on regular channels DISCEN : Boolean := False; -- Discontinuous mode on injected channels JDISCEN : Boolean := False; -- Discontinuous mode channel count DISCNUM : CR1_DISCNUM_Field := 16#0#; -- unspecified Reserved_16_21 : HAL.UInt6 := 16#0#; -- Analog watchdog enable on injected channels JAWDEN : Boolean := False; -- Analog watchdog enable on regular channels AWDEN : Boolean := False; -- Resolution RES : CR1_RES_Field := 16#0#; -- Overrun interrupt enable OVRIE : Boolean := False; -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record AWDCH at 0 range 0 .. 4; EOCIE at 0 range 5 .. 5; AWDIE at 0 range 6 .. 6; JEOCIE at 0 range 7 .. 7; SCAN at 0 range 8 .. 8; AWDSGL at 0 range 9 .. 9; JAUTO at 0 range 10 .. 10; DISCEN at 0 range 11 .. 11; JDISCEN at 0 range 12 .. 12; DISCNUM at 0 range 13 .. 15; Reserved_16_21 at 0 range 16 .. 21; JAWDEN at 0 range 22 .. 22; AWDEN at 0 range 23 .. 23; RES at 0 range 24 .. 25; OVRIE at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; ------------------ -- CR2_Register -- ------------------ subtype CR2_JEXTSEL_Field is HAL.UInt4; subtype CR2_JEXTEN_Field is HAL.UInt2; subtype CR2_EXTSEL_Field is HAL.UInt4; subtype CR2_EXTEN_Field is HAL.UInt2; -- control register 2 type CR2_Register is record -- A/D Converter ON / OFF ADON : Boolean := False; -- Continuous conversion CONT : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- Direct memory access mode (for single ADC mode) DMA : Boolean := False; -- DMA disable selection (for single ADC mode) DDS : Boolean := False; -- End of conversion selection EOCS : Boolean := False; -- Data alignment ALIGN : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- External event select for injected group JEXTSEL : CR2_JEXTSEL_Field := 16#0#; -- External trigger enable for injected channels JEXTEN : CR2_JEXTEN_Field := 16#0#; -- Start conversion of injected channels JSWSTART : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- External event select for regular group EXTSEL : CR2_EXTSEL_Field := 16#0#; -- External trigger enable for regular channels EXTEN : CR2_EXTEN_Field := 16#0#; -- Start conversion of regular channels SWSTART : Boolean := False; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record ADON at 0 range 0 .. 0; CONT at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; DMA at 0 range 8 .. 8; DDS at 0 range 9 .. 9; EOCS at 0 range 10 .. 10; ALIGN at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; JEXTSEL at 0 range 16 .. 19; JEXTEN at 0 range 20 .. 21; JSWSTART at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; EXTSEL at 0 range 24 .. 27; EXTEN at 0 range 28 .. 29; SWSTART at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -------------------- -- SMPR1_Register -- -------------------- --------------- -- SMPR1.SMP -- --------------- -- SMPR1_SMP array element subtype SMPR1_SMP_Element is HAL.UInt3; -- SMPR1_SMP array type SMPR1_SMP_Field_Array is array (10 .. 18) of SMPR1_SMP_Element with Component_Size => 3, Size => 27; -- Type definition for SMPR1_SMP type SMPR1_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : HAL.UInt27; when True => -- SMP as an array Arr : SMPR1_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 27; for SMPR1_SMP_Field use record Val at 0 range 0 .. 26; Arr at 0 range 0 .. 26; end record; -- sample time register 1 type SMPR1_Register is record -- Sample time bits SMP : SMPR1_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR1_Register use record SMP at 0 range 0 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -------------------- -- SMPR2_Register -- -------------------- --------------- -- SMPR2.SMP -- --------------- -- SMPR2_SMP array element subtype SMPR2_SMP_Element is HAL.UInt3; -- SMPR2_SMP array type SMPR2_SMP_Field_Array is array (0 .. 9) of SMPR2_SMP_Element with Component_Size => 3, Size => 30; -- Type definition for SMPR2_SMP type SMPR2_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : HAL.UInt30; when True => -- SMP as an array Arr : SMPR2_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SMPR2_SMP_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- sample time register 2 type SMPR2_Register is record -- Sample time bits SMP : SMPR2_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR2_Register use record SMP at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; -------------------- -- JOFR1_Register -- -------------------- subtype JOFR1_JOFFSET1_Field is HAL.UInt12; -- injected channel data offset register x type JOFR1_Register is record -- Data offset for injected channel x JOFFSET1 : JOFR1_JOFFSET1_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR1_Register use record JOFFSET1 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR2_Register -- -------------------- subtype JOFR2_JOFFSET2_Field is HAL.UInt12; -- injected channel data offset register x type JOFR2_Register is record -- Data offset for injected channel x JOFFSET2 : JOFR2_JOFFSET2_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR2_Register use record JOFFSET2 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR3_Register -- -------------------- subtype JOFR3_JOFFSET3_Field is HAL.UInt12; -- injected channel data offset register x type JOFR3_Register is record -- Data offset for injected channel x JOFFSET3 : JOFR3_JOFFSET3_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR3_Register use record JOFFSET3 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR4_Register -- -------------------- subtype JOFR4_JOFFSET4_Field is HAL.UInt12; -- injected channel data offset register x type JOFR4_Register is record -- Data offset for injected channel x JOFFSET4 : JOFR4_JOFFSET4_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR4_Register use record JOFFSET4 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- HTR_Register -- ------------------ subtype HTR_HT_Field is HAL.UInt12; -- watchdog higher threshold register type HTR_Register is record -- Analog watchdog higher threshold HT : HTR_HT_Field := 16#FFF#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HTR_Register use record HT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- LTR_Register -- ------------------ subtype LTR_LT_Field is HAL.UInt12; -- watchdog lower threshold register type LTR_Register is record -- Analog watchdog lower threshold LT : LTR_LT_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LTR_Register use record LT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------- -- SQR1_Register -- ------------------- ------------- -- SQR1.SQ -- ------------- -- SQR1_SQ array element subtype SQR1_SQ_Element is HAL.UInt5; -- SQR1_SQ array type SQR1_SQ_Field_Array is array (13 .. 16) of SQR1_SQ_Element with Component_Size => 5, Size => 20; -- Type definition for SQR1_SQ type SQR1_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt20; when True => -- SQ as an array Arr : SQR1_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for SQR1_SQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype SQR1_L_Field is HAL.UInt4; -- regular sequence register 1 type SQR1_Register is record -- 13th conversion in regular sequence SQ : SQR1_SQ_Field := (As_Array => False, Val => 16#0#); -- Regular channel sequence length L : SQR1_L_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR1_Register use record SQ at 0 range 0 .. 19; L at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------- -- SQR2_Register -- ------------------- ------------- -- SQR2.SQ -- ------------- -- SQR2_SQ array element subtype SQR2_SQ_Element is HAL.UInt5; -- SQR2_SQ array type SQR2_SQ_Field_Array is array (7 .. 12) of SQR2_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR2_SQ type SQR2_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt30; when True => -- SQ as an array Arr : SQR2_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR2_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 2 type SQR2_Register is record -- 7th conversion in regular sequence SQ : SQR2_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR2_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- SQR3_Register -- ------------------- ------------- -- SQR3.SQ -- ------------- -- SQR3_SQ array element subtype SQR3_SQ_Element is HAL.UInt5; -- SQR3_SQ array type SQR3_SQ_Field_Array is array (1 .. 6) of SQR3_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR3_SQ type SQR3_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt30; when True => -- SQ as an array Arr : SQR3_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR3_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 3 type SQR3_Register is record -- 1st conversion in regular sequence SQ : SQR3_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR3_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- JSQR_Register -- ------------------- -------------- -- JSQR.JSQ -- -------------- -- JSQR_JSQ array element subtype JSQR_JSQ_Element is HAL.UInt5; -- JSQR_JSQ array type JSQR_JSQ_Field_Array is array (1 .. 4) of JSQR_JSQ_Element with Component_Size => 5, Size => 20; -- Type definition for JSQR_JSQ type JSQR_JSQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- JSQ as a value Val : HAL.UInt20; when True => -- JSQ as an array Arr : JSQR_JSQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for JSQR_JSQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype JSQR_JL_Field is HAL.UInt2; -- injected sequence register type JSQR_Register is record -- 1st conversion in injected sequence JSQ : JSQR_JSQ_Field := (As_Array => False, Val => 16#0#); -- Injected sequence length JL : JSQR_JL_Field := 16#0#; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JSQR_Register use record JSQ at 0 range 0 .. 19; JL at 0 range 20 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------ -- JDR_Register -- ------------------ subtype JDR1_JDATA_Field is HAL.Short; -- injected data register x type JDR_Register is record -- Read-only. Injected data JDATA : JDR1_JDATA_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JDR_Register use record JDATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- DR_Register -- ----------------- subtype DR_DATA_Field is HAL.Short; -- regular data register type DR_Register is record -- Read-only. Regular data DATA : DR_DATA_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ------------------ -- CSR_Register -- ------------------ -- ADC Common status register type CSR_Register is record -- Read-only. Analog watchdog flag of ADC 1 AWD1 : Boolean; -- Read-only. End of conversion of ADC 1 EOC1 : Boolean; -- Read-only. Injected channel end of conversion of ADC 1 JEOC1 : Boolean; -- Read-only. Injected channel Start flag of ADC 1 JSTRT1 : Boolean; -- Read-only. Regular channel Start flag of ADC 1 STRT1 : Boolean; -- Read-only. Overrun flag of ADC 1 OVR1 : Boolean; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. Analog watchdog flag of ADC 2 AWD2 : Boolean; -- Read-only. End of conversion of ADC 2 EOC2 : Boolean; -- Read-only. Injected channel end of conversion of ADC 2 JEOC2 : Boolean; -- Read-only. Injected channel Start flag of ADC 2 JSTRT2 : Boolean; -- Read-only. Regular channel Start flag of ADC 2 STRT2 : Boolean; -- Read-only. Overrun flag of ADC 2 OVR2 : Boolean; -- unspecified Reserved_14_15 : HAL.UInt2; -- Read-only. Analog watchdog flag of ADC 3 AWD3 : Boolean; -- Read-only. End of conversion of ADC 3 EOC3 : Boolean; -- Read-only. Injected channel end of conversion of ADC 3 JEOC3 : Boolean; -- Read-only. Injected channel Start flag of ADC 3 JSTRT3 : Boolean; -- Read-only. Regular channel Start flag of ADC 3 STRT3 : Boolean; -- Read-only. Overrun flag of ADC3 OVR3 : Boolean; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record AWD1 at 0 range 0 .. 0; EOC1 at 0 range 1 .. 1; JEOC1 at 0 range 2 .. 2; JSTRT1 at 0 range 3 .. 3; STRT1 at 0 range 4 .. 4; OVR1 at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; AWD2 at 0 range 8 .. 8; EOC2 at 0 range 9 .. 9; JEOC2 at 0 range 10 .. 10; JSTRT2 at 0 range 11 .. 11; STRT2 at 0 range 12 .. 12; OVR2 at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; AWD3 at 0 range 16 .. 16; EOC3 at 0 range 17 .. 17; JEOC3 at 0 range 18 .. 18; JSTRT3 at 0 range 19 .. 19; STRT3 at 0 range 20 .. 20; OVR3 at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------ -- CCR_Register -- ------------------ subtype CCR_MULT_Field is HAL.UInt5; subtype CCR_DELAY_Field is HAL.UInt4; subtype CCR_DMA_Field is HAL.UInt2; subtype CCR_ADCPRE_Field is HAL.UInt2; -- ADC common control register type CCR_Register is record -- Multi ADC mode selection MULT : CCR_MULT_Field := 16#0#; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- Delay between 2 sampling phases DELAY_k : CCR_DELAY_Field := 16#0#; -- unspecified Reserved_12_12 : HAL.Bit := 16#0#; -- DMA disable selection for multi-ADC mode DDS : Boolean := False; -- Direct memory access mode for multi ADC mode DMA : CCR_DMA_Field := 16#0#; -- ADC prescaler ADCPRE : CCR_ADCPRE_Field := 16#0#; -- unspecified Reserved_18_21 : HAL.UInt4 := 16#0#; -- VBAT enable VBATE : Boolean := False; -- Temperature sensor and VREFINT enable TSVREFE : Boolean := False; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR_Register use record MULT at 0 range 0 .. 4; Reserved_5_7 at 0 range 5 .. 7; DELAY_k at 0 range 8 .. 11; Reserved_12_12 at 0 range 12 .. 12; DDS at 0 range 13 .. 13; DMA at 0 range 14 .. 15; ADCPRE at 0 range 16 .. 17; Reserved_18_21 at 0 range 18 .. 21; VBATE at 0 range 22 .. 22; TSVREFE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------ -- CDR_Register -- ------------------ -- CDR_DATA array element subtype CDR_DATA_Element is HAL.Short; -- CDR_DATA array type CDR_DATA_Field_Array is array (1 .. 2) of CDR_DATA_Element with Component_Size => 16, Size => 32; -- ADC common regular data register for dual and triple modes type CDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : CDR_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for CDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Analog-to-digital converter type ADC1_Peripheral is record -- status register SR : SR_Register; -- control register 1 CR1 : CR1_Register; -- control register 2 CR2 : CR2_Register; -- sample time register 1 SMPR1 : SMPR1_Register; -- sample time register 2 SMPR2 : SMPR2_Register; -- injected channel data offset register x JOFR1 : JOFR1_Register; -- injected channel data offset register x JOFR2 : JOFR2_Register; -- injected channel data offset register x JOFR3 : JOFR3_Register; -- injected channel data offset register x JOFR4 : JOFR4_Register; -- watchdog higher threshold register HTR : HTR_Register; -- watchdog lower threshold register LTR : LTR_Register; -- regular sequence register 1 SQR1 : SQR1_Register; -- regular sequence register 2 SQR2 : SQR2_Register; -- regular sequence register 3 SQR3 : SQR3_Register; -- injected sequence register JSQR : JSQR_Register; -- injected data register x JDR1 : JDR_Register; -- injected data register x JDR2 : JDR_Register; -- injected data register x JDR3 : JDR_Register; -- injected data register x JDR4 : JDR_Register; -- regular data register DR : DR_Register; end record with Volatile; for ADC1_Peripheral use record SR at 0 range 0 .. 31; CR1 at 4 range 0 .. 31; CR2 at 8 range 0 .. 31; SMPR1 at 12 range 0 .. 31; SMPR2 at 16 range 0 .. 31; JOFR1 at 20 range 0 .. 31; JOFR2 at 24 range 0 .. 31; JOFR3 at 28 range 0 .. 31; JOFR4 at 32 range 0 .. 31; HTR at 36 range 0 .. 31; LTR at 40 range 0 .. 31; SQR1 at 44 range 0 .. 31; SQR2 at 48 range 0 .. 31; SQR3 at 52 range 0 .. 31; JSQR at 56 range 0 .. 31; JDR1 at 60 range 0 .. 31; JDR2 at 64 range 0 .. 31; JDR3 at 68 range 0 .. 31; JDR4 at 72 range 0 .. 31; DR at 76 range 0 .. 31; end record; -- Analog-to-digital converter ADC1_Periph : aliased ADC1_Peripheral with Import, Address => ADC1_Base; -- Analog-to-digital converter ADC2_Periph : aliased ADC1_Peripheral with Import, Address => ADC2_Base; -- Analog-to-digital converter ADC3_Periph : aliased ADC1_Peripheral with Import, Address => ADC3_Base; -- Common ADC registers type C_ADC_Peripheral is record -- ADC Common status register CSR : CSR_Register; -- ADC common control register CCR : CCR_Register; -- ADC common regular data register for dual and triple modes CDR : CDR_Register; end record with Volatile; for C_ADC_Peripheral use record CSR at 0 range 0 .. 31; CCR at 4 range 0 .. 31; CDR at 8 range 0 .. 31; end record; -- Common ADC registers C_ADC_Periph : aliased C_ADC_Peripheral with Import, Address => C_ADC_Base; end STM32_SVD.ADC;
stcarrez/ada-wiki
Ada
2,124
adb
----------------------------------------------------------------------- -- wiki-render-links -- Wiki links renderering -- Copyright (C) 2015, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Wiki.Render.Links is -- ------------------------------ -- Get the image link that must be rendered from the wiki image link. -- ------------------------------ overriding procedure Make_Image_Link (Renderer : in out Default_Link_Renderer; Link : in Wiki.Strings.WString; URI : out Wiki.Strings.UString; Width : in out Natural; Height : in out Natural) is pragma Unreferenced (Renderer); begin URI := Wiki.Strings.To_UString (Link); Width := 0; Height := 0; end Make_Image_Link; -- ------------------------------ -- Get the page link that must be rendered from the wiki page link. -- ------------------------------ overriding procedure Make_Page_Link (Renderer : in out Default_Link_Renderer; Link : in Wiki.Strings.WString; URI : out Wiki.Strings.UString; Exists : out Boolean) is pragma Unreferenced (Renderer); begin URI := Wiki.Strings.To_UString (Link); Exists := True; end Make_Page_Link; end Wiki.Render.Links;
stcarrez/ada-ado
Ada
6,897
ads
----------------------------------------------------------------------- -- ado-connections -- Database connections -- Copyright (C) 2010, 2011, 2012, 2016, 2017, 2018, 2019, 2021, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with ADO.Statements; with ADO.Schemas; with ADO.Configs; with Util.Strings; with Util.Strings.Vectors; with Util.Refs; -- The `ADO.Connections` package represents the database driver that will create -- database connections and provide the database specific implementation. package ADO.Connections is use ADO.Statements; -- Raised for all errors reported by the database. Database_Error : exception; type Driver is abstract tagged limited private; type Driver_Access is access all Driver'Class; subtype Driver_Index is ADO.Configs.Driver_Index range 1 .. ADO.Configs.Driver_Index'Last; -- ------------------------------ -- Database connection implementation -- ------------------------------ -- type Database_Connection is abstract new Util.Refs.Ref_Entity with record Ident : String (1 .. 8) := (others => ' '); end record; type Database_Connection_Access is access all Database_Connection'Class; function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access is abstract; function Create_Statement (Database : in Database_Connection; Query : in String) return Query_Statement_Access is abstract; -- Create a delete statement. function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access is abstract; -- Create an insert statement. function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access is abstract; -- Create an update statement. function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access is abstract; -- Start a transaction. procedure Begin_Transaction (Database : in out Database_Connection) is abstract; -- Commit the current transaction. procedure Commit (Database : in out Database_Connection) is abstract; -- Rollback the current transaction. procedure Rollback (Database : in out Database_Connection) is abstract; -- Load the database schema definition for the current database. procedure Load_Schema (Database : in Database_Connection; Schema : out ADO.Schemas.Schema_Definition) is abstract; -- Check if the table with the given name exists in the database. function Has_Table (Database : in Database_Connection; Name : in String) return Boolean is abstract; -- Get the database driver which manages this connection. function Get_Driver (Database : in Database_Connection) return Driver_Access is abstract; -- Closes the database connection procedure Close (Database : in out Database_Connection) is abstract; package Ref is new Util.Refs.Indefinite_References (Element_Type => Database_Connection'Class, Element_Access => Database_Connection_Access); -- ------------------------------ -- The database configuration properties -- ------------------------------ type Configuration is new ADO.Configs.Configuration with null record; -- Get the driver index that corresponds to the driver for this database connection string. function Get_Driver (Config : in Configuration) return Driver_Index; -- Create a new connection using the configuration parameters. procedure Create_Connection (Config : in Configuration'Class; Result : in out Ref.Ref'Class) with Post => not Result.Is_Null; function Has_Limited_Transactions (Config : in Configuration'Class) return Boolean; -- ------------------------------ -- Database Driver -- ------------------------------ -- Create a new connection using the configuration parameters. procedure Create_Connection (D : in out Driver; Config : in Configuration'Class; Result : in out Ref.Ref'Class) is abstract with Post'Class => not Result.Is_Null; -- Create the database and initialize it with the schema SQL file. -- The `Admin` parameter describes the database connection with administrator access. -- The `Config` parameter describes the target database connection. procedure Create_Database (D : in out Driver; Admin : in Configs.Configuration'Class; Config : in Configs.Configuration'Class; Schema_Path : in String; Messages : out Util.Strings.Vectors.Vector) is abstract; -- Returns true if the database has limited transaction support. -- The HiLo sequence generator must not use a separate database -- connection and it should use the current database connection instead -- to avoid database locks. function Has_Limited_Transactions (Config : in Driver) return Boolean is (False); -- Get the driver unique index. function Get_Driver_Index (D : in Driver) return Driver_Index; -- Get the driver name. function Get_Driver_Name (D : in Driver) return String; -- Register a database driver. procedure Register (Driver : in Driver_Access); -- Get a database driver given its name. function Get_Driver (Name : in String) return Driver_Access; private type Driver is abstract new Ada.Finalization.Limited_Controlled with record Name : Util.Strings.Name_Access; Index : Driver_Index; end record; end ADO.Connections;
stcarrez/sql-benchmark
Ada
4,990
ads
-- -- -- package Copyright (c) Dmitry A. Kazakov -- -- IEEE_754.Generic_Double_Precision Luebeck -- -- Interface Summer, 2008 -- -- -- -- Last revision : 09:27 06 Nov 2016 -- -- -- -- This library 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 2 of -- -- the License, 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. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- generic type Number is digits <>; package IEEE_754.Generic_Double_Precision is pragma Pure (IEEE_754.Generic_Double_Precision); use Interfaces; -- -- Float_64 -- 64-bit double-precision IEEE 754 float. The memory layout -- is big endian, i.e. the byte containing the number's sign -- and the most significant bits of the exponent is the first array -- element. The byte containing the least significant bits of the -- mantissa is the last array element. -- type Float_64 is array (1..8) of Byte; Positive_Infinity : constant Float_64; Positive_Zero : constant Float_64; Negative_Infinity : constant Float_64; Negative_Zero : constant Float_64; -- -- From_IEEE -- Conversion from 32-bit single precision IEEE 754 float -- -- Value - The argument -- -- Returns : -- -- The corresponding floating-point number -- -- Exceptions : -- -- Not_A_Number_Error - Not a number -- Positive_Overflow_Error - Positive infinity or too big positive -- Negative_Overflow_Error - Negative infinity or too big negative -- function From_IEEE (Value : Float_64) return Number; -- -- Is_NaN -- NaN test -- -- Value - The argument -- -- Returns : -- -- True if Value is an IEEE NaN -- function Is_NaN (Value : Float_64) return Boolean; -- -- Is_Negative -- IEEE sign test -- -- Value - The argument -- -- Returns : -- -- True if Value has an IEEE sign -- function Is_Negative (Value : Float_64) return Boolean; -- -- Is_Real -- Value test -- -- Value - The argument -- -- This function tests if Value represents a real number. Infinities and -- NaN are not numbers. Both zeros are considered numbers. -- -- Returns : -- -- True if Value represents a real number -- function Is_Real (Value : Float_64) return Boolean; -- -- Normalize -- Split number into integer mantissa and binary exponent -- -- Value - The argument -- Mantissa - The mantissa -- Exponent - The binary exponent -- procedure Normalize ( Value : Number; Mantissa : out Unsigned_64; Exponent : out Integer ); -- -- To_IEEE -- Conversion to 32-bit single precision IEEE 754 float -- -- Value - The argument -- -- The value to big for normalized representation results in the -- corresponding IEEE infinities. Too small values are represented as -- IEEE zero. -- -- Returns : -- -- The corresponding IEEE 754 representation -- function To_IEEE (Value : Number) return Float_64; private pragma Inline (Is_NaN); pragma Inline (Is_Negative); pragma Inline (Is_Real); pragma Inline (Normalize); Positive_Infinity : constant Float_64 := (16#7F#,16#F0#,others => 0); Positive_Zero : constant Float_64 := (others => 0); Negative_Infinity : constant Float_64 := (16#FF#,16#F8#,others => 0); Negative_Zero : constant Float_64 := (16#80#,others => 0); end IEEE_754.Generic_Double_Precision;
reznikmm/matreshka
Ada
81
ads
package Documentation_Generator is pragma Pure; end Documentation_Generator;
onox/orka
Ada
17,733
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Unchecked_Conversion; package body GL.Runtime_Loading is generic type Function_Reference is private; function Load (Function_Name : String) return Function_Reference; function Load (Function_Name : String) return Function_Reference is function As_Function_Reference is new Ada.Unchecked_Conversion (Source => System.Address, Target => Function_Reference); begin return As_Function_Reference (Raw_Subprogram_Reference (Function_Name)); end Load; package body Function_Without_Params is function Init return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref.all; end Init; end Function_Without_Params; package body Function_With_1_Param is function Init (Param1 : Param1_Type) return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref (Param1); end Init; end Function_With_1_Param; package body Function_With_2_Params is function Init (Param1 : Param1_Type; Param2 : Param2_Type) return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref (Param1, Param2); end Init; end Function_With_2_Params; package body Function_With_3_Params is function Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type) return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref (Param1, Param2, Param3); end Init; end Function_With_3_Params; package body Function_With_4_Params is function Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type) return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref (Param1, Param2, Param3, Param4); end Init; end Function_With_4_Params; package body Function_With_8_Params is function Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type) return Return_Type is function Load_Function is new Load (Function_Reference); begin Ref := Load_Function (Function_Name); return Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8); end Init; end Function_With_8_Params; package body Array_Getter_With_5_Params is type Procedure_Reference is not null access procedure (Param1 : Param1_Type; Param2 : Param2_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) with Convention => StdCall; procedure Internal_Init (Param1 : Param1_Type; Param2 : Param2_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) with Convention => StdCall; Internal_Ref : Procedure_Reference := Internal_Init'Access; procedure Internal_Init (Param1 : Param1_Type; Param2 : Param2_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Internal_Ref := Load_Procedure (Procedure_Name); Internal_Ref (Param1, Param2, Max, Size, Values); end Internal_Init; function Ref (Param1 : Param1_Type; Param2 : Param2_Type; Max_Size : Types.Size) return Array_Type is Actual_Size : Types.Size := 0; Result : Array_Type (1 .. Max_Size); begin Internal_Ref (Param1, Param2, Max_Size, Actual_Size, Result); return (if Actual_Size /= Max_Size then Result (1 .. Actual_Size) else Result); end Ref; end Array_Getter_With_5_Params; package body Array_Getter_With_8_Params is type Procedure_Reference is not null access procedure (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) with Convention => StdCall; procedure Internal_Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) with Convention => StdCall; Internal_Ref : Procedure_Reference := Internal_Init'Access; procedure Internal_Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Max : Types.Size; Size : in out Types.Size; Values : in out Array_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Internal_Ref := Load_Procedure (Procedure_Name); Internal_Ref (Param1, Param2, Param3, Param4, Param5, Max, Size, Values); end Internal_Init; function Ref (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Max_Size : Types.Size) return Array_Type is Actual_Size : Types.Size := 0; Result : Array_Type (1 .. Max_Size); begin Internal_Ref (Param1, Param2, Param3, Param4, Param5, Max_Size, Actual_Size, Result); return (if Actual_Size /= Max_Size then Result (1 .. Actual_Size) else Result); end Ref; end Array_Getter_With_8_Params; package body Procedure_Without_Params is procedure Init is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref.all; end Init; end Procedure_Without_Params; package body Procedure_With_1_Param is procedure Init (Param1 : Param1_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1); end Init; end Procedure_With_1_Param; package body Procedure_With_2_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2); end Init; end Procedure_With_2_Params; package body Procedure_With_3_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3); end Init; end Procedure_With_3_Params; package body Procedure_With_4_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4); end Init; end Procedure_With_4_Params; package body Procedure_With_5_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5); end Init; end Procedure_With_5_Params; package body Procedure_With_6_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6); end Init; end Procedure_With_6_Params; package body Procedure_With_7_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7); end Init; end Procedure_With_7_Params; package body Procedure_With_8_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8); end Init; end Procedure_With_8_Params; package body Procedure_With_9_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type; Param9 : Param9_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9); end Init; end Procedure_With_9_Params; package body Procedure_With_10_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type; Param9 : Param9_Type; Param10 : Param10_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10); end Init; end Procedure_With_10_Params; package body Procedure_With_11_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type; Param9 : Param9_Type; Param10 : Param10_Type; Param11 : Param11_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11); end Init; end Procedure_With_11_Params; package body Procedure_With_12_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type; Param9 : Param9_Type; Param10 : Param10_Type; Param11 : Param11_Type; Param12 : Param12_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12); end Init; end Procedure_With_12_Params; package body Procedure_With_15_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Param5 : Param5_Type; Param6 : Param6_Type; Param7 : Param7_Type; Param8 : Param8_Type; Param9 : Param9_Type; Param10 : Param10_Type; Param11 : Param11_Type; Param12 : Param12_Type; Param13 : Param13_Type; Param14 : Param14_Type; Param15 : Param15_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15); end Init; end Procedure_With_15_Params; package body Array_Proc_With_2_Params is procedure Init (Param1 : Size_Type; Param2 : Array_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2); end Init; end Array_Proc_With_2_Params; package body Array_Proc_With_3_Params is procedure Init (Param1 : Param1_Type; Param2 : Size_Type; Param3 : Array_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3); end Init; end Array_Proc_With_3_Params; package body Getter_With_2_Params is procedure Init (Param1 : Param1_Type; Value : in out Value_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Value); end Init; end Getter_With_2_Params; package body Getter_With_3_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Value : in out Value_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Value); end Init; end Getter_With_3_Params; package body Getter_With_4_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Value : in out Value_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Value); end Init; end Getter_With_4_Params; package body Getter_With_5_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Param3 : Param3_Type; Param4 : Param4_Type; Value : in out Value_Type) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Param3, Param4, Value); end Init; end Getter_With_5_Params; package body String_Getter_With_4_Params is procedure Init (Param1 : Param1_Type; Buffer_Size : Size_Type; Length : out Size_Type; Value : in out String) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Buffer_Size, Length, Value); end Init; end String_Getter_With_4_Params; package body String_Getter_With_5_Params is procedure Init (Param1 : Param1_Type; Param2 : Param2_Type; Buffer_Size : Size_Type; Length : out Size_Type; Value : in out String) is function Load_Procedure is new Load (Procedure_Reference); begin Ref := Load_Procedure (Procedure_Name); Ref (Param1, Param2, Buffer_Size, Length, Value); end Init; end String_Getter_With_5_Params; end GL.Runtime_Loading;
reznikmm/matreshka
Ada
3,589
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-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$ ------------------------------------------------------------------------------ -- Root package for WSDL to Ada translator. ------------------------------------------------------------------------------ package WSDL is pragma Pure; WSDL_Error : exception; -- Raised to stop processing of WSDL document. end WSDL;
twdroeger/ada-awa
Ada
21,184
adb
----------------------------------------------------------------------- -- awa-setup -- Setup and installation -- Copyright (C) 2016, 2017, 2018, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.IO_Exceptions; with Ada.Directories; with Util.Files; with Util.Processes; with Util.Properties; with Util.Log.Loggers; with Util.Streams.Pipes; with Util.Streams.Buffered; with Util.Strings; with ASF.Events.Faces.Actions; with ASF.Applications.Main.Configs; with ASF.Applications.Messages.Factory; with AWA.Applications; with AWA.Applications.Configs; with AWA.Components.Factory; package body AWA.Setup.Applications is use ASF.Applications; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Setup.Applications"); package Save_Binding is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Application, Method => Save, Name => "save"); package Start_Binding is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Application, Method => Start, Name => "start"); package Finish_Binding is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Application, Method => Finish, Name => "finish"); package Configure_Binding is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Application, Method => Configure_Database, Name => "configure_database"); -- The application base URL. package P_Base_URL is new ASF.Applications.Main.Configs.Parameter ("app_url_base", "http://localhost:8080/#{contextPath}"); Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (Save_Binding.Proxy'Access, Start_Binding.Proxy'Access, Finish_Binding.Proxy'Access, Configure_Binding.Proxy'Access); protected body State is -- ------------------------------ -- Wait until the configuration is finished. -- ------------------------------ entry Wait_Configuring when Value /= CONFIGURING is begin null; end Wait_Configuring; -- ------------------------------ -- Wait until the server application is initialized and ready. -- ------------------------------ entry Wait_Ready when Value = READY is begin null; end Wait_Ready; -- ------------------------------ -- Set the configuration state. -- ------------------------------ procedure Set (V : in Configure_State) is begin Value := V; end Set; end State; overriding procedure Do_Get (Server : in Redirect_Servlet; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class) is pragma Unreferenced (Server); Context_Path : constant String := Request.Get_Context_Path; begin Response.Send_Redirect (Context_Path & "/setup/install.html"); end Do_Get; -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ function Get_Value (From : in Application; Name : in String) return Util.Beans.Objects.Object is begin if Name = "database_name" then return Util.Beans.Objects.To_Object (From.Database.Get_Database); elsif Name = "database_server" then return From.Db_Host; elsif Name = "database_port" then return From.Db_Port; elsif Name = "database_user" then return Util.Beans.Objects.To_Object (From.Database.Get_Property ("user")); elsif Name = "database_password" then return Util.Beans.Objects.To_Object (From.Database.Get_Property ("password")); elsif Name = "database_driver" then return From.Driver; elsif Name = "database_root_user" then return From.Root_User; elsif Name = "database_root_password" then return From.Root_Passwd; elsif Name = "result" then return From.Result; end if; if From.Changed.Exists (Name) then return Util.Beans.Objects.To_Object (String '(From.Changed.Get (Name))); end if; declare Param : constant String := From.Config.Get (Name); begin return Util.Beans.Objects.To_Object (Param); end; exception when others => return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ procedure Set_Value (From : in out Application; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "database_name" then From.Database.Set_Database (Util.Beans.Objects.To_String (Value)); elsif Name = "database_server" then From.Db_Host := Value; elsif Name = "database_port" then From.Db_Port := Value; elsif Name = "database_user" then From.Database.Set_Property ("user", Util.Beans.Objects.To_String (Value)); elsif Name = "database_password" then From.Database.Set_Property ("password", Util.Beans.Objects.To_String (Value)); elsif Name = "database_driver" then From.Driver := Value; elsif Name = "database_root_user" then From.Root_User := Value; elsif Name = "database_root_password" then From.Root_Passwd := (if Util.Beans.Objects.Is_Null (Value) then Empty else Value); elsif Name = "callback_url" then From.Changed.Set (Name, Util.Beans.Objects.To_String (Value)); From.Changed.Set ("facebook.callback_url", Util.Beans.Objects.To_String (Value) & "#{contextPath}/auth/verify"); From.Changed.Set ("google-plus.callback_url", Util.Beans.Objects.To_String (Value) & "#{contextPath}/auth/verify"); else From.Changed.Set (Name, Util.Beans.Objects.To_String (Value)); end if; end Set_Value; -- ------------------------------ -- Get the database connection string to be used by the application. -- ------------------------------ function Get_Database_URL (From : in Application) return String is use Ada.Strings.Unbounded; Result : Ada.Strings.Unbounded.Unbounded_String; Driver : constant String := Util.Beans.Objects.To_String (From.Driver); User : constant String := From.Database.Get_Property ("user"); begin if Driver = "" then Append (Result, "mysql"); else Append (Result, Driver); end if; Append (Result, "://"); if Driver /= "sqlite" then Append (Result, From.Database.Get_Server); if From.Database.Get_Port /= 0 then Append (Result, ":"); Append (Result, Util.Strings.Image (From.Database.Get_Port)); end if; end if; Append (Result, "/"); Append (Result, From.Database.Get_Database); if User /= "" then Append (Result, "?user="); Append (Result, User); if From.Database.Get_Property ("password") /= "" then Append (Result, "&password="); Append (Result, From.Database.Get_Property ("password")); end if; end if; if Driver = "sqlite" then if User /= "" then Append (Result, "&"); else Append (Result, "?"); end if; Append (Result, "synchronous=OFF&encoding=UTF-8"); end if; return To_String (Result); end Get_Database_URL; -- ------------------------------ -- Get the command to configure the database. -- ------------------------------ function Get_Configure_Command (From : in Application) return String is Database : constant String := From.Get_Database_URL; Command : constant String := "dynamo create-database db '" & Database & "'"; Root : constant String := Util.Beans.Objects.To_String (From.Root_User); Passwd : constant String := Util.Beans.Objects.To_String (From.Root_Passwd); begin if Root = "" then return Command; elsif Passwd = "" then return Command & " " & Root; else return Command & " " & Root & " " & Passwd; end if; end Get_Configure_Command; -- ------------------------------ -- Validate the database configuration parameters. -- ------------------------------ procedure Validate (From : in out Application) is Driver : constant String := Util.Beans.Objects.To_String (From.Driver); Server : constant String := Util.Beans.Objects.To_String (From.Db_Host); begin From.Has_Error := False; if Driver = "sqlite" then return; end if; begin From.Database.Set_Port (Util.Beans.Objects.To_Integer (From.Db_Port)); exception when others => From.Has_Error := True; Messages.Factory.Add_Field_Message ("db-port", "setup.setup_database_port_error", Messages.ERROR); end; if Server'Length = 0 then From.Has_Error := True; Messages.Factory.Add_Field_Message ("db-server", "setup.setup_database_host_error", Messages.ERROR); end if; From.Database.Set_Server (Server); end Validate; -- ------------------------------ -- Configure the database. -- ------------------------------ procedure Configure_Database (From : in out Application; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin From.Validate; if not From.Has_Error then declare Pipe : aliased Util.Streams.Pipes.Pipe_Stream; Buffer : Util.Streams.Buffered.Input_Buffer_Stream; Content : Ada.Strings.Unbounded.Unbounded_String; Command : constant String := From.Get_Configure_Command; begin Log.Info ("Configure database with {0}", Command); Pipe.Open (Command, Util.Processes.READ); Buffer.Initialize (Pipe'Unchecked_Access, 64 * 1024); Buffer.Read (Content); Pipe.Close; From.Result := Util.Beans.Objects.To_Object (Content); From.Has_Error := Pipe.Get_Exit_Status /= 0; if From.Has_Error then Log.Error ("Command {0} exited with status {1}", Command, Util.Strings.Image (Pipe.Get_Exit_Status)); Messages.Factory.Add_Message ("setup.setup_database_error", Messages.ERROR); if Pipe.Get_Exit_Status = 127 then Messages.Factory.Add_Message ("setup.setup_dynamo_missing_error", Messages.ERROR); end if; end if; end; end if; if From.Has_Error then Ada.Strings.Unbounded.Set_Unbounded_String (Outcome, "failure"); end if; end Configure_Database; -- ------------------------------ -- Save the configuration. -- ------------------------------ procedure Save (From : in out Application; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is pragma Unreferenced (Outcome); procedure Save_Property (Name : in String; Value : in Util.Properties.Value); procedure Read_Property (Line : in String); Path : constant String := Ada.Strings.Unbounded.To_String (From.Path); New_File : constant String := Path & ".tmp"; Output : Ada.Text_IO.File_Type; Changed : ASF.Applications.Config := From.Changed; procedure Read_Property (Line : in String) is Pos : constant Natural := Util.Strings.Index (Line, '='); begin if Pos = 0 or else not Changed.Exists (Line (Line'First .. Pos - 1)) then Ada.Text_IO.Put_Line (Output, Line); return; end if; Ada.Text_IO.Put (Output, Line (Line'First .. Pos)); Ada.Text_IO.Put_Line (Output, Changed.Get (Line (Line'First .. Pos - 1))); Changed.Remove (Line (Line'First .. Pos - 1)); end Read_Property; procedure Save_Property (Name : in String; Value : in Util.Properties.Value) is begin Ada.Text_IO.Put (Output, Name); Ada.Text_IO.Put (Output, "="); Ada.Text_IO.Put_Line (Output, Util.Properties.To_String (Value)); end Save_Property; begin Log.Info ("Saving configuration file {0}", Path); Changed.Set ("database", From.Get_Database_URL); Ada.Text_IO.Create (File => Output, Name => New_File); Util.Files.Read_File (Path, Read_Property'Access); Changed.Iterate (Save_Property'Access); Ada.Text_IO.Close (Output); Ada.Directories.Delete_File (Path); Ada.Directories.Rename (Old_Name => New_File, New_Name => Path); end Save; -- ------------------------------ -- Finish the setup to start the application. -- ------------------------------ procedure Start (From : in out Application; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is pragma Unreferenced (Outcome); begin Log.Info ("Waiting for application to be started"); From.Status.Wait_Ready; end Start; -- ------------------------------ -- Finish the setup and exit the setup. -- ------------------------------ procedure Finish (From : in out Application; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Log.Info ("Finish configuration"); From.Save (Outcome); From.Status.Set (STARTING); end Finish; -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression -- ------------------------------ overriding function Get_Method_Bindings (From : in Application) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Enter in the application setup -- ------------------------------ procedure Setup (App : in out Application; Config : in String; Server : in out ASF.Server.Container'Class) is Path : constant String := AWA.Applications.Configs.Get_Config_Path (Config); Dir : constant String := Ada.Directories.Containing_Directory (Path); Done : constant String := Ada.Directories.Compose (Dir, ".initialized"); begin Log.Info ("Entering configuration for {0}", Path); App.Path := Ada.Strings.Unbounded.To_Unbounded_String (Path); begin App.Config.Load_Properties (Path); Util.Log.Loggers.Initialize (Path); exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot read application configuration file: {0}", Path); end; -- If the Done file marker exists, the installation was done -- and we don't want to enter in it again. if Ada.Directories.Exists (Done) then Log.Info ("Application {0} is already initialized.", Config); Log.Info ("Remove {0} if you want to enter in the installation again.", Done); return; end if; App.Initialize (App.Config, App.Factory); App.Set_Error_Page (ASF.Responses.SC_NOT_FOUND, "/setup/install.html"); App.Set_Global ("contextPath", App.Config.Get ("contextPath")); App.Set_Global ("setup", Util.Beans.Objects.To_Object (App'Unchecked_Access, Util.Beans.Objects.STATIC)); App.Add_Servlet (Name => "redirect", Server => App.Redirect'Unchecked_Access); App.Add_Servlet (Name => "faces", Server => App.Faces'Unchecked_Access); App.Add_Servlet (Name => "files", Server => App.Files'Unchecked_Access); App.Add_Mapping (Pattern => "*.html", Name => "redirect"); App.Add_Mapping (Pattern => "/setup/*.html", Name => "faces"); App.Add_Mapping (Pattern => "*.css", Name => "files"); App.Add_Mapping (Pattern => "*.js", Name => "files"); App.Add_Mapping (Pattern => "*.png", Name => "files"); App.Add_Components (AWA.Components.Factory.Definition); declare Paths : constant String := App.Get_Config (AWA.Applications.P_Module_Dir.P); Path : constant String := Util.Files.Find_File_Path ("setup.xml", Paths); begin ASF.Applications.Main.Configs.Read_Configuration (App, Path); exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Setup configuration file '{0}' does not exist", Path); end; declare URL : constant String := App.Config.Get ("google-plus.callback_url", ""); Pos : constant Natural := Util.Strings.Index (URL, '#'); begin if Pos > 0 then App.Changed.Set ("callback_url", URL (URL'First .. Pos - 1)); else App.Changed.Set ("callback_url", "http://mydomain.com/oauth"); end if; end; App.Database.Set_Connection (App.Get_Config (AWA.Applications.P_Database.P)); App.Driver := Util.Beans.Objects.To_Object (App.Database.Get_Driver); if App.Database.Get_Driver = "mysql" then App.Db_Host := Util.Beans.Objects.To_Object (App.Database.Get_Server); App.Db_Port := Util.Beans.Objects.To_Object (App.Database.Get_Port); else App.Db_Host := Util.Beans.Objects.To_Object (String '("localhost")); App.Db_Port := Util.Beans.Objects.To_Object (Integer (3306)); end if; Server.Register_Application (App.Get_Config (AWA.Applications.P_Context_Path.P), App'Unchecked_Access); Log.Info ("Connect your browser to {0}/index.html", App.Get_Config (P_Base_URL.P)); App.Status.Wait_Configuring; Log.Info ("Application setup is now finished"); Log.Info ("Creating the installation marker file {0}", Done); Util.Files.Write_File (Done, "installed"); end Setup; -- ------------------------------ -- Configure the application by using the setup application, allowing -- the administrator to setup the application database, define the application -- admin parameters. After the configuration is done, register the -- application in the server container and start it. -- ------------------------------ procedure Configure (Server : in out ASF.Server.Container'Class; App : in Application_Access; Config : in String; URI : in String) is Path : constant String := AWA.Applications.Configs.Get_Config_Path (Config); S : aliased Application; C : ASF.Applications.Config; begin -- Do the application setup. S.Setup (Config, Server); -- Load the application configuration file that was configured -- during the setup process. begin C.Load_Properties (Path); exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot read application configuration file {0}", Path); end; -- Initialize the application and register it. Log.Info ("Initializing application {0}", URI); Initialize (App, C); Server.Register_Application (URI, App.all'Access); S.Status.Set (READY); delay 2.0; -- Now we can remove the setup application. Server.Remove_Application (S'Unchecked_Access); end Configure; end AWA.Setup.Applications;
zhmu/ananas
Ada
2,576
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . S T R I N G S . H A S H _ C A S E _ I N S E N S I T I V E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Containers; function Ada.Strings.Hash_Case_Insensitive (Key : String) return Containers.Hash_Type; pragma Pure (Ada.Strings.Hash_Case_Insensitive); -- Computes a hash value for Key without regard for character case. This is -- useful as the generic actual Hash function when instantiating a hashed -- container package with type String as the key.
AdaCore/spat
Ada
3,230
adb
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); package body SPAT.Proof_Attempt is --------------------------------------------------------------------------- -- "<" --------------------------------------------------------------------------- not overriding function "<" (Left : in T; Right : in T) return Boolean is use type Proof_Attempt_Ids.Id; begin -- Sort by time, steps, result, and then prover name. if Left.Time /= Right.Time then return Left.Time > Right.Time; end if; if Left.Steps /= Right.Steps then return Left.Steps > Right.Steps; end if; if Left.Result /= Right.Result then return Left.Result < Right.Result; end if; if Left.Prover /= Right.Prover then return Left.Prover < Right.Prover; end if; -- Last resort, the unique id. return Left.Id < Right.Id; end "<"; --------------------------------------------------------------------------- -- Create --------------------------------------------------------------------------- function Create (Object : JSON_Value; Prover : Prover_Name) return T is Time_Field : constant JSON_Value := Object.Get (Field => Field_Names.Time); begin return T'(Entity.T with Prover => Prover, Result => Result_Name (Subject_Name'(Object.Get (Field => Field_Names.Result))), Workload => Time_And_Steps' (Time => (case Time_Field.Kind is when JSON_Float_Type => Duration (Time_Field.Get_Long_Float), when JSON_Int_Type => Duration (Long_Long_Integer'(Time_Field.Get)), when others => raise Program_Error with "Fatal: Impossible Kind """ & Time_Field.Kind'Image & """ of JSON object!"), Steps => -- FIXME: Step scaling will not be necessary anymore for -- the SPARK development version (i.e. SPARK CE 2021). Scaled (Prover => Prover, Raw_Steps => Prover_Steps (Long_Integer' (Object.Get (Field => Field_Names.Steps))))), Id => Proof_Attempt_Ids.Next); end Create; end SPAT.Proof_Attempt;
gitter-badger/libAnne
Ada
629
adb
package body Bindings.stdio is -------------------- -- Initialization -- -------------------- --* This package requires some initialization tricks to get the value of certain variables function get_stdin return Address with Import, Convention => StdCall, External_Name => "__gnat_constant_stdin"; function get_stdout return Address with Import, Convention => StdCall, External_Name => "__gnat_constant_stdout"; function get_stderr return Address with Import, Convention => StdCall, External_Name => "__gnat_constant_stderr"; begin stdin := get_stdin; stdout := get_stdout; stderr := get_stderr; end Bindings.stdio;
dan76/Amass
Ada
2,283
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 name = "AbuseIPDB" type = "scrape" function start() set_rate_limit(1) end function vertical(ctx, domain) local _, count = string.gsub(domain, "%.", "") if count > 1 then return end local ip = get_ip(ctx, domain) if (ip == nil or ip == "") then return end local resp, err = request(ctx, {['url']=build_url(ip)}) if (err ~= nil and err ~= "") then log(ctx, "vertical request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "vertical request to service returned with status code: " .. resp.status) return end local pattern = "<h1 class=text-center>([.a-z0-9-]{1,63})" local matches = submatch(resp.body, pattern) if (matches == nil or #matches == 0 or not in_scope(ctx, matches[1][2])) then return end pattern = "<li>([.a-z0-9-]{1,256})</li>" matches = submatch(resp.body, pattern) if (matches == nil or #matches == 0) then return end for _, match in pairs(matches) do if (match ~= nil and #match >=2) then send_names(ctx, match[2] .. "." .. domain) end end end function build_url(ip) return "https://www.abuseipdb.com/whois/" .. ip end function get_ip(ctx, domain) local resp, err = request(ctx, {['url']=ip_url(domain)}) if (err ~= nil and err ~= "") then log(ctx, "get_ip request to service failed: " .. err) return nil elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "get_ip request to service returned with status code: " .. resp.status) return nil end local pattern = "<i\\ class=text\\-primary>(.*)</i>" local matches = submatch(resp.body, pattern) if (matches == nil or #matches == 0) then return nil end local match = matches[1] if (match == nil or #match < 2 or match[2] == "") then return nil end return match[2] end function ip_url(domain) return "https://www.abuseipdb.com/check/" .. domain end
reznikmm/matreshka
Ada
6,398
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2018, 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.Holders.JSON_Arrays; with League.JSON.Arrays; with League.JSON.Documents; with League.Strings; with XML.SAX.Pretty_Writers; with XML.SAX.Simple_Readers; with XML.SAX.String_Input_Sources; with XML.SAX.String_Output_Destinations; with XML.Templates.Processors; procedure Test_454 is use type League.Strings.Universal_String; Data : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("[" & "{""name"":""post 1""," & " ""submenu"":[{""name"":""subitem 1-1""}," & " {""name"":""subitem 1-2""}]}," & "{""name"":""post 2""," & " ""submenu"":[{""name"":""subitem 2-1""}," & " {""name"":""subitem 2-2""}]}" & "]"); Page : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("<html xmlns='http://www.w3.org/1999/xhtml'" & " xmlns:mtl='http://forge.ada-ru.org/matreshka/template'>" & " <body>" & " <mtl:for expression='item of posts'>" & " ${item.name}" & " <mtl:for expression='subitem of item.submenu'>" & " ${item.name} -&gt; ${subitem.name}" & " </mtl:for>" & " </mtl:for>" & " </body>" & "</html>"); Expected : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("<?xml version='1.0'?>" & "<html xmlns='http://www.w3.org/1999/xhtml'>" & " <body>" & " post 1" & " post 1 -> subitem 1-1" & " post 1 -> subitem 1-2" & " post 2" & " post 2 -> subitem 2-1" & " post 2 -> subitem 2-2" & " </body></html>"); Posts : constant League.JSON.Arrays.JSON_Array := League.JSON.Documents.From_JSON (Data).To_JSON_Array; Input : aliased XML.SAX.String_Input_Sources.String_Input_Source; Reader : aliased XML.SAX.Simple_Readers.Simple_Reader; Filter : aliased XML.Templates.Processors.Template_Processor; Writer : aliased XML.SAX.Pretty_Writers.XML_Pretty_Writer; Output : aliased XML.SAX.String_Output_Destinations.String_Output_Destination; begin Input.Set_String (Page); -- Configure reader. Reader.Set_Input_Source (Input'Unchecked_Access); Reader.Set_Content_Handler (Filter'Unchecked_Access); Reader.Set_Lexical_Handler (Filter'Unchecked_Access); -- Configure template processor. Filter.Set_Content_Handler (Writer'Unchecked_Access); Filter.Set_Lexical_Handler (Writer'Unchecked_Access); Filter.Set_Parameter (League.Strings.To_Universal_String ("posts"), League.Holders.JSON_Arrays.To_Holder (Posts)); -- Configure XML writer. Writer.Set_Output_Destination (Output'Unchecked_Access); -- Process template. Reader.Parse; -- Output result. if Output.Get_Text /= Expected then raise Program_Error; end if; end Test_454;
reznikmm/matreshka
Ada
4,678
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Testsuite 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: 3927 $ $Date: 2013-05-02 22:43:26 +0300 (Чт., 02 мая 2013) $ ------------------------------------------------------------------------------ -- Checks whether wheter reopen connection hangs the driver. ------------------------------------------------------------------------------ with League.Strings; with League.Application; with SQL.Databases; with SQL.Options; with SQL.Queries; with Matreshka.Internals.SQL_Drivers.Oracle.Factory; procedure Test_337 is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Driver : constant League.Strings.Universal_String := +"ORACLE"; Options : SQL.Options.SQL_Options; begin Options.Set (Matreshka.Internals.SQL_Drivers.Oracle.User_Option, League.Application.Environment.Value (+"ORACLE_TEST_USER")); Options.Set (Matreshka.Internals.SQL_Drivers.Oracle.Password_Option, League.Application.Environment.Value (+"ORACLE_TEST_PASSWORD")); Options.Set (Matreshka.Internals.SQL_Drivers.Oracle.Database_Option, +"TEST"); declare Database : SQL.Databases.SQL_Database := SQL.Databases.Create (Driver, Options); Query : SQL.Queries.SQL_Query; begin Database.Open; Query := Database.Query (+"select * from dual"); Query.Execute; Database.Close; Database.Open; end; end Test_337;
OneWingedShark/Byron
Ada
201
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Lexington.Token_Vector_Pkg; -- Ensures that no invalid tokens are emitted. Procedure Lexington.Aux.P20(Data : in out Token_Vector_Pkg.Vector);
reznikmm/matreshka
Ada
3,642
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 League.Holders.Generic_Holders; package AMF.DC.Holders.Points is new League.Holders.Generic_Holders (AMF.DC.DC_Point); pragma Preelaborate (AMF.DC.Holders.Points);
afrl-rq/OpenUxAS
Ada
2,492
adb
with AVTAS.LMCP.Types; with LMCP_Message_Conversions; use LMCP_Message_Conversions; package body Assignment_Tree_Branch_Bound_Communication is ---------------- -- Initialize -- ---------------- procedure Initialize (This : out Assignment_Tree_Branch_Bound_Mailbox; Source_Group : String; Unique_Id : Int64; Entity_Id : UInt32; Service_Id : UInt32) is begin -- The procedure UxAS.Comms.LMCP_Net_Client.Initialize_Network_Client() -- will also initialize its Message_Sender_Pipe component but will not -- use it for sending: -- -- This.Message_Sender_Pipe.Initialize_Push -- (Source_Group => Value (This.Message_Source_Group), -- Entity_Id => This.Entity_Id, -- Service_Id => UInt32 (This.Network_Id)); This.Message_Sender_Pipe.Initialize_Push (Source_Group => Source_Group, Entity_Id => AVTAS.LMCP.Types.UInt32 (Entity_Id), Service_Id => AVTAS.LMCP.Types.UInt32 (Service_Id)); This.Unique_Entity_Send_Message_Id := Unique_Id; end Initialize; -------------------------- -- sendBroadcastMessage -- -------------------------- -- this is sendSharedLMCPObjectBroadcastMessage(), in our code Send_Shared_LMCP_Object_Broadcast_Message procedure sendBroadcastMessage (This : in out Assignment_Tree_Branch_Bound_Mailbox; Msg : Message_Root'Class) is begin This.Unique_Entity_Send_Message_Id := This.Unique_Entity_Send_Message_Id + 1; -- This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (Msg); This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (As_Object_Any (Msg)); end sendBroadcastMessage; ---------------------- -- sendErrorMessage -- ---------------------- procedure sendErrorMessage (This : in out Assignment_Tree_Branch_Bound_Mailbox; Error_String : Unbounded_String) is KVP : KeyValuePair := (Key => To_Unbounded_String ("No UniqueAutomationResponse"), Value => Error_String); Message : ServiceStatus; begin Message.StatusType := Error; Message.Info := Add (Message.Info, KVP); This.Unique_Entity_Send_Message_Id := This.Unique_Entity_Send_Message_Id + 1; This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (As_Object_Any (Message)); end sendErrorMessage; end Assignment_Tree_Branch_Bound_Communication;
godunko/adawebpack
Ada
3,232
ads
------------------------------------------------------------------------------ -- -- -- AdaWebPack -- -- -- ------------------------------------------------------------------------------ -- Copyright © 2022, Vadim Godunko -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- ------------------------------------------------------------------------------ -- Helper subprograms to create objects at JavaScript side. with WASM.Classes; with Web.Strings; package WASM.Objects.Constructors is pragma Preelaborate; function New_Object (Class : WASM.Classes.Class_Index) return WASM.Objects.Object_Identifier; function New_Object_String (Class : WASM.Classes.Class_Index; Parameter : Web.Strings.Web_String) return WASM.Objects.Object_Identifier; end WASM.Objects.Constructors;
brock7/TianLong
Ada
15,762
ads
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- with Interfaces.C.Strings; with System; private package ZLib.Thin is -- From zconf.h MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 -- zconf.h:105 MAX_WBITS : constant := 15; -- zconf.h:115 -- 32K LZ77 window -- zconf.h:115 SEEK_SET : constant := 8#0000#; -- zconf.h:244 -- Seek from beginning of file. -- zconf.h:244 SEEK_CUR : constant := 1; -- zconf.h:245 -- Seek from current position. -- zconf.h:245 SEEK_END : constant := 2; -- zconf.h:246 -- Set file pointer to EOF plus "offset" -- zconf.h:246 type Byte is new Interfaces.C.unsigned_char; -- 8 bits -- zconf.h:214 type UInt is new Interfaces.C.unsigned; -- 16 bits or more -- zconf.h:216 type Int is new Interfaces.C.int; type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more -- zconf.h:217 subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; type ULong_Access is access ULong; type Int_Access is access Int; subtype Voidp is System.Address; -- zconf.h:232 subtype Byte_Access is Voidp; Nul : constant Voidp := System.Null_Address; -- end from zconf Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 -- zlib.h:125 Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 -- will be removed, use -- Z_SYNC_FLUSH instead -- zlib.h:126 Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 -- zlib.h:127 Z_FULL_FLUSH : constant := 3; -- zlib.h:128 -- zlib.h:128 Z_FINISH : constant := 4; -- zlib.h:129 -- zlib.h:129 Z_OK : constant := 8#0000#; -- zlib.h:132 -- zlib.h:132 Z_STREAM_END : constant := 1; -- zlib.h:133 -- zlib.h:133 Z_NEED_DICT : constant := 2; -- zlib.h:134 -- zlib.h:134 Z_ERRNO : constant := -1; -- zlib.h:135 -- zlib.h:135 Z_STREAM_ERROR : constant := -2; -- zlib.h:136 -- zlib.h:136 Z_DATA_ERROR : constant := -3; -- zlib.h:137 -- zlib.h:137 Z_MEM_ERROR : constant := -4; -- zlib.h:138 -- zlib.h:138 Z_BUF_ERROR : constant := -5; -- zlib.h:139 -- zlib.h:139 Z_VERSION_ERROR : constant := -6; -- zlib.h:140 -- zlib.h:140 Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 -- zlib.h:145 Z_BEST_SPEED : constant := 1; -- zlib.h:146 -- zlib.h:146 Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 -- zlib.h:147 Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 -- zlib.h:148 Z_FILTERED : constant := 1; -- zlib.h:151 -- zlib.h:151 Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 -- zlib.h:152 Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 -- zlib.h:153 Z_BINARY : constant := 8#0000#; -- zlib.h:156 -- zlib.h:156 Z_ASCII : constant := 1; -- zlib.h:157 -- zlib.h:157 Z_UNKNOWN : constant := 2; -- zlib.h:158 -- zlib.h:158 Z_DEFLATED : constant := 8; -- zlib.h:161 -- zlib.h:161 Z_NULL : constant := 8#0000#; -- zlib.h:164 -- for initializing zalloc, zfree, opaque -- zlib.h:164 type gzFile is new Voidp; -- zlib.h:646 type Z_Stream is private; type Z_Streamp is access all Z_Stream; -- zlib.h:89 type alloc_func is access function (Opaque : Voidp; Items : UInt; Size : UInt) return Voidp; -- zlib.h:63 type free_func is access procedure (opaque : Voidp; address : Voidp); function zlibVersion return Chars_Ptr; function Deflate (strm : Z_Streamp; flush : Int) return Int; function DeflateEnd (strm : Z_Streamp) return Int; function Inflate (strm : Z_Streamp; flush : Int) return Int; function InflateEnd (strm : Z_Streamp) return Int; function deflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; -- zlib.h:478 function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 function deflateParams (strm : Z_Streamp; level : Int; strategy : Int) return Int; -- zlib.h:506 function inflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; -- zlib.h:548 function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 function compress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; -- zlib.h:601 function compress2 (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong; level : Int) return Int; -- zlib.h:615 function uncompress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; function gzsetparams (file : gzFile; level : Int; strategy : Int) return Int; function gzread (file : gzFile; buf : Voidp; len : UInt) return Int; function gzwrite (file : in gzFile; buf : in Voidp; len : in UInt) return Int; function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; function gzgets (file : gzFile; buf : Chars_Ptr; len : Int) return Chars_Ptr; function gzputc (file : gzFile; char : Int) return Int; function gzgetc (file : gzFile) return Int; function gzflush (file : gzFile; flush : Int) return Int; function gzseek (file : gzFile; offset : Int; whence : Int) return Int; function gzrewind (file : gzFile) return Int; function gztell (file : gzFile) return Int; function gzeof (file : gzFile) return Int; function gzclose (file : gzFile) return Int; function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; function adler32 (adler : ULong; buf : Byte_Access; len : UInt) return ULong; function crc32 (crc : ULong; buf : Byte_Access; len : UInt) return ULong; function deflateInit (strm : Z_Streamp; level : Int; version : Chars_Ptr; stream_size : Int) return Int; function deflateInit2 (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int; version : Chars_Ptr; stream_size : Int) return Int; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int; pragma Inline (Deflate_Init); function inflateInit (strm : Z_Streamp; version : Chars_Ptr; stream_size : Int) return Int; function inflateInit2 (strm : in Z_Streamp; windowBits : in Int; version : in Chars_Ptr; stream_size : in Int) return Int; function inflateBackInit (strm : in Z_Streamp; windowBits : in Int; window : in Byte_Access; version : in Chars_Ptr; stream_size : in Int) return Int; -- Size of window have to be 2**windowBits. function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; pragma Inline (Inflate_Init); function zError (err : Int) return Chars_Ptr; function inflateSyncPoint (z : Z_Streamp) return Int; function get_crc_table return ULong_Access; -- Interface to the available fields of the z_stream structure. -- The application must update next_in and avail_in when avail_in has -- dropped to zero. It must update next_out and avail_out when avail_out -- has dropped to zero. The application must initialize zalloc, zfree and -- opaque before calling the init function. procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_In); procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_Out); procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func); pragma Inline (Set_Mem_Func); function Last_Error_Message (Strm : in Z_Stream) return String; pragma Inline (Last_Error_Message); function Avail_Out (Strm : in Z_Stream) return UInt; pragma Inline (Avail_Out); function Avail_In (Strm : in Z_Stream) return UInt; pragma Inline (Avail_In); function Total_In (Strm : in Z_Stream) return ULong; pragma Inline (Total_In); function Total_Out (Strm : in Z_Stream) return ULong; pragma Inline (Total_Out); function inflateCopy (dest : in Z_Streamp; Source : in Z_Streamp) return Int; function compressBound (Source_Len : in ULong) return ULong; function deflateBound (Strm : in Z_Streamp; Source_Len : in ULong) return ULong; function gzungetc (C : in Int; File : in gzFile) return Int; function zlibCompileFlags return ULong; private type Z_Stream is record -- zlib.h:68 Next_In : Voidp := Nul; -- next input byte Avail_In : UInt := 0; -- number of bytes available at next_in Total_In : ULong := 0; -- total nb of input bytes read so far Next_Out : Voidp := Nul; -- next output byte should be put there Avail_Out : UInt := 0; -- remaining free space at next_out Total_Out : ULong := 0; -- total nb of bytes output so far msg : Chars_Ptr; -- last error message, NULL if no error state : Voidp; -- not visible by applications zalloc : alloc_func := null; -- used to allocate the internal state zfree : free_func := null; -- used to free the internal state opaque : Voidp; -- private data object passed to -- zalloc and zfree data_type : Int; -- best guess about the data type: -- ascii or binary adler : ULong; -- adler32 value of the uncompressed -- data reserved : ULong; -- reserved for future use end record; pragma Convention (C, Z_Stream); pragma Import (C, zlibVersion, "zlibVersion"); pragma Import (C, Deflate, "deflate"); pragma Import (C, DeflateEnd, "deflateEnd"); pragma Import (C, Inflate, "inflate"); pragma Import (C, InflateEnd, "inflateEnd"); pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); pragma Import (C, deflateCopy, "deflateCopy"); pragma Import (C, deflateReset, "deflateReset"); pragma Import (C, deflateParams, "deflateParams"); pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); pragma Import (C, inflateSync, "inflateSync"); pragma Import (C, inflateReset, "inflateReset"); pragma Import (C, compress, "compress"); pragma Import (C, compress2, "compress2"); pragma Import (C, uncompress, "uncompress"); pragma Import (C, gzopen, "gzopen"); pragma Import (C, gzdopen, "gzdopen"); pragma Import (C, gzsetparams, "gzsetparams"); pragma Import (C, gzread, "gzread"); pragma Import (C, gzwrite, "gzwrite"); pragma Import (C, gzprintf, "gzprintf"); pragma Import (C, gzputs, "gzputs"); pragma Import (C, gzgets, "gzgets"); pragma Import (C, gzputc, "gzputc"); pragma Import (C, gzgetc, "gzgetc"); pragma Import (C, gzflush, "gzflush"); pragma Import (C, gzseek, "gzseek"); pragma Import (C, gzrewind, "gzrewind"); pragma Import (C, gztell, "gztell"); pragma Import (C, gzeof, "gzeof"); pragma Import (C, gzclose, "gzclose"); pragma Import (C, gzerror, "gzerror"); pragma Import (C, adler32, "adler32"); pragma Import (C, crc32, "crc32"); pragma Import (C, deflateInit, "deflateInit_"); pragma Import (C, inflateInit, "inflateInit_"); pragma Import (C, deflateInit2, "deflateInit2_"); pragma Import (C, inflateInit2, "inflateInit2_"); pragma Import (C, zError, "zError"); pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); pragma Import (C, get_crc_table, "get_crc_table"); -- since zlib 1.2.0: pragma Import (C, inflateCopy, "inflateCopy"); pragma Import (C, compressBound, "compressBound"); pragma Import (C, deflateBound, "deflateBound"); pragma Import (C, gzungetc, "gzungetc"); pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); pragma Import (C, inflateBackInit, "inflateBackInit_"); -- I stopped binding the inflateBack routines, becouse realize that -- it does not support zlib and gzip headers for now, and have no -- symmetric deflateBack routines. -- ZLib-Ada is symmetric regarding deflate/inflate data transformation -- and has a similar generic callback interface for the -- deflate/inflate transformation based on the regular Deflate/Inflate -- routines. -- pragma Import (C, inflateBack, "inflateBack"); -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); end ZLib.Thin;
AdaCore/libadalang
Ada
108
adb
package body Pkg is procedure Foo (X : Integer) is null; procedure Foo (X : String) is null; end Pkg;
charlie5/aIDE
Ada
6,778
adb
with AdaM.Declaration.of_exception, AdaM.Assist, aIDE.Editor.of_block, aIDE.GUI, Glib, glib.Error, gtk.Builder, gtk.Handlers, ada.unchecked_Deallocation; with Ada.Text_IO; use Ada.Text_IO; package body aIDE.Editor.of_exception_handler is use Glib, glib.Error, gtk.Builder; type editor_slot_Pair is record Editor : aIDE.editor.of_exception_handler.view; Slot : Positive; end record; package Button_user_Handler is new Gtk.Handlers.user_Callback (Gtk_Button_Record, editor_slot_Pair); procedure on_rid_Button_clicked (the_Button : access Gtk_Button_Record'Class; Pair : in editor_slot_Pair) is pragma Unreferenced (the_Button); the_Editor : editor.of_exception_handler.view := Pair.Editor; begin the_Editor.exception_Handler.destruct; free (the_Editor); end on_rid_Button_clicked; procedure On_Clicked (the_Button : access Gtk_Button_Record'Class; Pair : in editor_slot_Pair) is -- use gtk.Button; begin aIDE.GUI.show_exceptions_Palette (Invoked_by => gtk_Button (the_Button), Target => Pair.Editor.exception_Handler, Slot => Pair.Slot); end On_Clicked; package Label_user_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Label_Record, Boolean, Editor.of_exception_handler.view); function on_when_Label_clicked (the_Label : access Gtk.Label.Gtk_Label_Record'Class; Self : in Editor.of_exception_handler.view) return Boolean is pragma Unreferenced (the_Label); function next_free_Slot return Natural is begin for i in 1 .. Self.exception_Handler.exception_Count loop if Self.exception_Handler.is_Free (i) then return i; end if; end loop; return 0; end next_free_Slot; Slot : constant Natural := next_free_Slot; default_Exception : constant AdaM.Declaration.of_exception.view := aIDE.the_entity_Environ.find ("Constraint_Error"); begin if Slot = 0 then Self.exception_Handler.add_Exception (default_Exception); Self.add_new_exception_Button (Self.exception_Handler.exception_Count); else Self.exception_Handler.my_Exception_is (Slot, default_Exception); Self.exception_Button (Slot).Show_All; end if; return False; end on_when_Label_clicked; function exception_Button (Self : in Item; Slot : in Positive) return gtk_Button is the_Child : constant Gtk.Widget.gtk_Widget := Self.exception_names_Box.Get_Child (Gint (Slot) - 1); begin return gtk_Button (the_Child); end exception_Button; procedure add_new_exception_Button (Self : access Item; Slot : in Positive) is use Gtk.Widget.Widget_List; use type AdaM.Declaration.of_exception.view; new_Button : gtk_Button; the_Exception : constant AdaM.Declaration.of_exception.view := Self.exception_Handler.my_Exception (slot); begin gtk_New (new_Button); if the_Exception = null then new_Button.Set_Tooltip_Text ("Not yet set."); else new_Button.Set_Tooltip_Text (String (the_Exception.full_Name)); new_Button.Set_Label (String (AdaM.Assist.strip_standard_Prefix (the_Exception.Name))); end if; Self.exception_names_Box.pack_Start (new_Button, expand => True, fill => True); if not Self.exception_Handler.is_Free (Slot) then new_Button.Show; else new_Button.Hide; end if; Button_user_Handler.Connect (new_Button, "clicked", On_Clicked'Access, (View (Self), Slot)); end add_new_exception_Button; -- Forge -- function new_Editor (the_Handler : in AdaM.exception_Handler.view) return View is Self : constant Editor.of_exception_handler.view := new Editor.of_exception_handler.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; pragma Unreferenced (Result); begin Self.exception_Handler := the_Handler; Gtk_New (the_Builder); Result := the_Builder.Add_From_File ("glade/editor/exception_handler_editor.glade", Error'Access); if Error /= null then Error_Free (Error); end if; Self.top_Frame := gtk_Frame (the_Builder.get_Object ("top_Frame")); Self.top_Box := gtk_Box (the_Builder.get_Object ("top_Box")); Self.handler_Alignment := gtk_Alignment (the_Builder.get_Object ("handler_Alignment")); Self.when_Label := gtk_Label (the_Builder.get_Object ("when_Label")); Self.exception_names_Box := gtk_Box (the_Builder.get_Object ("exception_names_Box")); Self.rid_Button := gtk_Button (the_Builder.get_Object ("rid_Button")); Self.block_Editor := aIDE.Editor.of_block.Forge.to_block_Editor (Self.exception_Handler.Handler); Self.block_Editor.top_Widget.reparent (Self.handler_Alignment); for i in 1 .. Self.exception_Handler.exception_Count loop Self.add_new_exception_Button (i); end loop; Label_user_return_Callbacks.Connect (Self.when_Label, "button-release-event", on_when_Label_clicked'Access, Self); Button_user_Handler.Connect (Self.rid_Button, "clicked", on_rid_Button_clicked'Access, (Self, 1)); return Self; end new_Editor; procedure free (the_Handler : in out View) is procedure deallocate is new ada.Unchecked_Deallocation (Item'Class, View); begin the_Handler.top_Frame.destroy; deallocate (the_Handler); end free; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.top_Frame); end top_Widget; end aIDE.Editor.of_exception_handler;
kontena/ruby-packer
Ada
6,932
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Terminfo -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2006,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision: 1.6 $ -- $Date: 2009/12/26 17:38:58 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Unchecked_Conversion; package body Terminal_Interface.Curses.Terminfo is function Is_MinusOne_Pointer (P : chars_ptr) return Boolean; function Is_MinusOne_Pointer (P : chars_ptr) return Boolean is type Weird_Address is new System.Storage_Elements.Integer_Address; Invalid_Pointer : constant Weird_Address := -1; function To_Weird is new Ada.Unchecked_Conversion (Source => chars_ptr, Target => Weird_Address); begin if To_Weird (P) = Invalid_Pointer then return True; else return False; end if; end Is_MinusOne_Pointer; pragma Inline (Is_MinusOne_Pointer); ------------------------------------------------------------------------------ function Get_Flag (Name : String) return Boolean is function tigetflag (id : char_array) return Curses_Bool; pragma Import (C, tigetflag); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); if tigetflag (Txt) = Curses_Bool (Curses_True) then return True; else return False; end if; end Get_Flag; ------------------------------------------------------------------------------ procedure Get_String (Name : String; Value : out Terminfo_String; Result : out Boolean) is function tigetstr (id : char_array) return chars_ptr; pragma Import (C, tigetstr, "tigetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; begin To_C (Name, Txt, Length); Txt2 := tigetstr (Txt); if Txt2 = Null_Ptr then Result := False; elsif Is_MinusOne_Pointer (Txt2) then raise Curses_Exception; else Value := Terminfo_String (Fill_String (Txt2)); Result := True; end if; end Get_String; ------------------------------------------------------------------------------ function Has_String (Name : String) return Boolean is function tigetstr (id : char_array) return chars_ptr; pragma Import (C, tigetstr, "tigetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; begin To_C (Name, Txt, Length); Txt2 := tigetstr (Txt); if Txt2 = Null_Ptr then return False; elsif Is_MinusOne_Pointer (Txt2) then raise Curses_Exception; else return True; end if; end Has_String; ------------------------------------------------------------------------------ function Get_Number (Name : String) return Integer is function tigetstr (s : char_array) return C_Int; pragma Import (C, tigetstr); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); return Integer (tigetstr (Txt)); end Get_Number; ------------------------------------------------------------------------------ procedure Put_String (Str : Terminfo_String; affcnt : Natural := 1; putc : putctype := null) is function tputs (str : char_array; affcnt : C_Int; putc : putctype) return C_Int; function putp (str : char_array) return C_Int; pragma Import (C, tputs); pragma Import (C, putp); Txt : char_array (0 .. Str'Length); Length : size_t; Err : C_Int; begin To_C (String (Str), Txt, Length); if putc = null then Err := putp (Txt); else Err := tputs (Txt, C_Int (affcnt), putc); end if; if Err = Curses_Err then raise Curses_Exception; end if; end Put_String; end Terminal_Interface.Curses.Terminfo;
pvrego/adaino
Ada
615
adb
with AVR; with AVR.MCU; with AVR.WATCHDOG; with AVR.USART; with AVR.TWI; with AVR.TIMERS; with AVR.TIMERS.CLOCK; with AVR.TIMERS.SCHEDULER; with AVR.PWM_SIMPLEST; with AVR.INTERRUPTS; pragma Unreferenced (AVR.MCU, AVR.WATCHDOG, AVR.USART, AVR.TWI, AVR.TIMERS, AVR.TIMERS.CLOCK, AVR.TIMERS.SCHEDULER, AVR.PWM_SIMPLEST, AVR.INTERRUPTS); procedure Main is Counter : Integer := 0; Map : Integer := 0; begin for Index in 1 .. 1000 loop Counter := Counter + 1; for Index_Map in 1 .. 1000 loop Map := Map + Counter + 1; end loop; end loop; end Main;
charlie5/cBound
Ada
1,478
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_query_objectiv_arb_cookie_t is -- Item -- type Item is record sequence : aliased Interfaces.C.unsigned; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_query_objectiv_arb_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_query_objectiv_arb_cookie_t.Item, Element_Array => xcb.xcb_glx_get_query_objectiv_arb_cookie_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_query_objectiv_arb_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_query_objectiv_arb_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_query_objectiv_arb_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_query_objectiv_arb_cookie_t;
reznikmm/matreshka
Ada
4,033
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Text_Path_Mode_Attributes; package Matreshka.ODF_Draw.Text_Path_Mode_Attributes is type Draw_Text_Path_Mode_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Text_Path_Mode_Attributes.ODF_Draw_Text_Path_Mode_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Text_Path_Mode_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Text_Path_Mode_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Text_Path_Mode_Attributes;
godunko/cga
Ada
1,368
ads
-- -- Copyright (C) 2023, Vadim Godunko <[email protected]> -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -- Direction - unit vector in the 3D space. limited with CGK.Primitives.Vectors_3D; with CGK.Primitives.XYZs; with CGK.Reals; package CGK.Primitives.Directions_3D is pragma Pure; type Direction_3D is private; function X (Self : Direction_3D) return CGK.Reals.Real with Inline; -- Returns X coordinate. function Y (Self : Direction_3D) return CGK.Reals.Real with Inline; -- Returns Y coordinate. function Z (Self : Direction_3D) return CGK.Reals.Real with Inline; -- Returns Z coordinate. function XYZ (Self : Direction_3D) return CGK.Primitives.XYZs.XYZ with Inline; -- Returns XYZ triplet coordinate. function As_Vector_3D (Self : Direction_3D) return CGK.Primitives.Vectors_3D.Vector_3D with Inline; -- Convert Direction_3D to Vector_3D. private type Direction_3D is record Coordinates : CGK.Primitives.XYZs.XYZ := CGK.Primitives.XYZs.Create_XYZ (1.0, 0.0, 0.0); end record; procedure Unchecked_Set (Self : out Direction_3D; X : CGK.Reals.Real; Y : CGK.Reals.Real; Z : CGK.Reals.Real); -- Sets components of the Direction_3D object. No checks or normalization -- done. end CGK.Primitives.Directions_3D;
zhmu/ananas
Ada
32,933
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ E V A L -- -- -- -- 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. 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains various subprograms involved in compile time -- evaluation of expressions and checks for staticness of expressions and -- types. It also contains the circuitry for checking for violations of pure -- and preelaborated conditions (this naturally goes here, since these rules -- involve consideration of staticness). -- Note: the static evaluation for attributes is found in Sem_Attr even though -- logically it belongs here. We have done this so that it is easier to add -- new attributes to GNAT. with Types; use Types; with Uintp; use Uintp; with Urealp; use Urealp; package Sem_Eval is ------------------------------------ -- Handling of Static Expressions -- ------------------------------------ -- This package contains a set of routines that process individual -- subexpression nodes with the objective of folding (precomputing) the -- value of static expressions that are known at compile time and properly -- computing the setting of two flags that appear in every subexpression -- node: -- Is_Static_Expression -- True for static expressions, as defined in RM-4.9. -- Raises_Constraint_Error -- This flag indicates that it is known at compile time that the -- evaluation of an expression raises constraint error. If the -- expression is static, and this flag is off, then it is also known at -- compile time that the expression does not raise constraint error -- (i.e. the flag is accurate for static expressions, and conservative -- for non-static expressions. -- See also Is_OK_Static_Expression, which is True for static -- expressions that do not raise Constraint_Error. This is used in most -- legality checks, because static expressions that raise Constraint_Error -- are usually illegal. -- See also Compile_Time_Known_Value, which is True for an expression whose -- value is known at compile time. In this case, the expression is folded -- to a literal or to a constant that is itself (recursively) either a -- literal or a constant -- Is_[OK_]Static_Expression are used for legality checks, whereas -- Compile_Time_Known_Value is used for optimization purposes. -- When we are analyzing and evaluating static expressions, we propagate -- both flags. Usually if a subexpression raises a Constraint_Error, then -- so will its parent expression, and Raise_Constraint_Error will be -- propagated to this parent. The exception is conditional cases like -- (True or else 1/0 = 0), which results in an expression that has the -- Is_Static_Expression flag True, and Raises_Constraint_Error False. Even -- though 1/0 would raise an exception, the right operand is never actually -- executed, so the expression as a whole does not raise CE. -- Finally, the case of static predicates. These are applied only to entire -- expressions, not to subexpressions, so we do not have the case of having -- to propagate this information. We handle this case simply by resetting -- the Is_Static_Expression flag if a static predicate fails. Note that we -- can't use this simpler approach for the constraint error case because of -- the (True or else 1/0 = 0) example discussed above. ------------------------------- -- Compile-Time Known Values -- ------------------------------- -- For most legality checking purposes the flag Is_Static_Expression -- defined in Sinfo should be used. This package also provides a routine -- called Is_OK_Static_Expression which in addition of checking that an -- expression is static in the RM 4.9 sense, it checks that the expression -- does not raise constraint error. In fact for certain legality checks not -- only do we need to ascertain that the expression is static, but we must -- also ensure that it does not raise constraint error. -- Neither of Is_Static_Expression and Is_OK_Static_Expression should be -- used for compile time evaluation purposes. In fact certain expression -- whose value may be known at compile time are not static in the RM 4.9 -- sense. A typical example is: -- C : constant Integer := Record_Type'Size; -- The expression 'C' is not static in the technical RM sense, but for many -- simple record types, the size is in fact known at compile time. When we -- are trying to perform compile time constant folding (for instance for -- expressions like C + 1), Is_Static_Expression or Is_OK_Static_Expression -- are not the right functions to test if folding is possible. Instead, we -- use Compile_Time_Known_Value. All static expressions that do not raise -- constraint error (i.e. those for which Is_OK_Static_Expression is true) -- are known at compile time, but as shown by the above example, there may -- be cases of non-static expressions which are known at compile time. ----------------- -- Subprograms -- ----------------- procedure Check_Expression_Against_Static_Predicate (Expr : Node_Id; Typ : Entity_Id; Static_Failure_Is_Error : Boolean := False); -- Determine whether an arbitrary expression satisfies the static predicate -- of a type. The routine does nothing if Expr is not known at compile time -- or Typ lacks a static predicate; otherwise it may emit a warning if the -- expression is prohibited by the predicate, or if Static_Failure_Is_Error -- is True then an error will be flagged. If the expression is a static -- expression, it fails a predicate that was not explicitly stated to be -- a dynamic predicate, and Static_Failure_Is_Error is False, then an -- additional warning is given, and the flag Is_Static_Expression is reset -- on Expr. procedure Check_Non_Static_Context (N : Node_Id); -- Deals with the special check required for a static expression that -- appears in a non-static context, i.e. is not part of a larger static -- expression (see RM 4.9(35)), i.e. the value of the expression must be -- within the base range of the base type of its expected type. A check is -- also made for expressions that are inside the base range, but outside -- the range of the expected subtype (this is a warning message rather than -- an illegality). -- -- Note: most cases of non-static context checks are handled within -- Sem_Eval itself, including all cases of expressions at the outer level -- (i.e. those that are not a subexpression). The outside customers for -- this procedure are Sem_Aggr, Sem_Attr (because Eval_Attribute is there) -- and Sem_Res (for a special case arising from ranges, see Resolve_Range). -- -- Note: this procedure is also called by GNATprove on real literals -- that are not sub-expressions of static expressions, to convert them to -- machine numbers, as GNATprove cannot perform this conversion contrary -- to gigi. procedure Check_String_Literal_Length (N : Node_Id; Ttype : Entity_Id); -- N is either a string literal, or a constraint error node. In the latter -- case, the situation is already dealt with, and the call has no effect. -- In the former case, if the target type, Ttyp is constrained, then a -- check is made to see if the string literal is of appropriate length. function Checking_Potentially_Static_Expression return Boolean; -- Returns True if the checking for potentially static expressions is -- enabled; otherwise returns False. procedure Set_Checking_Potentially_Static_Expression (Value : Boolean); -- Enables checking for potentially static expressions if Value is True, -- and disables such checking if Value is False. type Compare_Result is (LT, LE, EQ, GT, GE, NE, Unknown); subtype Compare_GE is Compare_Result range EQ .. GE; subtype Compare_LE is Compare_Result range LT .. EQ; -- Result subtypes for Compile_Time_Compare subprograms function Compile_Time_Compare (L, R : Node_Id; Assume_Valid : Boolean) return Compare_Result; pragma Inline (Compile_Time_Compare); -- Given two expression nodes, finds out whether it can be determined at -- compile time how the runtime values will compare. An Unknown result -- means that the result of a comparison cannot be determined at compile -- time, otherwise the returned result indicates the known result of the -- comparison, given as tightly as possible (i.e. EQ or LT is preferred -- returned value to LE). If Assume_Valid is true, the result reflects -- the result of assuming that entities involved in the comparison have -- valid representations. If Assume_Valid is false, then the base type of -- any involved entity is used so that no assumption of validity is made. function Compile_Time_Compare (L, R : Node_Id; Diff : access Uint; Assume_Valid : Boolean; Rec : Boolean := False) return Compare_Result; -- This version of Compile_Time_Compare returns extra information if the -- result is GT or LT. In these cases, if the magnitude of the difference -- can be determined at compile time, this (positive) magnitude is returned -- in Diff.all. If the magnitude of the difference cannot be determined -- then Diff.all contains No_Uint on return. Rec is a parameter that is set -- True for a recursive call from within Compile_Time_Compare to avoid some -- infinite recursion cases. It should never be set by a client. function Compile_Time_Known_Bounds (T : Entity_Id) return Boolean; -- If T is an array whose index bounds are all known at compile time, then -- True is returned. If T is not an array type, or one or more of its index -- bounds is not known at compile time, then False is returned. function Compile_Time_Known_Value (Op : Node_Id) return Boolean; -- Returns true if Op is an expression not raising Constraint_Error whose -- value is known at compile time and for which a call to Expr_Value can -- be used to determine this value. This is always true if Op is a static -- expression, but can also be true for expressions which are technically -- non-static but which are in fact known at compile time. Some examples of -- such expressions are the static lower bound of a non-static range or the -- value of a constant object whose initial value is itself compile time -- known in the sense of this routine. Note that this routine is defended -- against unanalyzed expressions. Such expressions will not cause a -- blowup, they may cause pessimistic (i.e. False) results to be returned. -- In general we take a pessimistic view. False does not mean the value -- could not be known at compile time, but True means that absolutely -- definition it is known at compile time and it is safe to call -- Expr_Value[_XX] on the expression Op. -- -- Note that we don't define precisely the set of expressions that return -- True. Callers should not make any assumptions regarding the value that -- is returned for non-static expressions. Functional behavior should never -- be affected by whether a given non-static expression returns True or -- False when this function is called. In other words this is purely for -- efficiency optimization purposes. The code generated can often be more -- efficient with compile time known values, e.g. range analysis for the -- purpose of removing checks is more effective if we know precise bounds. -- WARNING: There is a matching C declaration of this subprogram in fe.h function CRT_Safe_Compile_Time_Known_Value (Op : Node_Id) return Boolean; -- In the case of configurable run-times, there may be an issue calling -- Compile_Time_Known_Value with non-static expressions where the legality -- of the program is not well-defined. Consider this example: -- -- X := B ** C; -- -- Now if C is compile time known, and has the value 4, then inline code -- can be generated at compile time, instead of calling a run-time routine. -- That's fine in the normal case, but when we have a configurable run-time -- the run-time routine may not be available. This means that the program -- will be rejected if C is not known at compile time. We don't want the -- legality of a program to depend on how clever the implementation of this -- function is. If the run-time in use lacks the exponentiation routine, -- then what we say is that exponentiation is permitted if the exponent is -- officially static and has a value in the range 0 .. 4. -- -- In a case like this, we use CRT_Safe_Compile_Time_Known_Value to avoid -- this effect. This routine will return False for a non-static expression -- if we are in configurable run-time mode, even if the expression would -- normally be considered compile-time known. function Expr_Rep_Value (N : Node_Id) return Uint; -- This is identical to Expr_Value, except in the case of enumeration -- literals of types for which an enumeration representation clause has -- been given, in which case it returns the representation value rather -- than the pos value. This is the value that is needed for generating code -- sequences, while the Expr_Value value is appropriate for compile time -- constraint errors or getting the logical value. Note that this function -- does NOT concern itself with biased values, if the caller needs a -- properly biased value, the subtraction of the bias must be handled -- explicitly. function Expr_Value (N : Node_Id) return Uint; -- Returns the folded value of the expression N. This function is called in -- instances where it has already been determined that the expression is -- static or its value is compile time known (Compile_Time_Known_Value (N) -- returns True). This version is used for integer values, and enumeration -- or character literals. In the latter two cases, the value returned is -- the Pos value in the relevant enumeration type. It can also be used for -- fixed-point values, in which case it returns the corresponding integer -- value, but it cannot be used for floating-point values. Finally, it can -- also be used for the Null access value, as well as for the result of an -- unchecked conversion of the aforementioned handled values. function Expr_Value_E (N : Node_Id) return Entity_Id; -- Returns the folded value of the expression. This function is called in -- instances where it has already been determined that the expression is -- static or its value known at compile time. This version is used for -- enumeration types and returns the corresponding enumeration literal. function Expr_Value_R (N : Node_Id) return Ureal; -- Returns the folded value of the expression. This function is called in -- instances where it has already been determined that the expression is -- static or its value known at compile time. This version is used for real -- values (including both the floating-point and fixed-point cases). In the -- case of a fixed-point type, the real value is returned (cf above version -- returning Uint). function Expr_Value_S (N : Node_Id) return Node_Id; -- Returns the folded value of the expression. This function is called -- in instances where it has already been determined that the expression -- is static or its value is known at compile time. This version is used -- for string types and returns the corresponding N_String_Literal node. procedure Eval_Actual (N : Node_Id); procedure Eval_Allocator (N : Node_Id); procedure Eval_Arithmetic_Op (N : Node_Id); procedure Eval_Call (N : Node_Id); procedure Eval_Case_Expression (N : Node_Id); procedure Eval_Character_Literal (N : Node_Id); procedure Eval_Concatenation (N : Node_Id); procedure Eval_Entity_Name (N : Node_Id); procedure Eval_If_Expression (N : Node_Id); procedure Eval_Indexed_Component (N : Node_Id); procedure Eval_Integer_Literal (N : Node_Id); procedure Eval_Logical_Op (N : Node_Id); procedure Eval_Membership_Op (N : Node_Id); procedure Eval_Named_Integer (N : Node_Id); procedure Eval_Named_Real (N : Node_Id); procedure Eval_Op_Expon (N : Node_Id); procedure Eval_Op_Not (N : Node_Id); procedure Eval_Real_Literal (N : Node_Id); procedure Eval_Relational_Op (N : Node_Id); procedure Eval_Selected_Component (N : Node_Id); procedure Eval_Shift (N : Node_Id); procedure Eval_Short_Circuit (N : Node_Id); procedure Eval_Slice (N : Node_Id); procedure Eval_String_Literal (N : Node_Id); procedure Eval_Qualified_Expression (N : Node_Id); procedure Eval_Type_Conversion (N : Node_Id); procedure Eval_Unary_Op (N : Node_Id); procedure Eval_Unchecked_Conversion (N : Node_Id); procedure Flag_Non_Static_Expr (Msg : String; Expr : Node_Id); -- This procedure is called after it has been determined that Expr is not -- static when it is required to be. Msg is the text of a message that -- explains the error. This procedure checks if an error is already posted -- on Expr, if so, it does nothing unless All_Errors_Mode is set in which -- case this flag is ignored. Otherwise the given message is posted using -- Error_Msg_F, and then Why_Not_Static is called on Expr to generate -- additional messages. The string given as Msg should end with ! to make -- it an unconditional message, to ensure that if it is posted, the entire -- set of messages is all posted. procedure Fold_Str (N : Node_Id; Val : String_Id; Static : Boolean); -- Rewrite N with a new N_String_Literal node as the result of the compile -- time evaluation of the node N. Val is the resulting string value from -- the folding operation. The Is_Static_Expression flag is set in the -- result node. The result is fully analyzed and resolved. Static indicates -- whether the result should be considered static or not (True = consider -- static). The point here is that normally all string literals are static, -- but if this was the result of some sequence of evaluation where values -- were known at compile time but not static, then the result is not -- static. The call has no effect if Raises_Constraint_Error (N) is True, -- since there is no point in folding if we have an error. procedure Fold_Uint (N : Node_Id; Val : Uint; Static : Boolean); -- Rewrite N with a (N_Integer_Literal, N_Identifier, N_Character_Literal) -- node as the result of the compile time evaluation of the node N. Val is -- the result in the integer case and is the position of the literal in the -- literals list for the enumeration case. Is_Static_Expression is set True -- in the result node. The result is fully analyzed/resolved. Static -- indicates whether the result should be considered static or not (True = -- consider static). The point here is that normally all integer literals -- are static, but if this was the result of some sequence of evaluation -- where values were known at compile time but not static, then the result -- is not static. The call has no effect if Raises_Constraint_Error (N) is -- True, since there is no point in folding if we have an error. procedure Fold_Ureal (N : Node_Id; Val : Ureal; Static : Boolean); -- Rewrite N with a new N_Real_Literal node as the result of the compile -- time evaluation of the node N. Val is the resulting real value from the -- folding operation. The Is_Static_Expression flag is set in the result -- node. The result is fully analyzed and result. Static indicates whether -- the result should be considered static or not (True = consider static). -- The point here is that normally all string literals are static, but if -- this was the result of some sequence of evaluation where values were -- known at compile time but not static, then the result is not static. -- The call has no effect if Raises_Constraint_Error (N) is True, since -- there is no point in folding if we have an error. procedure Fold (N : Node_Id); -- Rewrite N with the relevant value if Compile_Time_Known_Value (N) is -- True, otherwise a no-op. function Is_In_Range (N : Node_Id; Typ : Entity_Id; Assume_Valid : Boolean := False; Fixed_Int : Boolean := False; Int_Real : Boolean := False) return Boolean; -- Returns True if it can be guaranteed at compile time that expression -- N is known to be in range of the subtype Typ. A result of False does -- not mean that the expression is out of range, merely that it cannot be -- determined at compile time that it is in range. If Typ is a floating -- point type or Int_Real is set, any integer value is treated as though it -- was a real value (i.e. the underlying real value is used). In this case -- we use the corresponding real value, both for the bounds of Typ, and for -- the value of the expression N. If Typ is a fixed type or a discrete type -- and Int_Real is False but flag Fixed_Int is True then any fixed-point -- value is treated as though it was discrete value (i.e. the underlying -- integer value is used). In this case we use the corresponding integer -- value, both for the bounds of Typ, and for the value of the expression -- N. If Typ is a discrete type and Fixed_Int as well as Int_Real are -- false, integer values are used throughout. -- -- If Assume_Valid is set True, then N is always assumed to contain a valid -- value. If Assume_Valid is set False, then N may be invalid (unless there -- is some independent way of knowing that it is valid, i.e. either it is -- an entity with Is_Known_Valid set, or Assume_No_Invalid_Values is True. function Is_Null_Range (Lo : Node_Id; Hi : Node_Id) return Boolean; -- Returns True if it can guarantee that Lo .. Hi is a null range. If it -- cannot (because the value of Lo or Hi is not known at compile time) then -- it returns False. function Is_OK_Static_Expression (N : Node_Id) return Boolean; -- An OK static expression is one that is static in the RM definition sense -- and which does not raise constraint error. For most legality checking -- purposes you should use Is_Static_Expression. For those legality checks -- where the expression N should not raise constraint error use this -- routine. This routine is *not* to be used in contexts where the test is -- for compile time evaluation purposes. Use Compile_Time_Known_Value -- instead (see section on "Compile-Time Known Values" above). function Is_OK_Static_Range (N : Node_Id) return Boolean; -- Determines if range is static, as defined in RM 4.9(26), and also checks -- that neither bound of the range raises constraint error, thus ensuring -- that both bounds of the range are compile-time evaluable (i.e. do not -- raise constraint error). A result of true means that the bounds are -- compile time evaluable. A result of false means they are not (either -- because the range is not static, or because one or the other bound -- raises CE). function Is_OK_Static_Subtype (Typ : Entity_Id) return Boolean; -- Determines whether a subtype fits the definition of an Ada static -- subtype as given in (RM 4.9(26)) with the additional check that neither -- bound raises constraint error (meaning that Expr_Value[_R|S] can be used -- on these bounds). -- -- This differs from Is_Static_Subtype in that it includes the constraint -- error checks, which are missing from Is_Static_Subtype. function Is_Out_Of_Range (N : Node_Id; Typ : Entity_Id; Assume_Valid : Boolean := False; Fixed_Int : Boolean := False; Int_Real : Boolean := False) return Boolean; -- Returns True if it can be guaranteed at compile time that expression is -- known to be out of range of the subtype Typ. True is returned if Typ is -- a scalar type, and the value of N can be determined to be outside the -- range of Typ. A result of False does not mean that the expression is in -- range, but rather merely that it cannot be determined at compile time -- that it is out of range. The parameters Assume_Valid, Fixed_Int, and -- Int_Real are as described for Is_In_Range above. function Is_Static_Subtype (Typ : Entity_Id) return Boolean; -- Determines whether a subtype fits the definition of an Ada static -- subtype as given in (RM 4.9(26)). -- -- This differs from Is_OK_Static_Subtype (which is what must be used by -- clients) in that it does not care whether the bounds raise a constraint -- error exception or not. Used for checking whether expressions are static -- in the 4.9 sense (without worrying about exceptions). function Is_Statically_Unevaluated (Expr : Node_Id) return Boolean; -- This function returns True if the given expression Expr is statically -- unevaluated, as defined in (RM 4.9 (32.1-32.6)). function In_Subrange_Of (T1 : Entity_Id; T2 : Entity_Id; Fixed_Int : Boolean := False) return Boolean; -- Returns True if it can be guaranteed at compile time that the range of -- values for scalar type T1 are always in the range of scalar type T2. A -- result of False does not mean that T1 is not in T2's subrange, only that -- it cannot be determined at compile time. Flag Fixed_Int is used as in -- routine Is_In_Range above. function Machine_Number (Typ : Entity_Id; Val : Ureal; N : Node_Id) return Ureal; -- Return the machine number of Typ corresponding to the specified Val as -- per RM 4.9(38/2). N is a node only used to post warnings. function Not_Null_Range (Lo : Node_Id; Hi : Node_Id) return Boolean; -- Returns True if it can guarantee that Lo .. Hi is not a null range. If -- it cannot (because the value of Lo or Hi is not known at compile time) -- then it returns False. function Predicates_Compatible (T1, T2 : Entity_Id) return Boolean; -- In Ada 2012, subtypes are statically compatible if the predicates are -- compatible as well. This function performs the required check that -- predicates are compatible. Split from Subtypes_Statically_Compatible -- so that it can be used in specializing error messages. function Predicates_Match (T1, T2 : Entity_Id) return Boolean; -- In Ada 2012, subtypes statically match if their predicates match as -- as well. This function performs the required check that predicates -- match. Separated out from Subtypes_Statically_Match so that it can -- be used in specializing error messages. function Subtypes_Statically_Compatible (T1 : Entity_Id; T2 : Entity_Id; Formal_Derived_Matching : Boolean := False) return Boolean; -- Returns true if the subtypes are unconstrained or the constraint on -- on T1 is statically compatible with T2 (as defined by 4.9.1(4)). -- Otherwise returns false. Formal_Derived_Matching indicates whether -- the type T1 is a generic actual being checked against ancestor T2 -- in a formal derived type association. function Subtypes_Statically_Match (T1 : Entity_Id; T2 : Entity_Id; Formal_Derived_Matching : Boolean := False) return Boolean; -- Determine whether two types T1, T2, which have the same base type, -- are statically matching subtypes (RM 4.9.1(1-2)). Also includes the -- extra GNAT rule that object sizes must match (this can be false for -- types that match in the RM sense because of use of 'Object_Size), -- except when testing a generic actual T1 against an ancestor T2 in a -- formal derived type association (indicated by Formal_Derived_Matching). procedure Test_Comparison (Op : Node_Id; Assume_Valid : Boolean; True_Result : out Boolean; False_Result : out Boolean); -- Determine the outcome of evaluating comparison operator Op using routine -- Compile_Time_Compare. Assume_Valid should be set when the operands are -- to be assumed valid. Flags True_Result and False_Result are set when the -- comparison evaluates to True or False respectively. procedure Why_Not_Static (Expr : Node_Id); -- This procedure may be called after generating an error message that -- complains that something is non-static. If it finds good reasons, it -- generates one or more error messages pointing the appropriate offending -- component of the expression. If no good reasons can be figured out, then -- no messages are generated. The expectation here is that the caller has -- already issued a message complaining that the expression is non-static. -- Note that this message should be placed using Error_Msg_F or -- Error_Msg_FE, so that it will sort before any messages placed by this -- call. Note that it is fine to call Why_Not_Static with something that -- is not an expression, and usually this has no effect, but in some cases -- (N_Parameter_Association or N_Range), it makes sense for the internal -- recursive calls. -- -- Note that these messages are not continuation messages, instead they are -- separate unconditional messages, marked with '!'. The reason for this is -- that they can be posted at a different location from the main message as -- documented above ("appropriate offending component"), and continuation -- messages must always point to the same location as the parent message. procedure Initialize; -- Initializes the internal data structures private -- The Eval routines are all marked inline, since they are called once pragma Inline (Eval_Actual); pragma Inline (Eval_Allocator); pragma Inline (Eval_Character_Literal); pragma Inline (Eval_If_Expression); pragma Inline (Eval_Indexed_Component); pragma Inline (Eval_Named_Integer); pragma Inline (Eval_Named_Real); pragma Inline (Eval_Real_Literal); pragma Inline (Eval_Shift); pragma Inline (Eval_Slice); pragma Inline (Eval_String_Literal); pragma Inline (Eval_Unchecked_Conversion); pragma Inline (Is_OK_Static_Expression); pragma Inline (Machine_Number); end Sem_Eval;