id
int64
0
30.9k
extension
stringclasses
1 value
max_stars_count
int64
0
17k
max_stars_repo_name
stringlengths
7
106
max_stars_repo_path
stringlengths
5
136
text
stringlengths
9
1M
29,900
ada
0
djamal2727/Main-Bearing-Analytical-Model
Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_spark.ads
<reponame>djamal2727/Main-Bearing-Analytical-Model ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ S P A R K -- -- -- -- S p e c -- -- -- -- Copyright (C) 2011-2020, 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 implements a light expansion which is used in GNATprove mode. -- Instead of a complete expansion of nodes for code generation, this light -- expansion targets generation of intermediate code for formal verification. -- Expand_SPARK is called directly by Expander.Expand. with Types; use Types; package Exp_SPARK is procedure Expand_SPARK (N : Node_Id); procedure Expand_SPARK_Potential_Renaming (N : Node_Id); -- N must denote an N_Expanded_Name or N_Identifier. If N is a reference to -- a renaming, replace N with the renamed object. end Exp_SPARK;
29,901
ada
0
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/private2_pkg.ads
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/private2_pkg.ads package Private2_Pkg is type Rec2 (D : Natural) is private; private type Rec1 (D : Natural) is null record; type Rec2 (D : Natural) is new Rec1 (D); end Private2_Pkg;
29,902
ada
1
LaudateCorpus1/RosettaCodeData
Task/Sorting-algorithms-Bogosort/Ada/sorting-algorithms-bogosort.ada
<gh_stars>1-10 with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics.Discrete_Random; procedure Test_Bogosort is generic type Ordered is private; type List is array (Positive range <>) of Ordered; with function "<" (L, R : Ordered) return Boolean is <>; procedure Bogosort (Data : in out List); procedure Bogosort (Data : in out List) is function Sorted return Boolean is begin for I in Data'First..Data'Last - 1 loop if not (Data (I) < Data (I + 1)) then return False; end if; end loop; return True; end Sorted; subtype Index is Integer range Data'Range; package Dices is new Ada.Numerics.Discrete_Random (Index); use Dices; Dice : Generator; procedure Shuffle is J : Index; Temp : Ordered; begin for I in Data'Range loop J := Random (Dice); Temp := Data (I); Data (I) := Data (J); Data (J) := Temp; end loop; end Shuffle; begin while not Sorted loop Shuffle; end loop; end Bogosort; type List is array (Positive range <>) of Integer; procedure Integer_Bogosort is new Bogosort (Integer, List); Sequence : List := (7,6,3,9); begin Integer_Bogosort (Sequence); for I in Sequence'Range loop Put (Integer'Image (Sequence (I))); end loop; end Test_Bogosort;
29,903
ada
80
enfoTek/tomato.linksys.e2000.nvram-mod
tools-src/gnu/gcc/gcc/ada/par-ch3.adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . C H 3 -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, 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 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Turn off subprogram body ordering check. Subprograms are in order -- by RM section rather than alphabetical with Sinfo.CN; use Sinfo.CN; separate (Par) package body Ch3 is ----------------------- -- Local Subprograms -- ----------------------- function P_Component_List return Node_Id; function P_Defining_Character_Literal return Node_Id; function P_Delta_Constraint return Node_Id; function P_Derived_Type_Def_Or_Private_Ext_Decl return Node_Id; function P_Digits_Constraint return Node_Id; function P_Discriminant_Association return Node_Id; function P_Enumeration_Literal_Specification return Node_Id; function P_Enumeration_Type_Definition return Node_Id; function P_Fixed_Point_Definition return Node_Id; function P_Floating_Point_Definition return Node_Id; function P_Index_Or_Discriminant_Constraint return Node_Id; function P_Real_Range_Specification_Opt return Node_Id; function P_Subtype_Declaration return Node_Id; function P_Type_Declaration return Node_Id; function P_Modular_Type_Definition return Node_Id; function P_Variant return Node_Id; function P_Variant_Part return Node_Id; procedure P_Declarative_Items (Decls : List_Id; Done : out Boolean; In_Spec : Boolean); -- Scans out a single declarative item, or, in the case of a declaration -- with a list of identifiers, a list of declarations, one for each of -- the identifiers in the list. The declaration or declarations scanned -- are appended to the given list. Done indicates whether or not there -- may be additional declarative items to scan. If Done is True, then -- a decision has been made that there are no more items to scan. If -- Done is False, then there may be additional declarations to scan. -- In_Spec is true if we are scanning a package declaration, and is used -- to generate an appropriate message if a statement is encountered in -- such a context. procedure P_Identifier_Declarations (Decls : List_Id; Done : out Boolean; In_Spec : Boolean); -- Scans out a set of declarations for an identifier or list of -- identifiers, and appends them to the given list. The parameters have -- the same significance as for P_Declarative_Items. procedure Statement_When_Declaration_Expected (Decls : List_Id; Done : out Boolean; In_Spec : Boolean); -- Called when a statement is found at a point where a declaration was -- expected. The parameters are as described for P_Declarative_Items. procedure Set_Declaration_Expected; -- Posts a "declaration expected" error messages at the start of the -- current token, and if this is the first such message issued, saves -- the message id in Missing_Begin_Msg, for possible later replacement. ------------------- -- Init_Expr_Opt -- ------------------- function Init_Expr_Opt (P : Boolean := False) return Node_Id is begin if Token = Tok_Colon_Equal or else Token = Tok_Equal or else Token = Tok_Colon or else Token = Tok_Is then null; -- One other possibility. If we have a literal followed by a semicolon, -- we assume that we have a missing colon-equal. elsif Token in Token_Class_Literal then declare Scan_State : Saved_Scan_State; begin Save_Scan_State (Scan_State); Scan; -- past literal or identifier if Token = Tok_Semicolon then Restore_Scan_State (Scan_State); else Restore_Scan_State (Scan_State); return Empty; end if; end; -- Otherwise we definitely have no initialization expression else return Empty; end if; -- Merge here if we have an initialization expression T_Colon_Equal; if P then return P_Expression; else return P_Expression_No_Right_Paren; end if; end Init_Expr_Opt; ---------------------------- -- 3.1 Basic Declaration -- ---------------------------- -- Parsed by P_Basic_Declarative_Items (3.9) ------------------------------ -- 3.1 Defining Identifier -- ------------------------------ -- DEFINING_IDENTIFIER ::= IDENTIFIER -- Error recovery: can raise Error_Resync function P_Defining_Identifier return Node_Id is Ident_Node : Node_Id; begin -- Scan out the identifier. Note that this code is essentially identical -- to P_Identifier, except that in the call to Scan_Reserved_Identifier -- we set Force_Msg to True, since we want at least one message for each -- separate declaration (but not use) of a reserved identifier. if Token = Tok_Identifier then null; -- If we have a reserved identifier, manufacture an identifier with -- a corresponding name after posting an appropriate error message elsif Is_Reserved_Identifier then Scan_Reserved_Identifier (Force_Msg => True); -- Otherwise we have junk that cannot be interpreted as an identifier else T_Identifier; -- to give message raise Error_Resync; end if; Ident_Node := Token_Node; Scan; -- past the reserved identifier if Ident_Node /= Error then Change_Identifier_To_Defining_Identifier (Ident_Node); end if; return Ident_Node; end P_Defining_Identifier; ----------------------------- -- 3.2.1 Type Declaration -- ----------------------------- -- TYPE_DECLARATION ::= -- FULL_TYPE_DECLARATION -- | INCOMPLETE_TYPE_DECLARATION -- | PRIVATE_TYPE_DECLARATION -- | PRIVATE_EXTENSION_DECLARATION -- FULL_TYPE_DECLARATION ::= -- type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART] is TYPE_DEFINITION; -- | CONCURRENT_TYPE_DECLARATION -- INCOMPLETE_TYPE_DECLARATION ::= -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART]; -- PRIVATE_TYPE_DECLARATION ::= -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART] -- is [abstract] [tagged] [limited] private; -- PRIVATE_EXTENSION_DECLARATION ::= -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART] is -- [abstract] new ancestor_SUBTYPE_INDICATION with private; -- TYPE_DEFINITION ::= -- ENUMERATION_TYPE_DEFINITION | INTEGER_TYPE_DEFINITION -- | REAL_TYPE_DEFINITION | ARRAY_TYPE_DEFINITION -- | RECORD_TYPE_DEFINITION | ACCESS_TYPE_DEFINITION -- | DERIVED_TYPE_DEFINITION -- INTEGER_TYPE_DEFINITION ::= -- SIGNED_INTEGER_TYPE_DEFINITION -- MODULAR_TYPE_DEFINITION -- Error recovery: can raise Error_Resync -- Note: The processing for full type declaration, incomplete type -- declaration, private type declaration and type definition is -- included in this function. The processing for concurrent type -- declarations is NOT here, but rather in chapter 9 (i.e. this -- function handles only declarations starting with TYPE). function P_Type_Declaration return Node_Id is Type_Loc : Source_Ptr; Type_Start_Col : Column_Number; Ident_Node : Node_Id; Decl_Node : Node_Id; Discr_List : List_Id; Unknown_Dis : Boolean; Discr_Sloc : Source_Ptr; Abstract_Present : Boolean; Abstract_Loc : Source_Ptr; End_Labl : Node_Id; Typedef_Node : Node_Id; -- Normally holds type definition, except in the case of a private -- extension declaration, in which case it holds the declaration itself begin Type_Loc := Token_Ptr; Type_Start_Col := Start_Column; T_Type; Ident_Node := P_Defining_Identifier; Discr_Sloc := Token_Ptr; if P_Unknown_Discriminant_Part_Opt then Unknown_Dis := True; Discr_List := No_List; else Unknown_Dis := False; Discr_List := P_Known_Discriminant_Part_Opt; end if; -- Incomplete type declaration. We complete the processing for this -- case here and return the resulting incomplete type declaration node if Token = Tok_Semicolon then Scan; -- past ; Decl_Node := New_Node (N_Incomplete_Type_Declaration, Type_Loc); Set_Defining_Identifier (Decl_Node, Ident_Node); Set_Unknown_Discriminants_Present (Decl_Node, Unknown_Dis); Set_Discriminant_Specifications (Decl_Node, Discr_List); return Decl_Node; else Decl_Node := Empty; end if; -- Full type declaration or private type declaration, must have IS if Token = Tok_Equal then TF_Is; Scan; -- past = used in place of IS elsif Token = Tok_Renames then Error_Msg_SC ("RENAMES should be IS"); Scan; -- past RENAMES used in place of IS else TF_Is; end if; -- First an error check, if we have two identifiers in a row, a likely -- possibility is that the first of the identifiers is an incorrectly -- spelled keyword. if Token = Tok_Identifier then declare SS : Saved_Scan_State; I2 : Boolean; begin Save_Scan_State (SS); Scan; -- past initial identifier I2 := (Token = Tok_Identifier); Restore_Scan_State (SS); if I2 and then (Bad_Spelling_Of (Tok_Abstract) or else Bad_Spelling_Of (Tok_Access) or else Bad_Spelling_Of (Tok_Aliased) or else Bad_Spelling_Of (Tok_Constant)) then null; end if; end; end if; -- Check for misuse of Ada 95 keyword abstract in Ada 83 mode if Token_Name = Name_Abstract then Check_95_Keyword (Tok_Abstract, Tok_Tagged); Check_95_Keyword (Tok_Abstract, Tok_New); end if; -- Check cases of misuse of ABSTRACT if Token = Tok_Abstract then Abstract_Present := True; Abstract_Loc := Token_Ptr; Scan; -- past ABSTRACT if Token = Tok_Limited or else Token = Tok_Private or else Token = Tok_Record or else Token = Tok_Null then Error_Msg_AP ("TAGGED expected"); end if; else Abstract_Present := False; Abstract_Loc := No_Location; end if; -- Check for misuse of Ada 95 keyword Tagged if Token_Name = Name_Tagged then Check_95_Keyword (Tok_Tagged, Tok_Private); Check_95_Keyword (Tok_Tagged, Tok_Limited); Check_95_Keyword (Tok_Tagged, Tok_Record); end if; -- Special check for misuse of Aliased if Token = Tok_Aliased or else Token_Name = Name_Aliased then Error_Msg_SC ("ALIASED not allowed in type definition"); Scan; -- past ALIASED end if; -- The following procesing deals with either a private type declaration -- or a full type declaration. In the private type case, we build the -- N_Private_Type_Declaration node, setting its Tagged_Present and -- Limited_Present flags, on encountering the Private keyword, and -- leave Typedef_Node set to Empty. For the full type declaration -- case, Typedef_Node gets set to the type definition. Typedef_Node := Empty; -- Switch on token following the IS. The loop normally runs once. It -- only runs more than once if an error is detected, to try again after -- detecting and fixing up the error. loop case Token is when Tok_Access => Typedef_Node := P_Access_Type_Definition; TF_Semicolon; exit; when Tok_Array => Typedef_Node := P_Array_Type_Definition; TF_Semicolon; exit; when Tok_Delta => Typedef_Node := P_Fixed_Point_Definition; TF_Semicolon; exit; when Tok_Digits => Typedef_Node := P_Floating_Point_Definition; TF_Semicolon; exit; when Tok_In => Ignore (Tok_In); when Tok_Integer_Literal => T_Range; Typedef_Node := P_Signed_Integer_Type_Definition; TF_Semicolon; exit; when Tok_Null => Typedef_Node := P_Record_Definition; TF_Semicolon; exit; when Tok_Left_Paren => Typedef_Node := P_Enumeration_Type_Definition; TF_Semicolon; exit; when Tok_Mod => Typedef_Node := P_Modular_Type_Definition; TF_Semicolon; exit; when Tok_New => Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl; TF_Semicolon; exit; when Tok_Range => Typedef_Node := P_Signed_Integer_Type_Definition; TF_Semicolon; exit; when Tok_Record => Typedef_Node := P_Record_Definition; End_Labl := Make_Identifier (Token_Ptr, Chars => Chars (Ident_Node)); Set_Comes_From_Source (End_Labl, False); Set_End_Label (Typedef_Node, End_Labl); TF_Semicolon; exit; when Tok_Tagged => Scan; -- past TAGGED if Token = Tok_Abstract then Error_Msg_SC ("ABSTRACT must come before TAGGED"); Abstract_Present := True; Abstract_Loc := Token_Ptr; Scan; -- past ABSTRACT end if; if Token = Tok_Limited then Scan; -- past LIMITED -- TAGGED LIMITED PRIVATE case if Token = Tok_Private then Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc); Set_Tagged_Present (Decl_Node, True); Set_Limited_Present (Decl_Node, True); Scan; -- past PRIVATE -- TAGGED LIMITED RECORD else Typedef_Node := P_Record_Definition; Set_Tagged_Present (Typedef_Node, True); Set_Limited_Present (Typedef_Node, True); end if; else -- TAGGED PRIVATE if Token = Tok_Private then Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc); Set_Tagged_Present (Decl_Node, True); Scan; -- past PRIVATE -- TAGGED RECORD else Typedef_Node := P_Record_Definition; Set_Tagged_Present (Typedef_Node, True); end if; end if; TF_Semicolon; exit; when Tok_Private => Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc); Scan; -- past PRIVATE TF_Semicolon; exit; when Tok_Limited => Scan; -- past LIMITED loop if Token = Tok_Tagged then Error_Msg_SC ("TAGGED must come before LIMITED"); Scan; -- past TAGGED elsif Token = Tok_Abstract then Error_Msg_SC ("ABSTRACT must come before LIMITED"); Scan; -- past ABSTRACT else exit; end if; end loop; -- LIMITED RECORD or LIMITED NULL RECORD if Token = Tok_Record or else Token = Tok_Null then if Ada_83 then Error_Msg_SP ("(Ada 83) limited record declaration not allowed!"); end if; Typedef_Node := P_Record_Definition; Set_Limited_Present (Typedef_Node, True); -- LIMITED PRIVATE is the only remaining possibility here else Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc); Set_Limited_Present (Decl_Node, True); T_Private; -- past PRIVATE (or complain if not there!) end if; TF_Semicolon; exit; -- Here we have an identifier after the IS, which is certainly -- wrong and which might be one of several different mistakes. when Tok_Identifier => -- First case, if identifier is on same line, then probably we -- have something like "type X is Integer .." and the best -- diagnosis is a missing NEW. Note: the missing new message -- will be posted by P_Derived_Type_Def_Or_Private_Ext_Decl. if not Token_Is_At_Start_Of_Line then Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl; TF_Semicolon; -- If the identifier is at the start of the line, and is in the -- same column as the type declaration itself then we consider -- that we had a missing type definition on the previous line elsif Start_Column <= Type_Start_Col then Error_Msg_AP ("type definition expected"); Typedef_Node := Error; -- If the identifier is at the start of the line, and is in -- a column to the right of the type declaration line, then we -- may have something like: -- type x is -- r : integer -- and the best diagnosis is a missing record keyword else Typedef_Node := P_Record_Definition; TF_Semicolon; end if; exit; -- Anything else is an error when others => if Bad_Spelling_Of (Tok_Access) or else Bad_Spelling_Of (Tok_Array) or else Bad_Spelling_Of (Tok_Delta) or else Bad_Spelling_Of (Tok_Digits) or else Bad_Spelling_Of (Tok_Limited) or else Bad_Spelling_Of (Tok_Private) or else Bad_Spelling_Of (Tok_Range) or else Bad_Spelling_Of (Tok_Record) or else Bad_Spelling_Of (Tok_Tagged) then null; else Error_Msg_AP ("type definition expected"); raise Error_Resync; end if; end case; end loop; -- For the private type declaration case, the private type declaration -- node has been built, with the Tagged_Present and Limited_Present -- flags set as needed, and Typedef_Node is left set to Empty. if No (Typedef_Node) then Set_Unknown_Discriminants_Present (Decl_Node, Unknown_Dis); Set_Abstract_Present (Decl_Node, Abstract_Present); -- For a private extension declaration, Typedef_Node contains the -- N_Private_Extension_Declaration node, which we now complete. Note -- that the private extension declaration, unlike a full type -- declaration, does permit unknown discriminants. elsif Nkind (Typedef_Node) = N_Private_Extension_Declaration then Decl_Node := Typedef_Node; Set_Sloc (Decl_Node, Type_Loc); Set_Unknown_Discriminants_Present (Decl_Node, Unknown_Dis); Set_Abstract_Present (Typedef_Node, Abstract_Present); -- In the full type declaration case, Typedef_Node has the type -- definition and here is where we build the full type declaration -- node. This is also where we check for improper use of an unknown -- discriminant part (not allowed for full type declaration). else if Nkind (Typedef_Node) = N_Record_Definition or else (Nkind (Typedef_Node) = N_Derived_Type_Definition and then Present (Record_Extension_Part (Typedef_Node))) then Set_Abstract_Present (Typedef_Node, Abstract_Present); elsif Abstract_Present then Error_Msg ("ABSTRACT not allowed here, ignored", Abstract_Loc); end if; Decl_Node := New_Node (N_Full_Type_Declaration, Type_Loc); Set_Type_Definition (Decl_Node, Typedef_Node); if Unknown_Dis then Error_Msg ("Full type declaration cannot have unknown discriminants", Discr_Sloc); end if; end if; -- Remaining processing is common for all three cases Set_Defining_Identifier (Decl_Node, Ident_Node); Set_Discriminant_Specifications (Decl_Node, Discr_List); return Decl_Node; end P_Type_Declaration; ---------------------------------- -- 3.2.1 Full Type Declaration -- ---------------------------------- -- Parsed by P_Type_Declaration (3.2.1) ---------------------------- -- 3.2.1 Type Definition -- ---------------------------- -- Parsed by P_Type_Declaration (3.2.1) -------------------------------- -- 3.2.2 Subtype Declaration -- -------------------------------- -- SUBTYPE_DECLARATION ::= -- subtype DEFINING_IDENTIFIER is SUBTYPE_INDICATION; -- The caller has checked that the initial token is SUBTYPE -- Error recovery: can raise Error_Resync function P_Subtype_Declaration return Node_Id is Decl_Node : Node_Id; begin Decl_Node := New_Node (N_Subtype_Declaration, Token_Ptr); Scan; -- past SUBTYPE Set_Defining_Identifier (Decl_Node, P_Defining_Identifier); TF_Is; if Token = Tok_New then Error_Msg_SC ("NEW ignored (only allowed in type declaration)"); Scan; -- past NEW end if; Set_Subtype_Indication (Decl_Node, P_Subtype_Indication); TF_Semicolon; return Decl_Node; end P_Subtype_Declaration; ------------------------------- -- 3.2.2 Subtype Indication -- ------------------------------- -- SUBTYPE_INDICATION ::= SUBTYPE_MARK [CONSTRAINT] -- Error recovery: can raise Error_Resync function P_Subtype_Indication return Node_Id is Type_Node : Node_Id; begin if Token = Tok_Identifier or else Token = Tok_Operator_Symbol then Type_Node := P_Subtype_Mark; return P_Subtype_Indication (Type_Node); else -- Check for error of using record definition and treat it nicely, -- otherwise things are really messed up, so resynchronize. if Token = Tok_Record then Error_Msg_SC ("anonymous record definitions are not permitted"); Discard_Junk_Node (P_Record_Definition); return Error; else Error_Msg_AP ("subtype indication expected"); raise Error_Resync; end if; end if; end P_Subtype_Indication; -- The following function is identical except that it is called with -- the subtype mark already scanned out, and it scans out the constraint -- Error recovery: can raise Error_Resync function P_Subtype_Indication (Subtype_Mark : Node_Id) return Node_Id is Indic_Node : Node_Id; Constr_Node : Node_Id; begin Constr_Node := P_Constraint_Opt; if No (Constr_Node) then return Subtype_Mark; else Indic_Node := New_Node (N_Subtype_Indication, Sloc (Subtype_Mark)); Set_Subtype_Mark (Indic_Node, Check_Subtype_Mark (Subtype_Mark)); Set_Constraint (Indic_Node, Constr_Node); return Indic_Node; end if; end P_Subtype_Indication; ------------------------- -- 3.2.2 Subtype Mark -- ------------------------- -- SUBTYPE_MARK ::= subtype_NAME; -- Note: The subtype mark which appears after an IN or NOT IN -- operator is parsed by P_Range_Or_Subtype_Mark (3.5) -- Error recovery: cannot raise Error_Resync function P_Subtype_Mark return Node_Id is begin return P_Subtype_Mark_Resync; exception when Error_Resync => return Error; end P_Subtype_Mark; -- This routine differs from P_Subtype_Mark in that it insists that an -- identifier be present, and if it is not, it raises Error_Resync. -- Error recovery: can raise Error_Resync function P_Subtype_Mark_Resync return Node_Id is Type_Node : Node_Id; begin if Token = Tok_Access then Error_Msg_SC ("anonymous access type definition not allowed here"); Scan; -- past ACCESS end if; if Token = Tok_Array then Error_Msg_SC ("anonymous array definition not allowed here"); Discard_Junk_Node (P_Array_Type_Definition); return Error; else Type_Node := P_Qualified_Simple_Name_Resync; -- Check for a subtype mark attribute. The only valid possibilities -- are 'CLASS and 'BASE. Anything else is a definite error. We may -- as well catch it here. if Token = Tok_Apostrophe then return P_Subtype_Mark_Attribute (Type_Node); else return Type_Node; end if; end if; end P_Subtype_Mark_Resync; -- The following function is called to scan out a subtype mark attribute. -- The caller has already scanned out the subtype mark, which is passed in -- as the argument, and has checked that the current token is apostrophe. -- Only a special subclass of attributes, called type attributes -- (see Snames package) are allowed in this syntactic position. -- Note: if the apostrophe is followed by other than an identifier, then -- the input expression is returned unchanged, and the scan pointer is -- left pointing to the apostrophe. -- Error recovery: can raise Error_Resync function P_Subtype_Mark_Attribute (Type_Node : Node_Id) return Node_Id is Attr_Node : Node_Id := Empty; Scan_State : Saved_Scan_State; Prefix : Node_Id; begin Prefix := Check_Subtype_Mark (Type_Node); if Prefix = Error then raise Error_Resync; end if; -- Loop through attributes appearing (more than one can appear as for -- for example in X'Base'Class). We are at an apostrophe on entry to -- this loop, and it runs once for each attribute parsed, with -- Prefix being the current possible prefix if it is an attribute. loop Save_Scan_State (Scan_State); -- at Apostrophe Scan; -- past apostrophe if Token /= Tok_Identifier then Restore_Scan_State (Scan_State); -- to apostrophe return Prefix; -- no attribute after all elsif not Is_Type_Attribute_Name (Token_Name) then Error_Msg_N ("attribute & may not be used in a subtype mark", Token_Node); raise Error_Resync; else Attr_Node := Make_Attribute_Reference (Prev_Token_Ptr, Prefix => Prefix, Attribute_Name => Token_Name); Delete_Node (Token_Node); Scan; -- past type attribute identifier end if; exit when Token /= Tok_Apostrophe; Prefix := Attr_Node; end loop; -- Fall through here after scanning type attribute return Attr_Node; end P_Subtype_Mark_Attribute; ----------------------- -- 3.2.2 Constraint -- ----------------------- -- CONSTRAINT ::= SCALAR_CONSTRAINT | COMPOSITE_CONSTRAINT -- SCALAR_CONSTRAINT ::= -- RANGE_CONSTRAINT | DIGITS_CONSTRAINT | DELTA_CONSTRAINT -- COMPOSITE_CONSTRAINT ::= -- INDEX_CONSTRAINT | DISCRIMINANT_CONSTRAINT -- If no constraint is present, this function returns Empty -- Error recovery: can raise Error_Resync function P_Constraint_Opt return Node_Id is begin if Token = Tok_Range or else Bad_Spelling_Of (Tok_Range) then return P_Range_Constraint; elsif Token = Tok_Digits or else Bad_Spelling_Of (Tok_Digits) then return P_Digits_Constraint; elsif Token = Tok_Delta or else Bad_Spelling_Of (Tok_Delta) then return P_Delta_Constraint; elsif Token = Tok_Left_Paren then return P_Index_Or_Discriminant_Constraint; elsif Token = Tok_In then Ignore (Tok_In); return P_Constraint_Opt; else return Empty; end if; end P_Constraint_Opt; ------------------------------ -- 3.2.2 Scalar Constraint -- ------------------------------ -- Parsed by P_Constraint_Opt (3.2.2) --------------------------------- -- 3.2.2 Composite Constraint -- --------------------------------- -- Parsed by P_Constraint_Opt (3.2.2) -------------------------------------------------------- -- 3.3 Identifier Declarations (Also 7.4, 8.5, 11.1) -- -------------------------------------------------------- -- This routine scans out a declaration starting with an identifier: -- OBJECT_DECLARATION ::= -- DEFINING_IDENTIFIER_LIST : [constant] [aliased] -- SUBTYPE_INDICATION [:= EXPRESSION]; -- | DEFINING_IDENTIFIER_LIST : [constant] [aliased] -- ARRAY_TYPE_DEFINITION [:= EXPRESSION]; -- NUMBER_DECLARATION ::= -- DEFINING_IDENTIFIER_LIST : constant ::= static_EXPRESSION; -- OBJECT_RENAMING_DECLARATION ::= -- DEFINING_IDENTIFIER : SUBTYPE_MARK renames object_NAME; -- EXCEPTION_RENAMING_DECLARATION ::= -- DEFINING_IDENTIFIER : exception renames exception_NAME; -- EXCEPTION_DECLARATION ::= -- DEFINING_IDENTIFIER_LIST : exception; -- Note that the ALIASED indication in an object declaration is -- marked by a flag in the parent node. -- The caller has checked that the initial token is an identifier -- The value returned is a list of declarations, one for each identifier -- in the list (as described in Sinfo, we always split up multiple -- declarations into the equivalent sequence of single declarations -- using the More_Ids and Prev_Ids flags to preserve the source). -- If the identifier turns out to be a probable statement rather than -- an identifier, then the scan is left pointing to the identifier and -- No_List is returned. -- Error recovery: can raise Error_Resync procedure P_Identifier_Declarations (Decls : List_Id; Done : out Boolean; In_Spec : Boolean) is Decl_Node : Node_Id; Type_Node : Node_Id; Ident_Sloc : Source_Ptr; Scan_State : Saved_Scan_State; List_OK : Boolean := True; Ident : Nat; Init_Expr : Node_Id; Init_Loc : Source_Ptr; Con_Loc : Source_Ptr; Idents : array (Int range 1 .. 4096) of Entity_Id; -- Used to save identifiers in the identifier list. The upper bound -- of 4096 is expected to be infinite in practice, and we do not even -- bother to check if this upper bound is exceeded. Num_Idents : Nat := 1; -- Number of identifiers stored in Idents procedure No_List; -- This procedure is called in renames cases to make sure that we do -- not have more than one identifier. If we do have more than one -- then an error message is issued (and the declaration is split into -- multiple declarations) function Token_Is_Renames return Boolean; -- Checks if current token is RENAMES, and if so, scans past it and -- returns True, otherwise returns False. Includes checking for some -- common error cases. procedure No_List is begin if Num_Idents > 1 then Error_Msg ("identifier list not allowed for RENAMES", Sloc (Idents (2))); end if; List_OK := False; end No_List; function Token_Is_Renames return Boolean is At_Colon : Saved_Scan_State; begin if Token = Tok_Colon then Save_Scan_State (At_Colon); Scan; -- past colon Check_Misspelling_Of (Tok_Renames); if Token = Tok_Renames then Error_Msg_SP ("extra "":"" ignored"); Scan; -- past RENAMES return True; else Restore_Scan_State (At_Colon); return False; end if; else Check_Misspelling_Of (Tok_Renames); if Token = Tok_Renames then Scan; -- past RENAMES return True; else return False; end if; end if; end Token_Is_Renames; -- Start of processing for P_Identifier_Declarations begin Ident_Sloc := Token_Ptr; Save_Scan_State (Scan_State); -- at first identifier Idents (1) := P_Defining_Identifier; -- If we have a colon after the identifier, then we can assume that -- this is in fact a valid identifier declaration and can steam ahead. if Token = Tok_Colon then Scan; -- past colon -- If we have a comma, then scan out the list of identifiers elsif Token = Tok_Comma then while Comma_Present loop Num_Idents := Num_Idents + 1; Idents (Num_Idents) := P_Defining_Identifier; end loop; Save_Scan_State (Scan_State); -- at colon T_Colon; -- If we have identifier followed by := then we assume that what is -- really meant is an assignment statement. The assignment statement -- is scanned out and added to the list of declarations. An exception -- occurs if the := is followed by the keyword constant, in which case -- we assume it was meant to be a colon. elsif Token = Tok_Colon_Equal then Scan; -- past := if Token = Tok_Constant then Error_Msg_SP ("colon expected"); else Restore_Scan_State (Scan_State); Statement_When_Declaration_Expected (Decls, Done, In_Spec); return; end if; -- If we have an IS keyword, then assume the TYPE keyword was missing elsif Token = Tok_Is then Restore_Scan_State (Scan_State); Append_To (Decls, P_Type_Declaration); Done := False; return; -- Otherwise we have an error situation else Restore_Scan_State (Scan_State); -- First case is possible misuse of PROTECTED in Ada 83 mode. If -- so, fix the keyword and return to scan the protected declaration. if Token_Name = Name_Protected then Check_95_Keyword (Tok_Protected, Tok_Identifier); Check_95_Keyword (Tok_Protected, Tok_Type); Check_95_Keyword (Tok_Protected, Tok_Body); if Token = Tok_Protected then Done := False; return; end if; -- Check misspelling possibilities. If so, correct the misspelling -- and return to scan out the resulting declaration. elsif Bad_Spelling_Of (Tok_Function) or else Bad_Spelling_Of (Tok_Procedure) or else Bad_Spelling_Of (Tok_Package) or else Bad_Spelling_Of (Tok_Pragma) or else Bad_Spelling_Of (Tok_Protected) or else Bad_Spelling_Of (Tok_Generic) or else Bad_Spelling_Of (Tok_Subtype) or else Bad_Spelling_Of (Tok_Type) or else Bad_Spelling_Of (Tok_Task) or else Bad_Spelling_Of (Tok_Use) or else Bad_Spelling_Of (Tok_For) then Done := False; return; -- Otherwise we definitely have an ordinary identifier with a junk -- token after it. Just complain that we expect a declaration, and -- skip to a semicolon else Set_Declaration_Expected; Resync_Past_Semicolon; Done := False; return; end if; end if; -- Come here with an identifier list and colon scanned out. We now -- build the nodes for the declarative items. One node is built for -- each identifier in the list, with the type information being -- repeated by rescanning the appropriate section of source. -- First an error check, if we have two identifiers in a row, a likely -- possibility is that the first of the identifiers is an incorrectly -- spelled keyword. if Token = Tok_Identifier then declare SS : Saved_Scan_State; I2 : Boolean; begin Save_Scan_State (SS); Scan; -- past initial identifier I2 := (Token = Tok_Identifier); Restore_Scan_State (SS); if I2 and then (Bad_Spelling_Of (Tok_Access) or else Bad_Spelling_Of (Tok_Aliased) or else Bad_Spelling_Of (Tok_Constant)) then null; end if; end; end if; -- Loop through identifiers Ident := 1; Ident_Loop : loop -- Check for some cases of misused Ada 95 keywords if Token_Name = Name_Aliased then Check_95_Keyword (Tok_Aliased, Tok_Array); Check_95_Keyword (Tok_Aliased, Tok_Identifier); Check_95_Keyword (Tok_Aliased, Tok_Constant); end if; -- Constant cases if Token = Tok_Constant then Con_Loc := Token_Ptr; Scan; -- past CONSTANT -- Number declaration, initialization required Init_Expr := Init_Expr_Opt; if Present (Init_Expr) then Decl_Node := New_Node (N_Number_Declaration, Ident_Sloc); Set_Expression (Decl_Node, Init_Expr); -- Constant object declaration else Decl_Node := New_Node (N_Object_Declaration, Ident_Sloc); Set_Constant_Present (Decl_Node, True); if Token_Name = Name_Aliased then Check_95_Keyword (Tok_Aliased, Tok_Array); Check_95_Keyword (Tok_Aliased, Tok_Identifier); end if; if Token = Tok_Aliased then Error_Msg_SC ("ALIASED should be before CONSTANT"); Scan; -- past ALIASED Set_Aliased_Present (Decl_Node, True); end if; if Token = Tok_Array then Set_Object_Definition (Decl_Node, P_Array_Type_Definition); else Set_Object_Definition (Decl_Node, P_Subtype_Indication); end if; if Token = Tok_Renames then Error_Msg ("CONSTANT not permitted in renaming declaration", Con_Loc); Scan; -- Past renames Discard_Junk_Node (P_Name); end if; end if; -- Exception cases elsif Token = Tok_Exception then Scan; -- past EXCEPTION if Token_Is_Renames then No_List; Decl_Node := New_Node (N_Exception_Renaming_Declaration, Ident_Sloc); Set_Name (Decl_Node, P_Qualified_Simple_Name_Resync); No_Constraint; else Decl_Node := New_Node (N_Exception_Declaration, Prev_Token_Ptr); end if; -- Aliased case (note that an object definition is required) elsif Token = Tok_Aliased then Scan; -- past ALIASED Decl_Node := New_Node (N_Object_Declaration, Ident_Sloc); Set_Aliased_Present (Decl_Node, True); if Token = Tok_Constant then Scan; -- past CONSTANT Set_Constant_Present (Decl_Node, True); end if; if Token = Tok_Array then Set_Object_Definition (Decl_Node, P_Array_Type_Definition); else Set_Object_Definition (Decl_Node, P_Subtype_Indication); end if; -- Array case elsif Token = Tok_Array then Decl_Node := New_Node (N_Object_Declaration, Ident_Sloc); Set_Object_Definition (Decl_Node, P_Array_Type_Definition); -- Subtype indication case else Type_Node := P_Subtype_Mark; -- Object renaming declaration if Token_Is_Renames then No_List; Decl_Node := New_Node (N_Object_Renaming_Declaration, Ident_Sloc); Set_Subtype_Mark (Decl_Node, Type_Node); Set_Name (Decl_Node, P_Name); -- Object declaration else Decl_Node := New_Node (N_Object_Declaration, Ident_Sloc); Set_Object_Definition (Decl_Node, P_Subtype_Indication (Type_Node)); -- RENAMES at this point means that we had the combination of -- a constraint on the Type_Node and renames, which is illegal if Token_Is_Renames then Error_Msg_N ("constraint not allowed in object renaming declaration", Constraint (Object_Definition (Decl_Node))); raise Error_Resync; end if; end if; end if; -- Scan out initialization, allowed only for object declaration Init_Loc := Token_Ptr; Init_Expr := Init_Expr_Opt; if Present (Init_Expr) then if Nkind (Decl_Node) = N_Object_Declaration then Set_Expression (Decl_Node, Init_Expr); else Error_Msg ("initialization not allowed here", Init_Loc); end if; end if; TF_Semicolon; Set_Defining_Identifier (Decl_Node, Idents (Ident)); if List_OK then if Ident < Num_Idents then Set_More_Ids (Decl_Node, True); end if; if Ident > 1 then Set_Prev_Ids (Decl_Node, True); end if; end if; Append (Decl_Node, Decls); exit Ident_Loop when Ident = Num_Idents; Restore_Scan_State (Scan_State); T_Colon; Ident := Ident + 1; end loop Ident_Loop; Done := False; end P_Identifier_Declarations; ------------------------------- -- 3.3.1 Object Declaration -- ------------------------------- -- OBJECT DECLARATION ::= -- DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- SUBTYPE_INDICATION [:= EXPRESSION]; -- | DEFINING_IDENTIFIER_LIST : [aliased] [constant] -- ARRAY_TYPE_DEFINITION [:= EXPRESSION]; -- | SINGLE_TASK_DECLARATION -- | SINGLE_PROTECTED_DECLARATION -- Cases starting with TASK are parsed by P_Task (9.1) -- Cases starting with PROTECTED are parsed by P_Protected (9.4) -- All other cases are parsed by P_Identifier_Declarations (3.3) ------------------------------------- -- 3.3.1 Defining Identifier List -- ------------------------------------- -- DEFINING_IDENTIFIER_LIST ::= -- DEFINING_IDENTIFIER {, DEFINING_IDENTIFIER} -- Always parsed by the construct in which it appears. See special -- section on "Handling of Defining Identifier Lists" in this unit. ------------------------------- -- 3.3.2 Number Declaration -- ------------------------------- -- Parsed by P_Identifier_Declarations (3.3) ------------------------------------------------------------------------- -- 3.4 Derived Type Definition or Private Extension Declaration (7.3) -- ------------------------------------------------------------------------- -- DERIVED_TYPE_DEFINITION ::= -- [abstract] new parent_SUBTYPE_INDICATION [RECORD_EXTENSION_PART] -- PRIVATE_EXTENSION_DECLARATION ::= -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART] is -- [abstract] new ancestor_SUBTYPE_INDICATION with PRIVATE; -- RECORD_EXTENSION_PART ::= with RECORD_DEFINITION -- The caller has already scanned out the part up to the NEW, and Token -- either contains Tok_New (or ought to, if it doesn't this procedure -- will post an appropriate "NEW expected" message). -- Note: the caller is responsible for filling in the Sloc field of -- the returned node in the private extension declaration case as -- well as the stuff relating to the discriminant part. -- Error recovery: can raise Error_Resync; function P_Derived_Type_Def_Or_Private_Ext_Decl return Node_Id is Typedef_Node : Node_Id; Typedecl_Node : Node_Id; begin Typedef_Node := New_Node (N_Derived_Type_Definition, Token_Ptr); T_New; if Token = Tok_Abstract then Error_Msg_SC ("ABSTRACT must come before NEW, not after"); Scan; end if; Set_Subtype_Indication (Typedef_Node, P_Subtype_Indication); -- Deal with record extension, note that we assume that a WITH is -- missing in the case of "type X is new Y record ..." or in the -- case of "type X is new Y null record". if Token = Tok_With or else Token = Tok_Record or else Token = Tok_Null then T_With; -- past WITH or give error message if Token = Tok_Limited then Error_Msg_SC ("LIMITED keyword not allowed in private extension"); Scan; -- ignore LIMITED end if; -- Private extension declaration if Token = Tok_Private then Scan; -- past PRIVATE -- Throw away the type definition node and build the type -- declaration node. Note the caller must set the Sloc, -- Discriminant_Specifications, Unknown_Discriminants_Present, -- and Defined_Identifier fields in the returned node. Typedecl_Node := Make_Private_Extension_Declaration (No_Location, Defining_Identifier => Empty, Subtype_Indication => Subtype_Indication (Typedef_Node), Abstract_Present => Abstract_Present (Typedef_Node)); Delete_Node (Typedef_Node); return Typedecl_Node; -- Derived type definition with record extension part else Set_Record_Extension_Part (Typedef_Node, P_Record_Definition); return Typedef_Node; end if; -- Derived type definition with no record extension part else return Typedef_Node; end if; end P_Derived_Type_Def_Or_Private_Ext_Decl; --------------------------- -- 3.5 Range Constraint -- --------------------------- -- RANGE_CONSTRAINT ::= range RANGE -- The caller has checked that the initial token is RANGE -- Error recovery: cannot raise Error_Resync function P_Range_Constraint return Node_Id is Range_Node : Node_Id; begin Range_Node := New_Node (N_Range_Constraint, Token_Ptr); Scan; -- past RANGE Set_Range_Expression (Range_Node, P_Range); return Range_Node; end P_Range_Constraint; ---------------- -- 3.5 Range -- ---------------- -- RANGE ::= -- RANGE_ATTRIBUTE_REFERENCE | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION -- Note: the range that appears in a membership test is parsed by -- P_Range_Or_Subtype_Mark (3.5). -- Error recovery: cannot raise Error_Resync function P_Range return Node_Id is Expr_Node : Node_Id; Range_Node : Node_Id; begin Expr_Node := P_Simple_Expression_Or_Range_Attribute; if Expr_Form = EF_Range_Attr then return Expr_Node; elsif Token = Tok_Dot_Dot then Range_Node := New_Node (N_Range, Token_Ptr); Set_Low_Bound (Range_Node, Expr_Node); Scan; -- past .. Expr_Node := P_Expression; Check_Simple_Expression (Expr_Node); Set_High_Bound (Range_Node, Expr_Node); return Range_Node; -- Anything else is an error else T_Dot_Dot; -- force missing .. message return Error; end if; end P_Range; ---------------------------------- -- 3.5 P_Range_Or_Subtype_Mark -- ---------------------------------- -- RANGE ::= -- RANGE_ATTRIBUTE_REFERENCE -- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION -- This routine scans out the range or subtype mark that forms the right -- operand of a membership test. -- Note: as documented in the Sinfo interface, although the syntax only -- allows a subtype mark, we in fact allow any simple expression to be -- returned from this routine. The semantics is responsible for issuing -- an appropriate message complaining if the argument is not a name. -- This simplifies the coding and error recovery processing in the -- parser, and in any case it is preferable not to consider this a -- syntax error and to continue with the semantic analysis. -- Error recovery: cannot raise Error_Resync function P_Range_Or_Subtype_Mark return Node_Id is Expr_Node : Node_Id; Range_Node : Node_Id; begin Expr_Node := P_Simple_Expression_Or_Range_Attribute; if Expr_Form = EF_Range_Attr then return Expr_Node; -- Simple_Expression .. Simple_Expression elsif Token = Tok_Dot_Dot then Check_Simple_Expression (Expr_Node); Range_Node := New_Node (N_Range, Token_Ptr); Set_Low_Bound (Range_Node, Expr_Node); Scan; -- past .. Set_High_Bound (Range_Node, P_Simple_Expression); return Range_Node; -- Case of subtype mark (optionally qualified simple name or an -- attribute whose prefix is an optionally qualifed simple name) elsif Expr_Form = EF_Simple_Name or else Nkind (Expr_Node) = N_Attribute_Reference then -- Check for error of range constraint after a subtype mark if Token = Tok_Range then Error_Msg_SC ("range constraint not allowed in membership test"); Scan; -- past RANGE raise Error_Resync; -- Check for error of DIGITS or DELTA after a subtype mark elsif Token = Tok_Digits or else Token = Tok_Delta then Error_Msg_SC ("accuracy definition not allowed in membership test"); Scan; -- past DIGITS or DELTA raise Error_Resync; elsif Token = Tok_Apostrophe then return P_Subtype_Mark_Attribute (Expr_Node); else return Expr_Node; end if; -- At this stage, we have some junk following the expression. We -- really can't tell what is wrong, might be a missing semicolon, -- or a missing THEN, or whatever. Our caller will figure it out! else return Expr_Node; end if; end P_Range_Or_Subtype_Mark; ---------------------------------------- -- 3.5.1 Enumeration Type Definition -- ---------------------------------------- -- ENUMERATION_TYPE_DEFINITION ::= -- (ENUMERATION_LITERAL_SPECIFICATION -- {, ENUMERATION_LITERAL_SPECIFICATION}) -- The caller has already scanned out the TYPE keyword -- Error recovery: can raise Error_Resync; function P_Enumeration_Type_Definition return Node_Id is Typedef_Node : Node_Id; begin Typedef_Node := New_Node (N_Enumeration_Type_Definition, Token_Ptr); Set_Literals (Typedef_Node, New_List); T_Left_Paren; loop Append (P_Enumeration_Literal_Specification, Literals (Typedef_Node)); exit when not Comma_Present; end loop; T_Right_Paren; return Typedef_Node; end P_Enumeration_Type_Definition; ---------------------------------------------- -- 3.5.1 Enumeration Literal Specification -- ---------------------------------------------- -- ENUMERATION_LITERAL_SPECIFICATION ::= -- DEFINING_IDENTIFIER | DEFINING_CHARACTER_LITERAL -- Error recovery: can raise Error_Resync function P_Enumeration_Literal_Specification return Node_Id is begin if Token = Tok_Char_Literal then return P_Defining_Character_Literal; else return P_Defining_Identifier; end if; end P_Enumeration_Literal_Specification; --------------------------------------- -- 3.5.1 Defining_Character_Literal -- --------------------------------------- -- DEFINING_CHARACTER_LITERAL ::= CHARACTER_LITERAL -- Error recovery: cannot raise Error_Resync -- The caller has checked that the current token is a character literal function P_Defining_Character_Literal return Node_Id is Literal_Node : Node_Id; begin Literal_Node := Token_Node; Change_Character_Literal_To_Defining_Character_Literal (Literal_Node); Scan; -- past character literal return Literal_Node; end P_Defining_Character_Literal; ------------------------------------ -- 3.5.4 Integer Type Definition -- ------------------------------------ -- Parsed by P_Type_Declaration (3.2.1) ------------------------------------------- -- 3.5.4 Signed Integer Type Definition -- ------------------------------------------- -- SIGNED_INTEGER_TYPE_DEFINITION ::= -- range static_SIMPLE_EXPRESSION .. static_SIMPLE_EXPRESSION -- Normally the initial token on entry is RANGE, but in some -- error conditions, the range token was missing and control is -- passed with Token pointing to first token of the first expression. -- Error recovery: cannot raise Error_Resync function P_Signed_Integer_Type_Definition return Node_Id is Typedef_Node : Node_Id; Expr_Node : Node_Id; begin Typedef_Node := New_Node (N_Signed_Integer_Type_Definition, Token_Ptr); if Token = Tok_Range then Scan; -- past RANGE end if; Expr_Node := P_Expression; Check_Simple_Expression (Expr_Node); Set_Low_Bound (Typedef_Node, Expr_Node); T_Dot_Dot; Expr_Node := P_Expression; Check_Simple_Expression (Expr_Node); Set_High_Bound (Typedef_Node, Expr_Node); return Typedef_Node; end P_Signed_Integer_Type_Definition; ------------------------------------ -- 3.5.4 Modular Type Definition -- ------------------------------------ -- MODULAR_TYPE_DEFINITION ::= mod static_EXPRESSION -- The caller has checked that the initial token is MOD -- Error recovery: cannot raise Error_Resync function P_Modular_Type_Definition return Node_Id is Typedef_Node : Node_Id; begin if Ada_83 then Error_Msg_SC ("(Ada 83): modular types not allowed"); end if; Typedef_Node := New_Node (N_Modular_Type_Definition, Token_Ptr); Scan; -- past MOD Set_Expression (Typedef_Node, P_Expression_No_Right_Paren); -- Handle mod L..R cleanly if Token = Tok_Dot_Dot then Error_Msg_SC ("range not allowed for modular type"); Scan; -- past .. Set_Expression (Typedef_Node, P_Expression_No_Right_Paren); end if; return Typedef_Node; end P_Modular_Type_Definition; --------------------------------- -- 3.5.6 Real Type Definition -- --------------------------------- -- Parsed by P_Type_Declaration (3.2.1) -------------------------------------- -- 3.5.7 Floating Point Definition -- -------------------------------------- -- FLOATING_POINT_DEFINITION ::= -- digits static_EXPRESSION [REAL_RANGE_SPECIFICATION] -- Note: In Ada-83, the EXPRESSION must be a SIMPLE_EXPRESSION -- The caller has checked that the initial token is DIGITS -- Error recovery: cannot raise Error_Resync function P_Floating_Point_Definition return Node_Id is Digits_Loc : constant Source_Ptr := Token_Ptr; Def_Node : Node_Id; Expr_Node : Node_Id; begin Scan; -- past DIGITS Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression_In_Ada_83 (Expr_Node); -- Handle decimal fixed-point defn with DIGITS/DELTA in wrong order if Token = Tok_Delta then Error_Msg_SC ("DELTA must come before DIGITS"); Def_Node := New_Node (N_Decimal_Fixed_Point_Definition, Digits_Loc); Scan; -- past DELTA Set_Delta_Expression (Def_Node, P_Expression_No_Right_Paren); -- OK floating-point definition else Def_Node := New_Node (N_Floating_Point_Definition, Digits_Loc); end if; Set_Digits_Expression (Def_Node, Expr_Node); Set_Real_Range_Specification (Def_Node, P_Real_Range_Specification_Opt); return Def_Node; end P_Floating_Point_Definition; ------------------------------------- -- 3.5.7 Real Range Specification -- ------------------------------------- -- REAL_RANGE_SPECIFICATION ::= -- range static_SIMPLE_EXPRESSION .. static_SIMPLE_EXPRESSION -- Error recovery: cannot raise Error_Resync function P_Real_Range_Specification_Opt return Node_Id is Specification_Node : Node_Id; Expr_Node : Node_Id; begin if Token = Tok_Range then Specification_Node := New_Node (N_Real_Range_Specification, Token_Ptr); Scan; -- past RANGE Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression (Expr_Node); Set_Low_Bound (Specification_Node, Expr_Node); T_Dot_Dot; Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression (Expr_Node); Set_High_Bound (Specification_Node, Expr_Node); return Specification_Node; else return Empty; end if; end P_Real_Range_Specification_Opt; ----------------------------------- -- 3.5.9 Fixed Point Definition -- ----------------------------------- -- FIXED_POINT_DEFINITION ::= -- ORDINARY_FIXED_POINT_DEFINITION | DECIMAL_FIXED_POINT_DEFINITION -- ORDINARY_FIXED_POINT_DEFINITION ::= -- delta static_EXPRESSION REAL_RANGE_SPECIFICATION -- DECIMAL_FIXED_POINT_DEFINITION ::= -- delta static_EXPRESSION -- digits static_EXPRESSION [REAL_RANGE_SPECIFICATION] -- The caller has checked that the initial token is DELTA -- Error recovery: cannot raise Error_Resync function P_Fixed_Point_Definition return Node_Id is Delta_Node : Node_Id; Delta_Loc : Source_Ptr; Def_Node : Node_Id; Expr_Node : Node_Id; begin Delta_Loc := Token_Ptr; Scan; -- past DELTA Delta_Node := P_Expression_No_Right_Paren; Check_Simple_Expression_In_Ada_83 (Delta_Node); if Token = Tok_Digits then if Ada_83 then Error_Msg_SC ("(Ada 83) decimal fixed type not allowed!"); end if; Def_Node := New_Node (N_Decimal_Fixed_Point_Definition, Delta_Loc); Scan; -- past DIGITS Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression_In_Ada_83 (Expr_Node); Set_Digits_Expression (Def_Node, Expr_Node); else Def_Node := New_Node (N_Ordinary_Fixed_Point_Definition, Delta_Loc); -- Range is required in ordinary fixed point case if Token /= Tok_Range then Error_Msg_AP ("range must be given for fixed-point type"); T_Range; end if; end if; Set_Delta_Expression (Def_Node, Delta_Node); Set_Real_Range_Specification (Def_Node, P_Real_Range_Specification_Opt); return Def_Node; end P_Fixed_Point_Definition; -------------------------------------------- -- 3.5.9 Ordinary Fixed Point Definition -- -------------------------------------------- -- Parsed by P_Fixed_Point_Definition (3.5.9) ------------------------------------------- -- 3.5.9 Decimal Fixed Point Definition -- ------------------------------------------- -- Parsed by P_Decimal_Point_Definition (3.5.9) ------------------------------ -- 3.5.9 Digits Constraint -- ------------------------------ -- DIGITS_CONSTRAINT ::= -- digits static_EXPRESSION [RANGE_CONSTRAINT] -- Note: in Ada 83, the EXPRESSION must be a SIMPLE_EXPRESSION -- The caller has checked that the initial token is DIGITS function P_Digits_Constraint return Node_Id is Constraint_Node : Node_Id; Expr_Node : Node_Id; begin Constraint_Node := New_Node (N_Digits_Constraint, Token_Ptr); Scan; -- past DIGITS Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression_In_Ada_83 (Expr_Node); Set_Digits_Expression (Constraint_Node, Expr_Node); if Token = Tok_Range then Set_Range_Constraint (Constraint_Node, P_Range_Constraint); end if; return Constraint_Node; end P_Digits_Constraint; ----------------------------- -- 3.5.9 Delta Constraint -- ----------------------------- -- DELTA CONSTRAINT ::= DELTA STATIC_EXPRESSION [RANGE_CONSTRAINT] -- Note: this is an obsolescent feature in Ada 95 (I.3) -- Note: in Ada 83, the EXPRESSION must be a SIMPLE_EXPRESSION -- The caller has checked that the initial token is DELTA -- Error recovery: cannot raise Error_Resync function P_Delta_Constraint return Node_Id is Constraint_Node : Node_Id; Expr_Node : Node_Id; begin Constraint_Node := New_Node (N_Delta_Constraint, Token_Ptr); Scan; -- past DELTA Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression_In_Ada_83 (Expr_Node); Set_Delta_Expression (Constraint_Node, Expr_Node); if Token = Tok_Range then Set_Range_Constraint (Constraint_Node, P_Range_Constraint); end if; return Constraint_Node; end P_Delta_Constraint; -------------------------------- -- 3.6 Array Type Definition -- -------------------------------- -- ARRAY_TYPE_DEFINITION ::= -- UNCONSTRAINED_ARRAY_DEFINITION | CONSTRAINED_ARRAY_DEFINITION -- UNCONSTRAINED_ARRAY_DEFINITION ::= -- array (INDEX_SUBTYPE_DEFINITION {, INDEX_SUBTYPE_DEFINITION}) of -- COMPONENT_DEFINITION -- INDEX_SUBTYPE_DEFINITION ::= SUBTYPE_MARK range <> -- CONSTRAINED_ARRAY_DEFINITION ::= -- array (DISCRETE_SUBTYPE_DEFINITION {, DISCRETE_SUBTYPE_DEFINITION}) of -- COMPONENT_DEFINITION -- DISCRETE_SUBTYPE_DEFINITION ::= -- DISCRETE_SUBTYPE_INDICATION | RANGE -- COMPONENT_DEFINITION ::= [aliased] SUBTYPE_INDICATION -- The caller has checked that the initial token is ARRAY -- Error recovery: can raise Error_Resync function P_Array_Type_Definition return Node_Id is Array_Loc : Source_Ptr; Def_Node : Node_Id; Subs_List : List_Id; Scan_State : Saved_Scan_State; begin Array_Loc := Token_Ptr; Scan; -- past ARRAY Subs_List := New_List; T_Left_Paren; -- It's quite tricky to disentangle these two possibilities, so we do -- a prescan to determine which case we have and then reset the scan. -- The prescan skips past possible subtype mark tokens. Save_Scan_State (Scan_State); -- just after paren while Token in Token_Class_Desig or else Token = Tok_Dot or else Token = Tok_Apostrophe -- because of 'BASE, 'CLASS loop Scan; end loop; -- If we end up on RANGE <> then we have the unconstrained case. We -- will also allow the RANGE to be omitted, just to improve error -- handling for a case like array (integer <>) of integer; Scan; -- past possible RANGE or <> if (Prev_Token = Tok_Range and then Token = Tok_Box) or else Prev_Token = Tok_Box then Def_Node := New_Node (N_Unconstrained_Array_Definition, Array_Loc); Restore_Scan_State (Scan_State); -- to first subtype mark loop Append (P_Subtype_Mark_Resync, Subs_List); T_Range; T_Box; exit when Token = Tok_Right_Paren or else Token = Tok_Of; T_Comma; end loop; Set_Subtype_Marks (Def_Node, Subs_List); else Def_Node := New_Node (N_Constrained_Array_Definition, Array_Loc); Restore_Scan_State (Scan_State); -- to first discrete range loop Append (P_Discrete_Subtype_Definition, Subs_List); exit when not Comma_Present; end loop; Set_Discrete_Subtype_Definitions (Def_Node, Subs_List); end if; T_Right_Paren; T_Of; if Token = Tok_Aliased then Set_Aliased_Present (Def_Node, True); Scan; -- past ALIASED end if; Set_Subtype_Indication (Def_Node, P_Subtype_Indication); return Def_Node; end P_Array_Type_Definition; ----------------------------------------- -- 3.6 Unconstrained Array Definition -- ----------------------------------------- -- Parsed by P_Array_Type_Definition (3.6) --------------------------------------- -- 3.6 Constrained Array Definition -- --------------------------------------- -- Parsed by P_Array_Type_Definition (3.6) -------------------------------------- -- 3.6 Discrete Subtype Definition -- -------------------------------------- -- DISCRETE_SUBTYPE_DEFINITION ::= -- discrete_SUBTYPE_INDICATION | RANGE -- Note: the discrete subtype definition appearing in a constrained -- array definition is parsed by P_Array_Type_Definition (3.6) -- Error recovery: cannot raise Error_Resync function P_Discrete_Subtype_Definition return Node_Id is begin -- The syntax of a discrete subtype definition is identical to that -- of a discrete range, so we simply share the same parsing code. return P_Discrete_Range; end P_Discrete_Subtype_Definition; ------------------------------- -- 3.6 Component Definition -- ------------------------------- -- For the array case, parsed by P_Array_Type_Definition (3.6) -- For the record case, parsed by P_Component_Declaration (3.8) ----------------------------- -- 3.6.1 Index Constraint -- ----------------------------- -- Parsed by P_Index_Or_Discriminant_Constraint (3.7.1) --------------------------- -- 3.6.1 Discrete Range -- --------------------------- -- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | RANGE -- The possible forms for a discrete range are: -- Subtype_Mark (SUBTYPE_INDICATION, 3.2.2) -- Subtype_Mark range Range (SUBTYPE_INDICATION, 3.2.2) -- Range_Attribute (RANGE, 3.5) -- Simple_Expression .. Simple_Expression (RANGE, 3.5) -- Error recovery: cannot raise Error_Resync function P_Discrete_Range return Node_Id is Expr_Node : Node_Id; Range_Node : Node_Id; begin Expr_Node := P_Simple_Expression_Or_Range_Attribute; if Expr_Form = EF_Range_Attr then return Expr_Node; elsif Token = Tok_Range then if Expr_Form /= EF_Simple_Name then Error_Msg_SC ("range must be preceded by subtype mark"); end if; return P_Subtype_Indication (Expr_Node); -- Check Expression .. Expression case elsif Token = Tok_Dot_Dot then Range_Node := New_Node (N_Range, Token_Ptr); Set_Low_Bound (Range_Node, Expr_Node); Scan; -- past .. Expr_Node := P_Expression; Check_Simple_Expression (Expr_Node); Set_High_Bound (Range_Node, Expr_Node); return Range_Node; -- Otherwise we must have a subtype mark elsif Expr_Form = EF_Simple_Name then return Expr_Node; -- If incorrect, complain that we expect .. else T_Dot_Dot; return Expr_Node; end if; end P_Discrete_Range; ---------------------------- -- 3.7 Discriminant Part -- ---------------------------- -- DISCRIMINANT_PART ::= -- UNKNOWN_DISCRIMINANT_PART -- | KNOWN_DISCRIMINANT_PART -- A discriminant part is parsed by P_Known_Discriminant_Part_Opt (3.7) -- or P_Unknown_Discriminant_Part (3.7), since we know which we want. ------------------------------------ -- 3.7 Unknown Discriminant Part -- ------------------------------------ -- UNKNOWN_DISCRIMINANT_PART ::= (<>) -- If no unknown discriminant part is present, then False is returned, -- otherwise the unknown discriminant is scanned out and True is returned. -- Error recovery: cannot raise Error_Resync function P_Unknown_Discriminant_Part_Opt return Boolean is Scan_State : Saved_Scan_State; begin if Token /= Tok_Left_Paren then return False; else Save_Scan_State (Scan_State); Scan; -- past the left paren if Token = Tok_Box then if Ada_83 then Error_Msg_SC ("(Ada 83) unknown discriminant not allowed!"); end if; Scan; -- past the box T_Right_Paren; -- must be followed by right paren return True; else Restore_Scan_State (Scan_State); return False; end if; end if; end P_Unknown_Discriminant_Part_Opt; ---------------------------------- -- 3.7 Known Discriminant Part -- ---------------------------------- -- KNOWN_DISCRIMINANT_PART ::= -- (DISCRIMINANT_SPECIFICATION {; DISCRIMINANT_SPECIFICATION}) -- DISCRIMINANT_SPECIFICATION ::= -- DEFINING_IDENTIFIER_LIST : SUBTYPE_MARK -- [:= DEFAULT_EXPRESSION] -- | DEFINING_IDENTIFIER_LIST : ACCESS_DEFINITION -- [:= DEFAULT_EXPRESSION] -- If no known discriminant part is present, then No_List is returned -- Error recovery: cannot raise Error_Resync function P_Known_Discriminant_Part_Opt return List_Id is Specification_Node : Node_Id; Specification_List : List_Id; Ident_Sloc : Source_Ptr; Scan_State : Saved_Scan_State; Num_Idents : Nat; Ident : Nat; Idents : array (Int range 1 .. 4096) of Entity_Id; -- This array holds the list of defining identifiers. The upper bound -- of 4096 is intended to be essentially infinite, and we do not even -- bother to check for it being exceeded. begin if Token = Tok_Left_Paren then Specification_List := New_List; Scan; -- past ( P_Pragmas_Misplaced; Specification_Loop : loop Ident_Sloc := Token_Ptr; Idents (1) := P_Defining_Identifier; Num_Idents := 1; while Comma_Present loop Num_Idents := Num_Idents + 1; Idents (Num_Idents) := P_Defining_Identifier; end loop; T_Colon; -- If there are multiple identifiers, we repeatedly scan the -- type and initialization expression information by resetting -- the scan pointer (so that we get completely separate trees -- for each occurrence). if Num_Idents > 1 then Save_Scan_State (Scan_State); end if; -- Loop through defining identifiers in list Ident := 1; Ident_Loop : loop Specification_Node := New_Node (N_Discriminant_Specification, Ident_Sloc); Set_Defining_Identifier (Specification_Node, Idents (Ident)); if Token = Tok_Access then if Ada_83 then Error_Msg_SC ("(Ada 83) access discriminant not allowed!"); end if; Set_Discriminant_Type (Specification_Node, P_Access_Definition); else Set_Discriminant_Type (Specification_Node, P_Subtype_Mark); No_Constraint; end if; Set_Expression (Specification_Node, Init_Expr_Opt (True)); if Ident > 1 then Set_Prev_Ids (Specification_Node, True); end if; if Ident < Num_Idents then Set_More_Ids (Specification_Node, True); end if; Append (Specification_Node, Specification_List); exit Ident_Loop when Ident = Num_Idents; Ident := Ident + 1; Restore_Scan_State (Scan_State); end loop Ident_Loop; exit Specification_Loop when Token /= Tok_Semicolon; Scan; -- past ; P_Pragmas_Misplaced; end loop Specification_Loop; T_Right_Paren; return Specification_List; else return No_List; end if; end P_Known_Discriminant_Part_Opt; ------------------------------------- -- 3.7 DIscriminant Specification -- ------------------------------------- -- Parsed by P_Known_Discriminant_Part_Opt (3.7) ----------------------------- -- 3.7 Default Expression -- ----------------------------- -- Always parsed (simply as an Expression) by the parent construct ------------------------------------ -- 3.7.1 Discriminant Constraint -- ------------------------------------ -- Parsed by P_Index_Or_Discriminant_Constraint (3.7.1) -------------------------------------------------------- -- 3.7.1 Index or Discriminant Constraint (also 3.6) -- -------------------------------------------------------- -- DISCRIMINANT_CONSTRAINT ::= -- (DISCRIMINANT_ASSOCIATION {, DISCRIMINANT_ASSOCIATION}) -- DISCRIMINANT_ASSOCIATION ::= -- [discriminant_SELECTOR_NAME {| discriminant_SELECTOR_NAME} =>] -- EXPRESSION -- This routine parses either an index or a discriminant constraint. As -- is clear from the above grammar, it is often possible to clearly -- determine which of the two possibilities we have, but there are -- cases (those in which we have a series of expressions of the same -- syntactic form as subtype indications), where we cannot tell. Since -- this means that in any case the semantic phase has to distinguish -- between the two, there is not much point in the parser trying to -- distinguish even those cases where the difference is clear. In any -- case, if we have a situation like: -- (A => 123, 235 .. 500) -- it is not clear which of the two items is the wrong one, better to -- let the semantic phase give a clear message. Consequently, this -- routine in general returns a list of items which can be either -- discrete ranges or discriminant associations. -- The caller has checked that the initial token is a left paren -- Error recovery: can raise Error_Resync function P_Index_Or_Discriminant_Constraint return Node_Id is Scan_State : Saved_Scan_State; Constr_Node : Node_Id; Constr_List : List_Id; Expr_Node : Node_Id; Result_Node : Node_Id; begin Result_Node := New_Node (N_Index_Or_Discriminant_Constraint, Token_Ptr); Scan; -- past ( Constr_List := New_List; Set_Constraints (Result_Node, Constr_List); -- The two syntactic forms are a little mixed up, so what we are doing -- here is looking at the first entry to determine which case we have -- A discriminant constraint is a list of discriminant associations, -- which have one of the following possible forms: -- Expression -- Id => Expression -- Id | Id | .. | Id => Expression -- An index constraint is a list of discrete ranges which have one -- of the following possible forms: -- Subtype_Mark -- Subtype_Mark range Range -- Range_Attribute -- Simple_Expression .. Simple_Expression -- Loop through discriminants in list loop -- Check cases of Id => Expression or Id | Id => Expression if Token = Tok_Identifier then Save_Scan_State (Scan_State); -- at Id Scan; -- past Id if Token = Tok_Arrow or else Token = Tok_Vertical_Bar then Restore_Scan_State (Scan_State); -- to Id Append (P_Discriminant_Association, Constr_List); goto Loop_Continue; else Restore_Scan_State (Scan_State); -- to Id end if; end if; -- Otherwise scan out an expression and see what we have got Expr_Node := P_Expression_Or_Range_Attribute; if Expr_Form = EF_Range_Attr then Append (Expr_Node, Constr_List); elsif Token = Tok_Range then if Expr_Form /= EF_Simple_Name then Error_Msg_SC ("subtype mark required before RANGE"); end if; Append (P_Subtype_Indication (Expr_Node), Constr_List); goto Loop_Continue; -- Check Simple_Expression .. Simple_Expression case elsif Token = Tok_Dot_Dot then Check_Simple_Expression (Expr_Node); Constr_Node := New_Node (N_Range, Token_Ptr); Set_Low_Bound (Constr_Node, Expr_Node); Scan; -- past .. Expr_Node := P_Expression; Check_Simple_Expression (Expr_Node); Set_High_Bound (Constr_Node, Expr_Node); Append (Constr_Node, Constr_List); goto Loop_Continue; -- Case of an expression which could be either form else Append (Expr_Node, Constr_List); goto Loop_Continue; end if; -- Here with a single entry scanned <<Loop_Continue>> exit when not Comma_Present; end loop; T_Right_Paren; return Result_Node; end P_Index_Or_Discriminant_Constraint; ------------------------------------- -- 3.7.1 Discriminant Association -- ------------------------------------- -- DISCRIMINANT_ASSOCIATION ::= -- [discriminant_SELECTOR_NAME {| discriminant_SELECTOR_NAME} =>] -- EXPRESSION -- This routine is used only when the name list is present and the caller -- has already checked this (by scanning ahead and repositioning the -- scan). -- Error_Recovery: cannot raise Error_Resync; function P_Discriminant_Association return Node_Id is Discr_Node : Node_Id; Names_List : List_Id; Ident_Sloc : Source_Ptr; begin Ident_Sloc := Token_Ptr; Names_List := New_List; loop Append (P_Identifier, Names_List); exit when Token /= Tok_Vertical_Bar; Scan; -- past | end loop; Discr_Node := New_Node (N_Discriminant_Association, Ident_Sloc); Set_Selector_Names (Discr_Node, Names_List); TF_Arrow; Set_Expression (Discr_Node, P_Expression); return Discr_Node; end P_Discriminant_Association; --------------------------------- -- 3.8 Record Type Definition -- --------------------------------- -- RECORD_TYPE_DEFINITION ::= -- [[abstract] tagged] [limited] RECORD_DEFINITION -- There is no node in the tree for a record type definition. Instead -- a record definition node appears, with possible Abstract_Present, -- Tagged_Present, and Limited_Present flags set appropriately. ---------------------------- -- 3.8 Record Definition -- ---------------------------- -- RECORD_DEFINITION ::= -- record -- COMPONENT_LIST -- end record -- | null record -- Note: in the case where a record definition node is used to represent -- a record type definition, the caller sets the Tagged_Present and -- Limited_Present flags in the resulting N_Record_Definition node as -- required. -- Note that the RECORD token at the start may be missing in certain -- error situations, so this function is expected to post the error -- Error recovery: can raise Error_Resync function P_Record_Definition return Node_Id is Rec_Node : Node_Id; begin Rec_Node := New_Node (N_Record_Definition, Token_Ptr); -- Null record case if Token = Tok_Null then Scan; -- past NULL T_Record; Set_Null_Present (Rec_Node, True); -- Case starting with RECORD keyword. Build scope stack entry. For the -- column, we use the first non-blank character on the line, to deal -- with situations such as: -- type X is record -- ... -- end record; -- which is not official RM indentation, but is not uncommon usage else Push_Scope_Stack; Scope.Table (Scope.Last).Etyp := E_Record; Scope.Table (Scope.Last).Ecol := Start_Column; Scope.Table (Scope.Last).Sloc := Token_Ptr; Scope.Table (Scope.Last).Labl := Error; Scope.Table (Scope.Last).Junk := (Token /= Tok_Record); T_Record; Set_Component_List (Rec_Node, P_Component_List); loop exit when Check_End; Discard_Junk_Node (P_Component_List); end loop; end if; return Rec_Node; end P_Record_Definition; ------------------------- -- 3.8 Component List -- ------------------------- -- COMPONENT_LIST ::= -- COMPONENT_ITEM {COMPONENT_ITEM} -- | {COMPONENT_ITEM} VARIANT_PART -- | null; -- Error recovery: cannot raise Error_Resync function P_Component_List return Node_Id is Component_List_Node : Node_Id; Decls_List : List_Id; Scan_State : Saved_Scan_State; begin Component_List_Node := New_Node (N_Component_List, Token_Ptr); Decls_List := New_List; if Token = Tok_Null then Scan; -- past NULL TF_Semicolon; P_Pragmas_Opt (Decls_List); Set_Null_Present (Component_List_Node, True); return Component_List_Node; else P_Pragmas_Opt (Decls_List); if Token /= Tok_Case then Component_Scan_Loop : loop P_Component_Items (Decls_List); P_Pragmas_Opt (Decls_List); exit Component_Scan_Loop when Token = Tok_End or else Token = Tok_Case or else Token = Tok_When; -- We are done if we do not have an identifier. However, if -- we have a misspelled reserved identifier that is in a column -- to the right of the record definition, we will treat it as -- an identifier. It turns out to be too dangerous in practice -- to accept such a mis-spelled identifier which does not have -- this additional clue that confirms the incorrect spelling. if Token /= Tok_Identifier then if Start_Column > Scope.Table (Scope.Last).Ecol and then Is_Reserved_Identifier then Save_Scan_State (Scan_State); -- at reserved id Scan; -- possible reserved id if Token = Tok_Comma or else Token = Tok_Colon then Restore_Scan_State (Scan_State); Scan_Reserved_Identifier (Force_Msg => True); -- Note reserved identifier used as field name after -- all because not followed by colon or comma else Restore_Scan_State (Scan_State); exit Component_Scan_Loop; end if; -- Non-identifier that definitely was not reserved id else exit Component_Scan_Loop; end if; end if; end loop Component_Scan_Loop; end if; if Token = Tok_Case then Set_Variant_Part (Component_List_Node, P_Variant_Part); -- Check for junk after variant part if Token = Tok_Identifier then Save_Scan_State (Scan_State); Scan; -- past identifier if Token = Tok_Colon then Restore_Scan_State (Scan_State); Error_Msg_SC ("component may not follow variant part"); Discard_Junk_Node (P_Component_List); elsif Token = Tok_Case then Restore_Scan_State (Scan_State); Error_Msg_SC ("only one variant part allowed in a record"); Discard_Junk_Node (P_Component_List); else Restore_Scan_State (Scan_State); end if; end if; end if; end if; Set_Component_Items (Component_List_Node, Decls_List); return Component_List_Node; end P_Component_List; ------------------------- -- 3.8 Component Item -- ------------------------- -- COMPONENT_ITEM ::= COMPONENT_DECLARATION | REPRESENTATION_CLAUSE -- COMPONENT_DECLARATION ::= -- DEFINING_IDENTIFIER_LIST : COMPONENT_DEFINITION -- [:= DEFAULT_EXPRESSION]; -- COMPONENT_DEFINITION ::= [aliased] SUBTYPE_INDICATION -- Error recovery: cannot raise Error_Resync, if an error occurs, -- the scan is positioned past the following semicolon. -- Note: we do not yet allow representation clauses to appear as component -- items, do we need to add this capability sometime in the future ??? procedure P_Component_Items (Decls : List_Id) is Decl_Node : Node_Id; Scan_State : Saved_Scan_State; Num_Idents : Nat; Ident : Nat; Ident_Sloc : Source_Ptr; Idents : array (Int range 1 .. 4096) of Entity_Id; -- This array holds the list of defining identifiers. The upper bound -- of 4096 is intended to be essentially infinite, and we do not even -- bother to check for it being exceeded. begin if Token /= Tok_Identifier then Error_Msg_SC ("component declaration expected"); Resync_Past_Semicolon; return; end if; Ident_Sloc := Token_Ptr; Idents (1) := P_Defining_Identifier; Num_Idents := 1; while Comma_Present loop Num_Idents := Num_Idents + 1; Idents (Num_Idents) := P_Defining_Identifier; end loop; T_Colon; -- If there are multiple identifiers, we repeatedly scan the -- type and initialization expression information by resetting -- the scan pointer (so that we get completely separate trees -- for each occurrence). if Num_Idents > 1 then Save_Scan_State (Scan_State); end if; -- Loop through defining identifiers in list Ident := 1; Ident_Loop : loop -- The following block is present to catch Error_Resync -- which causes the parse to be reset past the semicolon begin Decl_Node := New_Node (N_Component_Declaration, Ident_Sloc); Set_Defining_Identifier (Decl_Node, Idents (Ident)); if Token = Tok_Constant then Error_Msg_SC ("constant components are not permitted"); Scan; end if; if Token_Name = Name_Aliased then Check_95_Keyword (Tok_Aliased, Tok_Identifier); end if; if Token = Tok_Aliased then Scan; -- past ALIASED Set_Aliased_Present (Decl_Node, True); end if; if Token = Tok_Array then Error_Msg_SC ("anonymous arrays not allowed as components"); raise Error_Resync; end if; Set_Subtype_Indication (Decl_Node, P_Subtype_Indication); Set_Expression (Decl_Node, Init_Expr_Opt); if Ident > 1 then Set_Prev_Ids (Decl_Node, True); end if; if Ident < Num_Idents then Set_More_Ids (Decl_Node, True); end if; Append (Decl_Node, Decls); exception when Error_Resync => if Token /= Tok_End then Resync_Past_Semicolon; end if; end; exit Ident_Loop when Ident = Num_Idents; Ident := Ident + 1; Restore_Scan_State (Scan_State); end loop Ident_Loop; TF_Semicolon; end P_Component_Items; -------------------------------- -- 3.8 Component Declaration -- -------------------------------- -- Parsed by P_Component_Items (3.8) ------------------------- -- 3.8.1 Variant Part -- ------------------------- -- VARIANT_PART ::= -- case discriminant_DIRECT_NAME is -- VARIANT -- {VARIANT} -- end case; -- The caller has checked that the initial token is CASE -- Error recovery: cannot raise Error_Resync function P_Variant_Part return Node_Id is Variant_Part_Node : Node_Id; Variants_List : List_Id; Case_Node : Node_Id; Case_Sloc : Source_Ptr; begin Variant_Part_Node := New_Node (N_Variant_Part, Token_Ptr); Push_Scope_Stack; Scope.Table (Scope.Last).Etyp := E_Case; Scope.Table (Scope.Last).Sloc := Token_Ptr; Scope.Table (Scope.Last).Ecol := Start_Column; Scan; -- past CASE Case_Node := P_Expression; Case_Sloc := Token_Ptr; Set_Name (Variant_Part_Node, Case_Node); if Nkind (Case_Node) /= N_Identifier then Set_Name (Variant_Part_Node, Error); Error_Msg ("discriminant name expected", Sloc (Case_Node)); end if; TF_Is; Variants_List := New_List; P_Pragmas_Opt (Variants_List); -- Test missing variant if Token = Tok_End then Error_Msg_BC ("WHEN expected (must have at least one variant)"); else Append (P_Variant, Variants_List); end if; -- Loop through variants, note that we allow if in place of when, -- this error will be detected and handled in P_Variant. loop P_Pragmas_Opt (Variants_List); if Token /= Tok_When and then Token /= Tok_If and then Token /= Tok_Others then exit when Check_End; end if; Append (P_Variant, Variants_List); end loop; Set_Variants (Variant_Part_Node, Variants_List); return Variant_Part_Node; end P_Variant_Part; -------------------- -- 3.8.1 Variant -- -------------------- -- VARIANT ::= -- when DISCRETE_CHOICE_LIST => -- COMPONENT_LIST -- Error recovery: cannot raise Error_Resync -- The initial token on entry is either WHEN, IF or OTHERS function P_Variant return Node_Id is Variant_Node : Node_Id; begin -- Special check to recover nicely from use of IF in place of WHEN if Token = Tok_If then T_When; Scan; -- past IF else T_When; end if; Variant_Node := New_Node (N_Variant, Prev_Token_Ptr); Set_Discrete_Choices (Variant_Node, P_Discrete_Choice_List); TF_Arrow; Set_Component_List (Variant_Node, P_Component_List); return Variant_Node; end P_Variant; --------------------------------- -- 3.8.1 Discrete Choice List -- --------------------------------- -- DISCRETE_CHOICE_LIST ::= DISCRETE_CHOICE {| DISCRETE_CHOICE} -- DISCRETE_CHOICE ::= EXPRESSION | DISCRETE_RANGE | others -- Note: in Ada 83, the expression must be a simple expression -- Error recovery: cannot raise Error_Resync function P_Discrete_Choice_List return List_Id is Choices : List_Id; Expr_Node : Node_Id; Choice_Node : Node_Id; begin Choices := New_List; loop if Token = Tok_Others then Append (New_Node (N_Others_Choice, Token_Ptr), Choices); Scan; -- past OTHERS else begin Expr_Node := No_Right_Paren (P_Expression_Or_Range_Attribute); if Token = Tok_Colon and then Nkind (Expr_Node) = N_Identifier then Error_Msg_SP ("label not permitted in this context"); Scan; -- past colon elsif Expr_Form = EF_Range_Attr then Append (Expr_Node, Choices); elsif Token = Tok_Dot_Dot then Check_Simple_Expression (Expr_Node); Choice_Node := New_Node (N_Range, Token_Ptr); Set_Low_Bound (Choice_Node, Expr_Node); Scan; -- past .. Expr_Node := P_Expression_No_Right_Paren; Check_Simple_Expression (Expr_Node); Set_High_Bound (Choice_Node, Expr_Node); Append (Choice_Node, Choices); elsif Expr_Form = EF_Simple_Name then if Token = Tok_Range then Append (P_Subtype_Indication (Expr_Node), Choices); elsif Token in Token_Class_Consk then Error_Msg_SC ("the only constraint allowed here " & "is a range constraint"); Discard_Junk_Node (P_Constraint_Opt); Append (Expr_Node, Choices); else Append (Expr_Node, Choices); end if; else Check_Simple_Expression_In_Ada_83 (Expr_Node); Append (Expr_Node, Choices); end if; exception when Error_Resync => Resync_Choice; return Error_List; end; end if; if Token = Tok_Comma then Error_Msg_SC (""","" should be ""|"""); else exit when Token /= Tok_Vertical_Bar; end if; Scan; -- past | or comma end loop; return Choices; end P_Discrete_Choice_List; ---------------------------- -- 3.8.1 Discrete Choice -- ---------------------------- -- Parsed by P_Discrete_Choice_List (3.8.1) ---------------------------------- -- 3.9.1 Record Extension Part -- ---------------------------------- -- RECORD_EXTENSION_PART ::= with RECORD_DEFINITION -- Parsed by P_Derived_Type_Def_Or_Private_Ext_Decl (3.4) ---------------------------------- -- 3.10 Access Type Definition -- ---------------------------------- -- ACCESS_TYPE_DEFINITION ::= -- ACCESS_TO_OBJECT_DEFINITION -- | ACCESS_TO_SUBPROGRAM_DEFINITION -- ACCESS_TO_OBJECT_DEFINITION ::= -- access [GENERAL_ACCESS_MODIFIER] SUBTYPE_INDICATION -- GENERAL_ACCESS_MODIFIER ::= all | constant -- ACCESS_TO_SUBPROGRAM_DEFINITION -- access [protected] procedure PARAMETER_PROFILE -- | access [protected] function PARAMETER_AND_RESULT_PROFILE -- PARAMETER_PROFILE ::= [FORMAL_PART] -- PARAMETER_AND_RESULT_PROFILE ::= [FORMAL_PART] RETURN SUBTYPE_MARK -- The caller has checked that the initial token is ACCESS -- Error recovery: can raise Error_Resync function P_Access_Type_Definition return Node_Id is Prot_Flag : Boolean; Access_Loc : Source_Ptr; Type_Def_Node : Node_Id; procedure Check_Junk_Subprogram_Name; -- Used in access to subprogram definition cases to check for an -- identifier or operator symbol that does not belong. procedure Check_Junk_Subprogram_Name is Saved_State : Saved_Scan_State; begin if Token = Tok_Identifier or else Token = Tok_Operator_Symbol then Save_Scan_State (Saved_State); Scan; -- past possible junk subprogram name if Token = Tok_Left_Paren or else Token = Tok_Semicolon then Error_Msg_SP ("unexpected subprogram name ignored"); return; else Restore_Scan_State (Saved_State); end if; end if; end Check_Junk_Subprogram_Name; -- Start of processing for P_Access_Type_Definition begin Access_Loc := Token_Ptr; Scan; -- past ACCESS if Token_Name = Name_Protected then Check_95_Keyword (Tok_Protected, Tok_Procedure); Check_95_Keyword (Tok_Protected, Tok_Function); end if; Prot_Flag := (Token = Tok_Protected); if Prot_Flag then Scan; -- past PROTECTED if Token /= Tok_Procedure and then Token /= Tok_Function then Error_Msg_SC ("FUNCTION or PROCEDURE expected"); end if; end if; if Token = Tok_Procedure then if Ada_83 then Error_Msg_SC ("(Ada 83) access to procedure not allowed!"); end if; Type_Def_Node := New_Node (N_Access_Procedure_Definition, Access_Loc); Scan; -- past PROCEDURE Check_Junk_Subprogram_Name; Set_Parameter_Specifications (Type_Def_Node, P_Parameter_Profile); Set_Protected_Present (Type_Def_Node, Prot_Flag); elsif Token = Tok_Function then if Ada_83 then Error_Msg_SC ("(Ada 83) access to function not allowed!"); end if; Type_Def_Node := New_Node (N_Access_Function_Definition, Access_Loc); Scan; -- past FUNCTION Check_Junk_Subprogram_Name; Set_Parameter_Specifications (Type_Def_Node, P_Parameter_Profile); Set_Protected_Present (Type_Def_Node, Prot_Flag); TF_Return; Set_Subtype_Mark (Type_Def_Node, P_Subtype_Mark); No_Constraint; else Type_Def_Node := New_Node (N_Access_To_Object_Definition, Access_Loc); if Token = Tok_All or else Token = Tok_Constant then if Ada_83 then Error_Msg_SC ("(Ada 83) access modifier not allowed!"); end if; if Token = Tok_All then Set_All_Present (Type_Def_Node, True); else Set_Constant_Present (Type_Def_Node, True); end if; Scan; -- past ALL or CONSTANT end if; Set_Subtype_Indication (Type_Def_Node, P_Subtype_Indication); end if; return Type_Def_Node; end P_Access_Type_Definition; --------------------------------------- -- 3.10 Access To Object Definition -- --------------------------------------- -- Parsed by P_Access_Type_Definition (3.10) ----------------------------------- -- 3.10 General Access Modifier -- ----------------------------------- -- Parsed by P_Access_Type_Definition (3.10) ------------------------------------------- -- 3.10 Access To Subprogram Definition -- ------------------------------------------- -- Parsed by P_Access_Type_Definition (3.10) ----------------------------- -- 3.10 Access Definition -- ----------------------------- -- ACCESS_DEFINITION ::= access SUBTYPE_MARK -- The caller has checked that the initial token is ACCESS -- Error recovery: cannot raise Error_Resync function P_Access_Definition return Node_Id is Def_Node : Node_Id; begin Def_Node := New_Node (N_Access_Definition, Token_Ptr); Scan; -- past ACCESS Set_Subtype_Mark (Def_Node, P_Subtype_Mark); No_Constraint; return Def_Node; end P_Access_Definition; ----------------------------------------- -- 3.10.1 Incomplete Type Declaration -- ----------------------------------------- -- Parsed by P_Type_Declaration (3.2.1) ---------------------------- -- 3.11 Declarative Part -- ---------------------------- -- DECLARATIVE_PART ::= {DECLARATIVE_ITEM} -- Error recovery: cannot raise Error_Resync (because P_Declarative_Items -- handles errors, and returns cleanly after an error has occurred) function P_Declarative_Part return List_Id is Decls : List_Id; Done : Boolean; begin -- Indicate no bad declarations detected yet. This will be reset by -- P_Declarative_Items if a bad declaration is discovered. Missing_Begin_Msg := No_Error_Msg; -- Get rid of active SIS entry from outer scope. This means we will -- miss some nested cases, but it doesn't seem worth the effort. See -- discussion in Par for further details SIS_Entry_Active := False; Decls := New_List; -- Loop to scan out the declarations loop P_Declarative_Items (Decls, Done, In_Spec => False); exit when Done; end loop; -- Get rid of active SIS entry which is left set only if we scanned a -- procedure declaration and have not found the body. We could give -- an error message, but that really would be usurping the role of -- semantic analysis (this really is a missing body case). SIS_Entry_Active := False; return Decls; end P_Declarative_Part; ---------------------------- -- 3.11 Declarative Item -- ---------------------------- -- DECLARATIVE_ITEM ::= BASIC_DECLARATIVE_ITEM | BODY -- Can return Error if a junk declaration is found, or Empty if no -- declaration is found (i.e. a token ending declarations, such as -- BEGIN or END is encountered). -- Error recovery: cannot raise Error_Resync. If an error resync occurs, -- then the scan is set past the next semicolon and Error is returned. procedure P_Declarative_Items (Decls : List_Id; Done : out Boolean; In_Spec : Boolean) is Scan_State : Saved_Scan_State; begin if Style_Check then Style.Check_Indentation; end if; case Token is when Tok_Function => Check_Bad_Layout; Append (P_Subprogram (Pf_Decl_Gins_Pbod_Rnam_Stub), Decls); Done := False; when Tok_For => Check_Bad_Layout; -- Check for loop (premature statement) Save_Scan_State (Scan_State); Scan; -- past FOR if Token = Tok_Identifier then Scan; -- past identifier if Token = Tok_In then Restore_Scan_State (Scan_State); Statement_When_Declaration_Expected (Decls, Done, In_Spec); return; end if; end if; -- Not a loop, so must be rep clause Restore_Scan_State (Scan_State); Append (P_Representation_Clause, Decls); Done := False; when Tok_Generic => Check_Bad_Layout; Append (P_Generic, Decls); Done := False; when Tok_Identifier => Check_Bad_Layout; P_Identifier_Declarations (Decls, Done, In_Spec); when Tok_Package => Check_Bad_Layout; Append (P_Package (Pf_Decl_Gins_Pbod_Rnam_Stub), Decls); Done := False; when Tok_Pragma => Append (P_Pragma, Decls); Done := False; when Tok_Procedure => Check_Bad_Layout; Append (P_Subprogram (Pf_Decl_Gins_Pbod_Rnam_Stub), Decls); Done := False; when Tok_Protected => Check_Bad_Layout; Scan; -- past PROTECTED Append (P_Protected, Decls); Done := False; when Tok_Subtype => Check_Bad_Layout; Append (P_Subtype_Declaration, Decls); Done := False; when Tok_Task => Check_Bad_Layout; Scan; -- past TASK Append (P_Task, Decls); Done := False; when Tok_Type => Check_Bad_Layout; Append (P_Type_Declaration, Decls); Done := False; when Tok_Use => Check_Bad_Layout; Append (P_Use_Clause, Decls); Done := False; when Tok_With => Check_Bad_Layout; Error_Msg_SC ("WITH can only appear in context clause"); raise Error_Resync; -- BEGIN terminates the scan of a sequence of declarations unless -- there is a missing subprogram body, see section on handling -- semicolon in place of IS. We only treat the begin as satisfying -- the subprogram declaration if it falls in the expected column -- or to its right. when Tok_Begin => if SIS_Entry_Active and then Start_Column >= SIS_Ecol then -- Here we have the case where a BEGIN is encountered during -- declarations in a declarative part, or at the outer level, -- and there is a subprogram declaration outstanding for which -- no body has been supplied. This is the case where we assume -- that the semicolon in the subprogram declaration should -- really have been is. The active SIS entry describes the -- subprogram declaration. On return the declaration has been -- modified to become a body. declare Specification_Node : Node_Id; Decl_Node : Node_Id; Body_Node : Node_Id; begin -- First issue the error message. If we had a missing -- semicolon in the declaration, then change the message -- to <missing "is"> if SIS_Missing_Semicolon_Message /= No_Error_Msg then Change_Error_Text -- Replace: "missing "";"" " (SIS_Missing_Semicolon_Message, "missing ""is"""); -- Otherwise we saved the semicolon position, so complain else Error_Msg (""";"" should be IS", SIS_Semicolon_Sloc); end if; -- The next job is to fix up any declarations that occurred -- between the procedure header and the BEGIN. These got -- chained to the outer declarative region (immediately -- after the procedure declaration) and they should be -- chained to the subprogram itself, which is a body -- rather than a spec. Specification_Node := Specification (SIS_Declaration_Node); Change_Node (SIS_Declaration_Node, N_Subprogram_Body); Body_Node := SIS_Declaration_Node; Set_Specification (Body_Node, Specification_Node); Set_Declarations (Body_Node, New_List); loop Decl_Node := Remove_Next (Body_Node); exit when Decl_Node = Empty; Append (Decl_Node, Declarations (Body_Node)); end loop; -- Now make the scope table entry for the Begin-End and -- scan it out Push_Scope_Stack; Scope.Table (Scope.Last).Sloc := SIS_Sloc; Scope.Table (Scope.Last).Etyp := E_Name; Scope.Table (Scope.Last).Ecol := SIS_Ecol; Scope.Table (Scope.Last).Labl := SIS_Labl; Scope.Table (Scope.Last).Lreq := False; SIS_Entry_Active := False; Scan; -- past BEGIN Set_Handled_Statement_Sequence (Body_Node, P_Handled_Sequence_Of_Statements); End_Statements (Handled_Statement_Sequence (Body_Node)); end; Done := False; else Done := True; end if; -- Normally an END terminates the scan for basic declarative -- items. The one exception is END RECORD, which is probably -- left over from some other junk. when Tok_End => Save_Scan_State (Scan_State); -- at END Scan; -- past END if Token = Tok_Record then Error_Msg_SP ("no RECORD for this `end record`!"); Scan; -- past RECORD TF_Semicolon; else Restore_Scan_State (Scan_State); -- to END Done := True; end if; -- The following tokens which can only be the start of a statement -- are considered to end a declarative part (i.e. we have a missing -- BEGIN situation). We are fairly conservative in making this -- judgment, because it is a real mess to go into statement mode -- prematurely in response to a junk declaration. when Tok_Abort | Tok_Accept | Tok_Declare | Tok_Delay | Tok_Exit | Tok_Goto | Tok_If | Tok_Loop | Tok_Null | Tok_Requeue | Tok_Select | Tok_While => -- But before we decide that it's a statement, let's check for -- a reserved word misused as an identifier. if Is_Reserved_Identifier then Save_Scan_State (Scan_State); Scan; -- past the token -- If reserved identifier not followed by colon or comma, then -- this is most likely an assignment statement to the bad id. if Token /= Tok_Colon and then Token /= Tok_Comma then Restore_Scan_State (Scan_State); Statement_When_Declaration_Expected (Decls, Done, In_Spec); return; -- Otherwise we have a declaration of the bad id else Restore_Scan_State (Scan_State); Scan_Reserved_Identifier (Force_Msg => True); P_Identifier_Declarations (Decls, Done, In_Spec); end if; -- If not reserved identifier, then it's definitely a statement else Statement_When_Declaration_Expected (Decls, Done, In_Spec); return; end if; -- The token RETURN may well also signal a missing BEGIN situation, -- however, we never let it end the declarative part, because it may -- also be part of a half-baked function declaration. when Tok_Return => Error_Msg_SC ("misplaced RETURN statement"); raise Error_Resync; -- PRIVATE definitely terminates the declarations in a spec, -- and is an error in a body. when Tok_Private => if In_Spec then Done := True; else Error_Msg_SC ("PRIVATE not allowed in body"); Scan; -- past PRIVATE end if; -- An end of file definitely terminates the declarations! when Tok_EOF => Done := True; -- The remaining tokens do not end the scan, but cannot start a -- valid declaration, so we signal an error and resynchronize. -- But first check for misuse of a reserved identifier. when others => -- Here we check for a reserved identifier if Is_Reserved_Identifier then Save_Scan_State (Scan_State); Scan; -- past the token if Token /= Tok_Colon and then Token /= Tok_Comma then Restore_Scan_State (Scan_State); Set_Declaration_Expected; raise Error_Resync; else Restore_Scan_State (Scan_State); Scan_Reserved_Identifier (Force_Msg => True); Check_Bad_Layout; P_Identifier_Declarations (Decls, Done, In_Spec); end if; else Set_Declaration_Expected; raise Error_Resync; end if; end case; -- To resynchronize after an error, we scan to the next semicolon and -- return with Done = False, indicating that there may still be more -- valid declarations to come. exception when Error_Resync => Resync_Past_Semicolon; Done := False; end P_Declarative_Items; ---------------------------------- -- 3.11 Basic Declarative Item -- ---------------------------------- -- BASIC_DECLARATIVE_ITEM ::= -- BASIC_DECLARATION | REPRESENTATION_CLAUSE | USE_CLAUSE -- Scan zero or more basic declarative items -- Error recovery: cannot raise Error_Resync. If an error is detected, then -- the scan pointer is repositioned past the next semicolon, and the scan -- for declarative items continues. function P_Basic_Declarative_Items return List_Id is Decl : Node_Id; Decls : List_Id; Kind : Node_Kind; Done : Boolean; begin -- Get rid of active SIS entry from outer scope. This means we will -- miss some nested cases, but it doesn't seem worth the effort. See -- discussion in Par for further details SIS_Entry_Active := False; -- Loop to scan out declarations Decls := New_List; loop P_Declarative_Items (Decls, Done, In_Spec => True); exit when Done; end loop; -- Get rid of active SIS entry. This is set only if we have scanned a -- procedure declaration and have not found the body. We could give -- an error message, but that really would be usurping the role of -- semantic analysis (this really is a case of a missing body). SIS_Entry_Active := False; -- Test for assorted illegal declarations not diagnosed elsewhere. Decl := First (Decls); while Present (Decl) loop Kind := Nkind (Decl); -- Test for body scanned, not acceptable as basic decl item if Kind = N_Subprogram_Body or else Kind = N_Package_Body or else Kind = N_Task_Body or else Kind = N_Protected_Body then Error_Msg ("proper body not allowed in package spec", Sloc (Decl)); -- Test for body stub scanned, not acceptable as basic decl item elsif Kind in N_Body_Stub then Error_Msg ("body stub not allowed in package spec", Sloc (Decl)); elsif Kind = N_Assignment_Statement then Error_Msg ("assignment statement not allowed in package spec", Sloc (Decl)); end if; Next (Decl); end loop; return Decls; end P_Basic_Declarative_Items; ---------------- -- 3.11 Body -- ---------------- -- For proper body, see below -- For body stub, see 10.1.3 ----------------------- -- 3.11 Proper Body -- ----------------------- -- Subprogram body is parsed by P_Subprogram (6.1) -- Package body is parsed by P_Package (7.1) -- Task body is parsed by P_Task (9.1) -- Protected body is parsed by P_Protected (9.4) ------------------------------ -- Set_Declaration_Expected -- ------------------------------ procedure Set_Declaration_Expected is begin Error_Msg_SC ("declaration expected"); if Missing_Begin_Msg = No_Error_Msg then Missing_Begin_Msg := Get_Msg_Id; end if; end Set_Declaration_Expected; ---------------------- -- Skip_Declaration -- ---------------------- procedure Skip_Declaration (S : List_Id) is Dummy_Done : Boolean; begin P_Declarative_Items (S, Dummy_Done, False); end Skip_Declaration; ----------------------------------------- -- Statement_When_Declaration_Expected -- ----------------------------------------- procedure Statement_When_Declaration_Expected (Decls : List_Id; Done : out Boolean; In_Spec : Boolean) is begin -- Case of second occurrence of statement in one declaration sequence if Missing_Begin_Msg /= No_Error_Msg then -- In the procedure spec case, just ignore it, we only give one -- message for the first occurrence, since otherwise we may get -- horrible cascading if BODY was missing in the header line. if In_Spec then null; -- In the declarative part case, take a second statement as a sure -- sign that we really have a missing BEGIN, and end the declarative -- part now. Note that the caller will fix up the first message to -- say "missing BEGIN" so that's how the error will be signalled. else Done := True; return; end if; -- Case of first occurrence of unexpected statement else -- If we are in a package spec, then give message of statement -- not allowed in package spec. This message never gets changed. if In_Spec then Error_Msg_SC ("statement not allowed in package spec"); -- If in declarative part, then we give the message complaining -- about finding a statement when a declaration is expected. This -- gets changed to a complaint about a missing BEGIN if we later -- find that no BEGIN is present. else Error_Msg_SC ("statement not allowed in declarative part"); end if; -- Capture message Id. This is used for two purposes, first to -- stop multiple messages, see test above, and second, to allow -- the replacement of the message in the declarative part case. Missing_Begin_Msg := Get_Msg_Id; end if; -- In all cases except the case in which we decided to terminate the -- declaration sequence on a second error, we scan out the statement -- and append it to the list of declarations (note that the semantics -- can handle statements in a declaration list so if we proceed to -- call the semantic phase, all will be (reasonably) well! Append_List_To (Decls, P_Sequence_Of_Statements (SS_Unco)); -- Done is set to False, since we want to continue the scan of -- declarations, hoping that this statement was a temporary glitch. -- If we indeed are now in the statement part (i.e. this was a missing -- BEGIN, then it's not terrible, we will simply keep calling this -- procedure to process the statements one by one, and then finally -- hit the missing BEGIN, which will clean up the error message. Done := False; end Statement_When_Declaration_Expected; end Ch3;
29,904
ada
12
TUM-EI-RCS/StratoX
tests/dispatch/ulog-gps.adb
-- Institution: Technische Universitaet Muenchen -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- Author: <NAME> (<EMAIL>) with Ada.Text_IO; -- TODO: remove -- @summary -- implements ULOG GPS message package body ULog.GPS with SPARK_Mode is overriding procedure Get_Serialization (msg : in Message; bytes : out HIL.Byte_Array) is begin -- TODO: serialize the extensions in GPS message null; end Get_Serialization; overriding procedure Get_Format (msg : in Message; bytes : out HIL.Byte_Array) is begin null; end Get_Format; function Copy (msg : in Message) return Message is begin Ada.Text_IO.Put_Line ("gps copy"); return msg; end Copy; overriding function Get_Size (msg : in Message) return Interfaces.Unsigned_16 is begin return 10; -- TODO end Get_Size; procedure Describe_Func (msg : in Message; namestring : out String) is begin namestring := "gps"; end Describe_Func; overriding function Self (msg : in Message) return ULog.Message'Class is begin Ada.Text_IO.Put_Line ("Self of ulog.gps"); return Message'(msg); end Self; end ULog.GPS;
29,905
ada
0
optikos/oasis
source/oasis/program-elements-object_access_types.ads
<reponame>optikos/oasis -- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Access_Types; with Program.Lexical_Elements; with Program.Elements.Subtype_Indications; package Program.Elements.Object_Access_Types is pragma Pure (Program.Elements.Object_Access_Types); type Object_Access_Type is limited interface and Program.Elements.Access_Types.Access_Type; type Object_Access_Type_Access is access all Object_Access_Type'Class with Storage_Size => 0; not overriding function Subtype_Indication (Self : Object_Access_Type) return not null Program.Elements.Subtype_Indications .Subtype_Indication_Access is abstract; not overriding function Has_Not_Null (Self : Object_Access_Type) return Boolean is abstract; not overriding function Has_All (Self : Object_Access_Type) return Boolean is abstract; not overriding function Has_Constant (Self : Object_Access_Type) return Boolean is abstract; type Object_Access_Type_Text is limited interface; type Object_Access_Type_Text_Access is access all Object_Access_Type_Text'Class with Storage_Size => 0; not overriding function To_Object_Access_Type_Text (Self : aliased in out Object_Access_Type) return Object_Access_Type_Text_Access is abstract; not overriding function Not_Token (Self : Object_Access_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Null_Token (Self : Object_Access_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Access_Token (Self : Object_Access_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function All_Token (Self : Object_Access_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Constant_Token (Self : Object_Access_Type_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Object_Access_Types;
29,906
ada
2
skordal/ada-regex
tests/regex_test_suite.adb
<reponame>skordal/ada-regex<gh_stars>1-10 -- Ada regular expression library -- (c) <NAME> 2020-2021 <<EMAIL>> -- Report bugs and issues on <https://github.com/skordal/ada-regex> with Regex_Test_Cases; with AUnit.Test_Caller; package body Regex_Test_Suite is package Regex_Test_Caller is new AUnit.Test_Caller (Regex_Test_Cases.Test_Fixture); function Test_Suite return AUnit.Test_Suites.Access_Test_Suite is Retval : constant AUnit.Test_Suites.Access_Test_Suite := new AUnit.Test_Suites.Test_Suite; begin Retval.Add_Test (Regex_Test_Caller.Create ("single-character", Regex_Test_Cases.Test_Single_Character'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("kleene-closure", Regex_Test_Cases.Test_Kleene_Closure'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("concatenation", Regex_Test_Cases.Test_Concatenation'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("alternation-single", Regex_Test_Cases.Test_Alternation_Single'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("alternation-multiple", Regex_Test_Cases.Test_Alternation_Multiple'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("dragon-book", Regex_Test_Cases.Test_Dragon_Example'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-character-single", Regex_Test_Cases.Test_Any_Char_Single'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-character-optional", Regex_Test_Cases.Test_Any_Char_Optional'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("any-alternate", Regex_Test_Cases.Test_Any_Alternate'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("escaped-char", Regex_Test_Cases.Test_Escape_Seqs'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("quotes", Regex_Test_Cases.Test_Quotes'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("single-quotes", Regex_Test_Cases.Test_Single_Quotes'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("single-range", Regex_Test_Cases.Test_Single_Range'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("multiple-ranges", Regex_Test_Cases.Test_Multiple_Ranges'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("ranges-and-chars", Regex_Test_Cases.Test_Ranges_And_Chars'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("plus-operator", Regex_Test_Cases.Test_Plus_Operator'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("hexadecimal", Regex_Test_Cases.Test_Hexadecimal'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("question-mark", Regex_Test_Cases.Test_Question_Operator'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("partial-match", Regex_Test_Cases.Test_Partial_Matching'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("newlines", Regex_Test_Cases.Test_Newlines'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("syntax-tree-compile", Regex_Test_Cases.Test_Syntax_Tree_Compile'Access)); Retval.Add_Test (Regex_Test_Caller.Create ("multiple-accept", Regex_Test_Cases.Test_Multiple_Accept'Access)); return Retval; end Test_Suite; end Regex_Test_Suite;
29,907
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt21_pkg.ads
<gh_stars>1-10 with System; package Opt21_Pkg is type R is record Ptr : System.Address := System.Null_Address; end record; type Obj is access all R; function Get_Object (Object : not null access R) return System.Address; function Convert (W : Obj) return System.Address; end Opt21_Pkg;
29,908
ada
52
onox/orka
orka/src/orka/windows/orka-os.ads
<reponame>onox/orka -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.OS is pragma Preelaborate; procedure Set_Task_Name (Name : in String) with Pre => Name'Length <= 15; function Monotonic_Clock return Duration with Inline; function Monotonic_Clock return Time with Inline; type File_Kind is (Standard_Error, Standard_Output); procedure Put_Line (Value : String; Kind : File_Kind := Standard_Output); end Orka.OS;
29,909
ada
24
svn2github/matreshka
tools/aflex/src/ecs.adb
<gh_stars>10-100 -- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by <NAME> 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 equivalence class -- AUTHOR: <NAME> (UCI) -- DESCRIPTION finds equivalence classes so DFA will be smaller -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/ecsB.a,v 1.7 90/01/12 15:19:54 self Exp Locker: self $ with Misc; with Unicode; package body ECS is use Unicode; -- ccl2ecl - convert character classes to set of equivalence classes procedure CCL2ECL is ICH, NEWLEN, CCLP, CCLMEC : INTEGER; begin for I in 1 .. LASTCCL loop -- we loop through each character class, and for each character -- in the class, add the character's equivalence class to the -- new "character" class we are creating. Thus when we are all -- done, character classes will really consist of collections -- of equivalence classes NEWLEN := 0; CCLP := CCLMAP(I); for CCLS in 0 .. CCLLEN(I) - 1 loop ICH := Unicode_Character'Pos (CCLTBL (CCLP + CCLS)); CCLMEC := ECGROUP(ICH); if (CCLMEC > 0) then CCLTBL(CCLP + NEWLEN) := Unicode_Character'Val (CCLMEC); NEWLEN := NEWLEN + 1; end if; end loop; CCLLEN(I) := NEWLEN; end loop; end CCL2ECL; -- cre8ecs - associate equivalence class numbers with class members -- fwd is the forward linked-list of equivalence class members. bck -- is the backward linked-list, and num is the number of class members. -- Returned is the number of classes. procedure CRE8ECS(FWD : C_SIZE_ARRAY; BCK : in out C_SIZE_ARRAY; NUM : INTEGER; RESULT : out INTEGER) is J, NUMCL : INTEGER; begin NUMCL := 0; -- create equivalence class numbers. From now on, abs( bck(x) ) -- is the equivalence class number for object x. If bck(x) -- is positive, then x is the representative of its equivalence -- class. for I in 1 .. NUM loop if (BCK(I) = NIL) then NUMCL := NUMCL + 1; BCK(I) := NUMCL; J := FWD(I); while (J /= NIL) loop BCK(J) := -NUMCL; J := FWD(J); end loop; end if; end loop; RESULT := NUMCL; return; end CRE8ECS; -- mkeccl - update equivalence classes based on character class xtions -- where ccls contains the elements of the character class, lenccl is the -- number of elements in the ccl, fwd is the forward link-list of equivalent -- characters, bck is the backward link-list, and llsiz size of the link-list procedure MKECCL (CCLS : Unicode_Character_Array; LENCCL : Integer; FWD, BCK : in out UNBOUNDED_INT_ARRAY; LLSIZ : Integer) is CCLP, OLDEC, NEWEC, CCLM, I, J : INTEGER; PROC_ARRAY : BOOLEAN_PTR; begin -- note that it doesn't matter whether or not the character class is -- negated. The same results will be obtained in either case. CCLP := CCLS'FIRST; -- this array tells whether or not a character class has been processed. PROC_ARRAY := new BOOLEAN_ARRAY(CCLS'FIRST .. CCLS'LAST); for CCL_INDEX in CCLS'FIRST .. CCLS'LAST loop PROC_ARRAY(CCL_INDEX) := FALSE; end loop; while (CCLP < LENCCL + CCLS'FIRST) loop CCLM := Unicode_Character'Pos (CCLS (CCLP)); OLDEC := BCK(CCLM); NEWEC := CCLM; J := CCLP + 1; I := FWD(CCLM); while ((I /= NIL) and (I <= LLSIZ)) loop -- look for the symbol in the character class while ((J < LENCCL + CCLS'FIRST) and ((CCLS(J) <= Unicode_Character'Val(I)) or PROC_ARRAY(J))) loop if (CCLS(J) = Unicode_Character'Val (I)) then -- we found an old companion of cclm in the ccl. -- link it into the new equivalence class and flag it as -- having been processed BCK(I) := NEWEC; FWD(NEWEC) := I; NEWEC := I; PROC_ARRAY(J) := TRUE; -- set flag so we don't reprocess -- get next equivalence class member -- continue 2 goto NEXT_PT; end if; J := J + 1; end loop; -- symbol isn't in character class. Put it in the old equivalence -- class BCK(I) := OLDEC; if (OLDEC /= NIL) then FWD(OLDEC) := I; end if; OLDEC := I; <<NEXT_PT>> I := FWD(I); end loop; if ((BCK(CCLM) /= NIL) or (OLDEC /= BCK(CCLM))) then BCK(CCLM) := NIL; FWD(OLDEC) := NIL; end if; FWD(NEWEC) := NIL; -- find next ccl member to process CCLP := CCLP + 1; while ((CCLP < LENCCL + CCLS'FIRST) and PROC_ARRAY(CCLP)) loop -- reset "doesn't need processing" flag PROC_ARRAY(CCLP) := FALSE; CCLP := CCLP + 1; end loop; end loop; exception when STORAGE_ERROR => Misc.Aflex_Fatal ("dynamic memory failure in mkeccl()"); end MKECCL; -- mkechar - create equivalence class for single character procedure MKECHAR(TCH : in INTEGER; FWD, BCK : in out C_SIZE_ARRAY) is begin -- if until now the character has been a proper subset of -- an equivalence class, break it away to create a new ec if (FWD(TCH) /= NIL) then BCK(FWD(TCH)) := BCK(TCH); end if; if (BCK(TCH) /= NIL) then FWD(BCK(TCH)) := FWD(TCH); end if; FWD(TCH) := NIL; BCK(TCH) := NIL; end MKECHAR; end ECS;
29,910
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c43208a.ada
-- C43208A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- FOR A ONE-DIMENSIONAL AGGREGATE OF THE FORM (F..G => (H..I => J)), -- CHECK THAT: -- A) IF F..G IS A NULL RANGE, H, I, AND J ARE NOT EVALUATED. -- B) IF F..G IS A NON-NULL RANGE, H AND I ARE EVALUATED G-F+1 -- TIMES, AND J IS EVALUATED (I-H+1)*(G-F+1) TIMES IF H..I -- IS NON-NULL. -- EG 01/19/84 WITH REPORT; PROCEDURE C43208A IS USE REPORT; BEGIN TEST("C43208A", "CHECK THAT THE EVALUATION OF A ONE-" & "DIMENSIONAL AGGREGATE OF THE FORM " & "(F..G => (H..I = J)) IS PERFORMED " & "CORRECTLY"); DECLARE TYPE CHOICE_INDEX IS (F, G, H, I, J); TYPE CHOICE_CNTR IS ARRAY(CHOICE_INDEX) OF INTEGER; CNTR : CHOICE_CNTR := (CHOICE_INDEX => 0); TYPE T1 IS ARRAY(INTEGER RANGE <>) OF INTEGER; FUNCTION CALC (A : CHOICE_INDEX; B : INTEGER) RETURN INTEGER IS BEGIN CNTR(A) := CNTR(A) + 1; RETURN IDENT_INT(B); END CALC; BEGIN CASE_A : BEGIN CASE_A1 : DECLARE A1 : ARRAY(4 .. 2) OF T1(1 .. 2); BEGIN CNTR := (CHOICE_INDEX => 0); A1 := (4 .. 2 => (CALC(H,1) .. CALC(I,2) => CALC(J,2))); IF CNTR(H) /= 0 THEN FAILED("CASE A1 : H WAS EVALUATED"); END IF; IF CNTR(I) /= 0 THEN FAILED("CASE A1 : I WAS EVALUATED"); END IF; IF CNTR(J) /= 0 THEN FAILED("CASE A1 : J WAS EVALUATED"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE A1 : EXCEPTION RAISED"); END CASE_A1; CASE_A2 : DECLARE A2 : ARRAY(4 .. 2) OF T1(1 .. 2); BEGIN CNTR := (CHOICE_INDEX => 0); A2 := (CALC(F,4) .. CALC(G,2) => (CALC(H,1) .. CALC(I,2) => CALC(J,2))); IF CNTR(H) /= 0 THEN FAILED("CASE A2 : H WAS EVALUATED"); END IF; IF CNTR(I) /= 0 THEN FAILED("CASE A2 : I WAS EVALUATED"); END IF; IF CNTR(J) /= 0 THEN FAILED("CASE A2 : J WAS EVALUATED"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE A2 : EXCEPTION RAISED"); END CASE_A2; END CASE_A; CASE_B : BEGIN CASE_B1 : DECLARE B1 : ARRAY(2 .. 3) OF T1(1 .. 2); BEGIN CNTR := (CHOICE_INDEX => 0); B1 := (2 .. 3 => (CALC(H,1) .. CALC(I,2) => CALC(J,2))); IF CNTR(H) /= 2 THEN FAILED("CASE B1 : H NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(I) /= 2 THEN FAILED("CASE B1 : I NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(J) /= 4 THEN FAILED("CASE B1 : J NOT EVALUATED (I-H+1)*" & "(G-F+1) TIMES"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE B1 : EXECEPTION RAISED"); END CASE_B1; CASE_B2 : DECLARE B2 : ARRAY(2 .. 3) OF T1(9 .. 10); BEGIN CNTR := (CHOICE_INDEX => 0); B2 := (CALC(F,2) .. CALC(G,3) => (CALC(H,9) .. CALC(I,10) => CALC(J,2))); IF CNTR(H) /= 2 THEN FAILED("CASE B2 : H NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(I) /= 2 THEN FAILED("CASE B2 : I NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(J) /= 4 THEN FAILED("CASE B2 : J NOT EVALUATED (I-H+1)*" & "(G-F+1) TIMES"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE B2 : EXECEPTION RAISED"); END CASE_B2; CASE_B3 : DECLARE B3 : ARRAY(2 .. 3) OF T1(2 .. 1); BEGIN CNTR := (CHOICE_INDEX => 0); B3 := (2 .. 3 => (CALC(H,2) .. CALC(I,1) => CALC(J,2))); IF CNTR(H) /= 2 THEN FAILED("CASE B3 : H NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(I) /= 2 THEN FAILED("CASE B3 : I NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(J) /= 0 THEN FAILED("CASE B3 : J NOT EVALUATED ZERO TIMES"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE B3 : EXECEPTION RAISED"); END CASE_B3; CASE_B4 : DECLARE B4 : ARRAY(2 .. 3) OF T1(2 .. 1); BEGIN CNTR := (CHOICE_INDEX => 0); B4 := (CALC(F,2) .. CALC(G,3) => (CALC(H,2) .. CALC(I,1) => CALC(J,2))); IF CNTR(H) /= 2 THEN FAILED("CASE B4 : H NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(I) /= 2 THEN FAILED("CASE B4 : I NOT EVALUATED G-F+1 " & "TIMES"); END IF; IF CNTR(J) /= 0 THEN FAILED("CASE B4 : J NOT EVALUATED ZERO TIMES"); END IF; EXCEPTION WHEN OTHERS => FAILED("CASE B4 : EXECEPTION RAISED"); END CASE_B4; END CASE_B; END; RESULT; END C43208A;
29,911
ada
0
reznikmm/gela
source/nodes/program-nodes-elsif_expression_paths.ads
<filename>source/nodes/program-nodes-elsif_expression_paths.ads -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Elsif_Expression_Paths; with Program.Element_Visitors; package Program.Nodes.Elsif_Expression_Paths is pragma Preelaborate; type Elsif_Expression_Path is new Program.Nodes.Node and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path_Text with private; function Create (Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Condition : not null Program.Elements.Expressions.Expression_Access; Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Expression : not null Program.Elements.Expressions.Expression_Access) return Elsif_Expression_Path; type Implicit_Elsif_Expression_Path is new Program.Nodes.Node and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path with private; function Create (Condition : not null Program.Elements.Expressions .Expression_Access; Expression : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Elsif_Expression_Path with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Elsif_Expression_Path is abstract new Program.Nodes.Node and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path with record Condition : not null Program.Elements.Expressions.Expression_Access; Expression : not null Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : in out Base_Elsif_Expression_Path'Class); overriding procedure Visit (Self : not null access Base_Elsif_Expression_Path; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Condition (Self : Base_Elsif_Expression_Path) return not null Program.Elements.Expressions.Expression_Access; overriding function Expression (Self : Base_Elsif_Expression_Path) return not null Program.Elements.Expressions.Expression_Access; overriding function Is_Elsif_Expression_Path (Self : Base_Elsif_Expression_Path) return Boolean; overriding function Is_Path (Self : Base_Elsif_Expression_Path) return Boolean; type Elsif_Expression_Path is new Base_Elsif_Expression_Path and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path_Text with record Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Elsif_Expression_Path_Text (Self : in out Elsif_Expression_Path) return Program.Elements.Elsif_Expression_Paths .Elsif_Expression_Path_Text_Access; overriding function Elsif_Token (Self : Elsif_Expression_Path) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Then_Token (Self : Elsif_Expression_Path) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Elsif_Expression_Path is new Base_Elsif_Expression_Path with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Elsif_Expression_Path_Text (Self : in out Implicit_Elsif_Expression_Path) return Program.Elements.Elsif_Expression_Paths .Elsif_Expression_Path_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Elsif_Expression_Path) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Elsif_Expression_Path) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Elsif_Expression_Path) return Boolean; end Program.Nodes.Elsif_Expression_Paths;
29,912
ada
1,823
Elon143/Amass
resources/scripts/cert/crtsh.ads
<reponame>Elon143/Amass -- Copyright 2021 <NAME>. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "Crtsh" type = "cert" function start() set_rate_limit(3) end function vertical(ctx, domain) local vurl = "https://crt.sh/?q=" .. domain .. "&output=json" local resp, err = request(ctx, {['url']=vurl}) if (err ~= nil and err ~= "") then log(ctx, "vertical request to service failed: " .. err) return end resp = "{\"subdomains\":" .. resp .. "}" local d = json.decode(resp) if (d == nil or d.subdomains == nil or #(d.subdomains) == 0) then return end for _, r in pairs(d.subdomains) do if (r['common_name'] ~= nil and r['common_name'] ~= "") then new_name(ctx, r['common_name']) end for _, n in pairs(split(r['name_value'], "\\n")) do if (n ~= nil and n ~= "") then new_name(ctx, n) end end end end function split(str, delim) local pattern = "[^%" .. delim .. "]+" local matches = find(str, pattern) if (matches == nil or #matches == 0) then return {str} end local result = {} for _, match in pairs(matches) do table.insert(result, match) end return result end
29,913
ada
192
rocher/Ada_Drivers_Library
components/src/motion/ak8963/ak8963.ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- AK8963 I2C device class package with HAL.I2C; use HAL; with HAL.Time; package AK8963 is type AK8963_Address_Selector is (Add_00, Add_01, Add_10, Add_11); type AK8963_Sampling_Mode is (Mode_14bit, Mode_16bit); subtype Gauss is Float; type AK8963_Operation_Mode is (Power_Down, Single_Measurement, Continuous_1, External_Trigger, Continuous_2, Self_Test, Fuse_ROM_Access); type AK8963_Device (I2C_Port : not null HAL.I2C.Any_I2C_Port; Address_Selector : AK8963_Address_Selector; Time : not null HAL.Time.Any_Delays) is private; procedure Initialize (Device : in out AK8963_Device); function Test_Connection (Device : AK8963_Device) return Boolean; function Self_Test (Device : in out AK8963_Device) return Boolean; procedure Set_Mode (Device : in out AK8963_Device; Operation_Mode : AK8963_Operation_Mode; Sampling_Mode : AK8963_Sampling_Mode); procedure Set_Mode (Device : in out AK8963_Device; Operation_Mode : AK8963_Operation_Mode); function Get_Data_Ready (Device : AK8963_Device) return Boolean; procedure Get_Heading (Device : AK8963_Device; Mx, My, Mz : out Gauss); function Get_Overflow_Status (Device : AK8963_Device) return Boolean; private type AK8963_Device (I2C_Port : not null HAL.I2C.Any_I2C_Port; Address_Selector : AK8963_Address_Selector; Time : not null HAL.Time.Any_Delays) is record Address : UInt10; Is_Init : Boolean := False; end record; for AK8963_Sampling_Mode use (Mode_14bit => 16#00#, Mode_16bit => 16#10#); for AK8963_Operation_Mode use (Power_Down => 16#00#, Single_Measurement => 16#01#, Continuous_1 => 16#02#, External_Trigger => 16#04#, Continuous_2 => 16#06#, Self_Test => 16#08#, Fuse_ROM_Access => 16#0F#); end AK8963;
29,914
ada
0
simonjwright/VL53L1X
ada/stddef_h.ads
<reponame>simonjwright/VL53L1X pragma Ada_2012; pragma Style_Checks (Off); pragma Warnings ("U"); with Interfaces.C; use Interfaces.C; with System; package stddef_h is -- unsupported macro: NULL __null -- arg-macro: procedure offsetof (TYPE, MEMBER) -- __builtin_offsetof (TYPE, MEMBER) subtype ptrdiff_t is int; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:143 subtype size_t is unsigned; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:209 -- skipped anonymous struct anon_anon_0 type max_align_t is record uu_max_align_ll : aliased Long_Long_Integer; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:416 uu_max_align_ld : aliased long_double; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:417 end record with Convention => C_Pass_By_Copy; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:426 subtype nullptr_t is System.Address; -- /opt/gcc-11.2.0/lib/gcc/arm-eabi/11.2.0/include/stddef.h:433 end stddef_h;
29,915
ada
192
rocher/Ada_Drivers_Library
boards/native/src/filesystem-native.adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package provides a low level driver to access the native file system. -- It is recommended to _not_ use this interface directly but to access the -- file system using the File_IO package. For more info, see the file system -- chapter of the documentation. with Ada.Directories; with Ada.Unchecked_Deallocation; package body Filesystem.Native is -- ??? There are a bunch of 'Unrestricted_Access here because the -- HAL.Filesystem API embeds implicit references to filesystems. It -- woudl be good to make these references explicit at some point to -- avoid kludges. function "+" (S : Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; function "+" (S : String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; procedure Destroy is new Ada.Unchecked_Deallocation (File_Handle, File_Handle_Access); procedure Destroy is new Ada.Unchecked_Deallocation (Directory_Handle, Directory_Handle_Access); procedure Destroy is new Ada.Unchecked_Deallocation (Node_Handle, Node_Handle_Access); function "<" (Left, Right : Node_Handle) return Boolean is (Ada.Strings.Unbounded."<" (Left.Name, Right.Name)); package Node_Sorting is new Node_Vectors.Generic_Sorting; -- Most of the time, standard operations give us no reliable way to -- determine specifically what triggered a failure, so use the following -- error code as a "generic" one. Generic_Error : constant Status_Code := Input_Output_Error; function Absolute_Path (This : Native_FS_Driver; Relative_Path : String) return String is (if Relative_Path = "" then +This.Root_Dir else Join (+This.Root_Dir, Relative_Path, True)); ---------------- -- Get_Handle -- ---------------- function Get_Handle (FS : in out Native_FS_Driver) return File_Handle_Access is Result : File_Handle_Access := FS.Free_File_Handles; begin if Result = null then Result := new File_Handle' (FS => FS'Unrestricted_Access, others => <>); else FS.Free_File_Handles := Result.Next; end if; return Result; end Get_Handle; ---------------- -- Get_Handle -- ---------------- function Get_Handle (FS : in out Native_FS_Driver) return Directory_Handle_Access is Result : Directory_Handle_Access := FS.Free_Dir_Handles; begin if Result = null then Result := new Directory_Handle' (FS => FS'Unrestricted_Access, others => <>); else FS.Free_Dir_Handles := Result.Next; end if; return Result; end Get_Handle; --------------------- -- Add_Free_Handle -- --------------------- procedure Add_Free_Handle (FS : in out Native_FS_Driver; Handle : in out File_Handle_Access) is begin Handle.Next := FS.Free_File_Handles; FS.Free_File_Handles := Handle; Handle := null; end Add_Free_Handle; --------------------- -- Add_Free_Handle -- --------------------- procedure Add_Free_Handle (FS : in out Native_FS_Driver; Handle : in out Directory_Handle_Access) is begin Handle.Next := FS.Free_Dir_Handles; FS.Free_Dir_Handles := Handle; Handle := null; end Add_Free_Handle; ------------- -- Destroy -- ------------- procedure Destroy (This : in out Native_FS_Driver_Access) is procedure Destroy is new Ada.Unchecked_Deallocation (Native_FS_Driver, Native_FS_Driver_Access); begin -- Free all handles while This.Free_File_Handles /= null loop declare H : constant File_Handle_Access := This.Free_File_Handles.Next; begin Destroy (This.Free_File_Handles); This.Free_File_Handles := H; end; end loop; while This.Free_Dir_Handles /= null loop declare H : constant Directory_Handle_Access := This.Free_Dir_Handles.Next; begin Destroy (This.Free_Dir_Handles); This.Free_Dir_Handles := H; end; end loop; Destroy (This); end Destroy; ------------ -- Create -- ------------ function Create (FS : out Native_FS_Driver; Root_Dir : String) return Status_Code is begin declare use type Ada.Directories.File_Kind; begin if Ada.Directories.Kind (Root_Dir) /= Ada.Directories.Directory then return Invalid_Parameter; end if; exception when Ada.Directories.Name_Error => return Invalid_Parameter; end; FS.Root_Dir := Ada.Strings.Unbounded.To_Unbounded_String (Root_Dir); return OK; end Create; ----------------- -- Create_Node -- ----------------- function Create_Node (This : in out Native_FS_Driver; Path : String; Kind : File_Kind) return Status_Code is Abs_Path : constant String := Absolute_Path (This, Path); begin case Kind is when Regular_File => declare File : Byte_IO.File_Type; begin begin Byte_IO.Create (File, Byte_IO.Out_File, Abs_Path); exception when Byte_IO.Status_Error | Byte_IO.Name_Error | Byte_IO.Use_Error => return Generic_Error; end; Byte_IO.Close (File); end; when Directory => begin Ada.Directories.Create_Directory (Abs_Path); exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => return Generic_Error; end; end case; return OK; end Create_Node; ---------------------- -- Create_Directory -- ---------------------- function Create_Directory (This : in out Native_FS_Driver; Path : String) return Status_Code is begin return This.Create_Node (Absolute_Path (This, Path), Directory); end Create_Directory; ----------------- -- Create_File -- ----------------- overriding function Create_File (This : in out Native_FS_Driver; Path : String) return Status_Code is begin return This.Create_Node (Path, Regular_File); end Create_File; ------------ -- Unlink -- ------------ overriding function Unlink (This : in out Native_FS_Driver; Path : String) return Status_Code is begin Ada.Directories.Delete_File (Absolute_Path (This, Path)); return OK; exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => return Generic_Error; end Unlink; ---------------------- -- Remove_Directory -- ---------------------- overriding function Remove_Directory (This : in out Native_FS_Driver; Path : String) return Status_Code is begin Ada.Directories.Delete_Directory (Absolute_Path (This, Path)); return OK; exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => return Generic_Error; end Remove_Directory; ------------ -- Get_FS -- ------------ overriding function Get_FS (This : Directory_Handle) return Any_Filesystem_Driver is (Any_Filesystem_Driver (This.FS)); --------------- -- Root_Node -- --------------- overriding function Root_Node (This : in out Native_FS_Driver; As : String; Handle : out Any_Node_Handle) return Status_Code is Ret : constant Node_Handle_Access := new Node_Handle; begin Ret.FS := This'Unchecked_Access; Ret.Kind := Directory; Ret.Name := +As; Ret.Read_Only := False; Ret.Hidden := False; Ret.Symlink := False; Ret.Size := 0; Handle := Any_Node_Handle (Ret); return OK; end Root_Node; ---------- -- Read -- ---------- overriding function Read (This : in out Directory_Handle; Handle : out Any_Node_Handle) return Status_Code is Ret : Node_Handle_Access; begin if This.Index > This.Data.Last_Index then Handle := null; return No_More_Entries; else Ret := new Node_Handle; Ret.all := This.Data.Element (This.Index); Handle := Any_Node_Handle (Ret); This.Index := This.Index + 1; return OK; end if; end Read; ------------ -- Rename -- ------------ function Rename (This : in out Native_FS_Driver; Old_Path : String; New_Path : String) return Status_Code is Old_Abs_Path : constant String := Absolute_Path (This, Old_Path); New_Abs_Path : constant String := Absolute_Path (This, New_Path); begin Ada.Directories.Rename (Old_Abs_Path, New_Abs_Path); return OK; exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => return Generic_Error; end Rename; ------------------- -- Truncate_File -- ------------------- function Truncate_File (This : in out Native_FS_Driver; Path : String; Length : File_Size) return Status_Code is pragma Unreferenced (This, Path, Length); begin -- ??? Implement this. This is not done at the moment as there seems to -- be no other way using standard Ada packages than do delete the file -- and re-create it. return Generic_Error; end Truncate_File; ---------- -- Open -- ---------- overriding function Open (This : in out Native_FS_Driver; Path : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code is Result : File_Handle_Access := This.Get_Handle; begin begin Byte_IO.Open (File => Result.File, Mode => (case Mode is when Read_Only => Byte_IO.In_File, when Write_Only => Byte_IO.Out_File, when Read_Write => Byte_IO.Inout_File), Name => Absolute_Path (This, Path)); exception when Byte_IO.Status_Error | Byte_IO.Name_Error | Byte_IO.Use_Error => Destroy (Result); return Generic_Error; end; Result.Mode := Mode; Handle := Result.all'Access; return OK; end Open; ---------- -- Open -- ---------- overriding function Open (This : Node_Handle; Name : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code is begin raise Program_Error with "Not implemented..."; return Input_Output_Error; end Open; ---------- -- Open -- ---------- overriding function Open (This : in out Native_FS_Driver; Path : String; Handle : out Any_Directory_Handle) return Status_Code is use Ada.Strings.Unbounded; Result : Directory_Handle_Access := This.Get_Handle; Search : Ada.Directories.Search_Type; begin begin Ada.Directories.Start_Search (Search, Absolute_Path (This, Path), ""); exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => This.Add_Free_Handle (Result); return Generic_Error; end; Result.Full_Name := +Path; while Ada.Directories.More_Entries (Search) loop declare use type Ada.Directories.File_Kind; E : Ada.Directories.Directory_Entry_Type; Kind : Ada.Directories.File_Kind; Name : Unbounded_String; begin Ada.Directories.Get_Next_Entry (Search, E); Kind := Ada.Directories.Kind (E); Name := +Ada.Directories.Simple_Name (E); -- HAL.Filesystem does not support special files, so just ignores -- them. As for current and parent directories entries, skip them -- for now as this makes tree traversal cumbersome to write. if Kind /= Ada.Directories.Special_File and then +Name /= "." and then +Name /= ".." then Result.Data.Append ((FS => This'Unchecked_Access, Kind => (case Kind is when Ada.Directories.Ordinary_File => Regular_File, when Ada.Directories.Directory => Directory, when others => raise Program_Error), Name => Name, Read_Only => False, Hidden => False, Symlink => False, Size => (if Kind = Ada.Directories.Ordinary_File then File_Size (Ada.Directories.Size (E)) else 0))); end if; end; end loop; Ada.Directories.End_Search (Search); -- Make sure entries are sorted so that we get determinism. This is -- convenient for testing. Node_Sorting.Sort (Result.Data); Result.Index := Result.Data.First_Index; Handle := Result.all'Access; return OK; end Open; ------------ -- Get_FS -- ------------ overriding function Get_FS (This : in out File_Handle) return Any_Filesystem_Driver is (Any_Filesystem_Driver (This.FS)); ---------- -- Size -- ---------- overriding function Size (This : File_Handle) return File_Size is (File_Size (Byte_IO.Size (This.File))); ---------- -- Mode -- ---------- overriding function Mode (This : File_Handle) return File_Mode is (This.Mode); ---------- -- Read -- ---------- overriding function Read (This : in out File_Handle; Addr : System.Address; Length : in out File_Size) return Status_Code is Data : UInt8_Array (1 .. Natural (Length)) with Address => Addr; Ret : File_Size := 0; begin for B of Data loop Byte_IO.Read (This.File, B); Ret := Ret + 1; end loop; Length := Ret; return OK; exception when Byte_IO.End_Error => Length := Ret; return OK; when Byte_IO.Mode_Error | Byte_IO.Data_Error => Length := Ret; return Generic_Error; end Read; ----------- -- Write -- ----------- overriding function Write (This : in out File_Handle; Addr : System.Address; Length : File_Size) return Status_Code is Data : UInt8_Array (1 .. Natural (Length)) with Address => Addr; begin for B of Data loop Byte_IO.Write (This.File, B); end loop; return OK; exception when Byte_IO.Mode_Error | Byte_IO.Use_Error => return Generic_Error; end Write; ------------ -- Offset -- ------------ overriding function Offset (This : File_Handle) return File_Size is begin return File_Size (Byte_IO.Index (This.File)); end Offset; ----------- -- Flush -- ----------- overriding function Flush (This : in out File_Handle) return Status_Code is begin Byte_IO.Flush (This.File); return OK; end Flush; ---------- -- Seek -- ---------- overriding function Seek (This : in out File_Handle; Origin : Seek_Mode; Amount : in out File_Size) return Status_Code is use type Byte_IO.Positive_Count; Index : Byte_IO.Positive_Count; begin case Origin is when From_Start => Index := Byte_IO.Positive_Count (Amount + 1); when From_End => Index := Byte_IO.Size (This.File) - Byte_IO.Count (Amount); when Forward => Index := Byte_IO.Index (This.File) + Byte_IO.Positive_Count (Amount); when Backward => Index := Byte_IO.Index (This.File) - Byte_IO.Positive_Count (Amount); end case; Byte_IO.Set_Index (This.File, Index); return OK; end Seek; ----------- -- Close -- ----------- overriding procedure Close (This : in out File_Handle) is This_Access : File_Handle_Access := This'Unrestricted_Access; begin begin Byte_IO.Close (This.File); exception when Byte_IO.Status_Error => null; end; This_Access.FS.Add_Free_Handle (This_Access); end Close; ----------- -- Close -- ----------- overriding procedure Close (This : in out Native_FS_Driver) is Tmp : Native_FS_Driver_Access := This'Unchecked_Access; begin Destroy (Tmp); end Close; ----------- -- Reset -- ----------- overriding procedure Reset (This : in out Directory_Handle) is begin This.Index := This.Data.First_Index; end Reset; ----------- -- Close -- ----------- overriding procedure Close (This : in out Directory_Handle) is This_Access : Directory_Handle_Access := This'Unrestricted_Access; begin This.Data.Clear; This_Access.FS.Add_Free_Handle (This_Access); end Close; --------------------- -- Node operations -- --------------------- ------------ -- Get_FS -- ------------ overriding function Get_FS (This : Node_Handle) return Any_Filesystem_Driver is (Any_Filesystem_Driver (This.FS)); -------------- -- Basename -- -------------- overriding function Basename (This : Node_Handle) return String is (+This.Name); ------------------ -- Is_Read_Only -- ------------------ overriding function Is_Read_Only (This : Node_Handle) return Boolean is (This.Read_Only); --------------- -- Is_Hidden -- --------------- overriding function Is_Hidden (This : Node_Handle) return Boolean is (This.Hidden); --------------------- -- Is_Subdirectory -- --------------------- overriding function Is_Subdirectory (This : Node_Handle) return Boolean is (This.Kind = Directory); ---------------- -- Is_Symlink -- ---------------- overriding function Is_Symlink (This : Node_Handle) return Boolean is (This.Symlink); ---------- -- Size -- ---------- overriding function Size (This : Node_Handle) return File_Size is (This.Size); ----------- -- Close -- ----------- overriding procedure Close (This : in out Node_Handle) is Hack : Node_Handle_Access := This'Unchecked_Access; begin Destroy (Hack); end Close; ---------- -- Join -- ---------- function Join (Prefix, Suffix : String; Ignore_Absolute_Suffixes : Boolean) return String is use Ada.Strings.Unbounded; package String_Vectors is new Ada.Containers.Vectors (Positive, Unbounded_String); Result : Unbounded_String := +Prefix; Names : String_Vectors.Vector; begin -- First, decompose Suffix into individual names: the following pushes -- the most local directory names first, then the most global ones. For -- instance, "a/b/c" will gives: Name => ("c", "b", "a"). declare Suffix_Acc : Unbounded_String := +Suffix; begin while Length (Suffix_Acc) > 0 loop begin declare Suffix : constant String := +Suffix_Acc; Next_Suffix : constant String := Ada.Directories.Containing_Directory (Suffix); Name : constant String := Ada.Directories.Simple_Name (Suffix); begin -- The following happens when Suffix is "." (the current -- directory). exit when Suffix = Next_Suffix; Names.Append (+Name); Suffix_Acc := +Next_Suffix; end; exception when Ada.Directories.Use_Error => -- Suffix is actually an absolute path. Forget about it and -- process it as a relative one. exit when Ignore_Absolute_Suffixes; return Suffix; end; end loop; end; -- Then, compose them using Ada.Directories.Compose so we have our -- result. for Name of reverse Names loop Result := +Ada.Directories.Compose (+Result, +Name); end loop; return +Result; end Join; end Filesystem.Native;
29,916
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/pointer_discr1_pkg1.ads
with Pointer_Discr1_Pkg2; package Pointer_Discr1_Pkg1 is type Arr is array (1..4) of Pointer_Discr1_Pkg2.T_WINDOW; Window : Arr; end Pointer_Discr1_Pkg1;
29,917
ada
0
Roldak/OpenGLAda
deps/gid/gid-decoding_jpg.ads
private package GID.Decoding_JPG is use JPEG_defs; type JPEG_marker is ( SOI , -- Start Of Image -- SOF_0 , -- Start Of Frame - Baseline DCT SOF_1 , -- Extended sequential DCT SOF_2 , -- Progressive DCT SOF_3 , -- Lossless (sequential) SOF_5 , -- Differential sequential DCT SOF_6 , -- Differential progressive DCT SOF_7 , -- Differential lossless (sequential) SOF_8 , -- Reserved for JPEG extensions SOF_9 , -- Extended sequential DCT SOF_10 , -- Progressive DCT SOF_11 , -- Lossless (sequential) SOF_13 , -- Differential sequential DCT SOF_14 , -- Differential progressive DCT SOF_15 , -- Differential lossless (sequential) -- DHT , -- Define Huffman Table DAC , -- Define Arithmetic Coding DQT , -- Define Quantization Table DRI , -- Define Restart Interval -- APP_0 , -- JFIF - JFIF JPEG image - AVI1 - Motion JPEG (MJPG) APP_1 , -- EXIF Metadata, TIFF IFD format, JPEG Thumbnail (160x120) APP_2 , -- ICC color profile, FlashPix APP_3 , APP_4 , APP_5 , APP_6 , APP_7 , APP_8 , APP_9 , APP_10 , APP_11 , APP_12 , -- Picture Info APP_13 , -- Photoshop Save As: IRB, 8BIM, IPTC APP_14 , -- Copyright Entries -- COM , -- Comments SOS , -- Start of Scan EOI -- End of Image ); YCbCr_set : constant Compo_set:= (Y|Cb|Cr => True, others => False); Y_Grey_set: constant Compo_set:= (Y => True, others => False); CMYK_set : constant Compo_set:= (Y|Cb|Cr|I => True, others => False); type Segment_head is record length : U16; kind : JPEG_marker; end record; procedure Read(image: in out Image_descriptor; sh: out Segment_head); -- SOF - Start Of Frame (the real header) procedure Read_SOF(image: in out Image_descriptor; sh: Segment_head); procedure Read_DHT(image: in out Image_descriptor; data_length: Natural); procedure Read_DQT(image: in out Image_descriptor; data_length: Natural); procedure Read_DRI(image: in out Image_descriptor); procedure Read_EXIF(image: in out Image_descriptor; data_length: Natural); -------------------- -- Image decoding -- -------------------- generic type Primary_color_range is mod <>; with procedure Set_X_Y (x, y: Natural); with procedure Put_Pixel ( red, green, blue : Primary_color_range; alpha : Primary_color_range ); with procedure Feedback (percents: Natural); -- mode: Display_mode; -- nice -> progressive nicely displayed -- procedure Load ( image : in out Image_descriptor; next_frame: out Ada.Calendar.Day_Duration ); end GID.Decoding_JPG;
29,918
ada
88
VVCAS-Sean/OpenUxAS
src/ada/src/comms/uxas-comms-lmcp_net_client.ads
<reponame>VVCAS-Sean/OpenUxAS -- see OpenUxAS\src\Communications\LmcpObjectNetworkClientBase.h with DOM.Core; with AVTAS.LMCP.Object; use AVTAS.LMCP.Object; with UxAS.Comms.Data.LMCP_Messages; use UxAS.Comms.Data.LMCP_Messages; with UxAS.Comms.LMCP_Object_Message_Sender_Pipes; use UxAS.Comms.LMCP_Object_Message_Sender_Pipes; with UxAS.Comms.LMCP_Object_Message_Receiver_Pipes; use UxAS.Comms.LMCP_Object_Message_Receiver_Pipes; with UxAS.Comms.Data.Addressed.Attributed; use UxAS.Comms.Data.Addressed.Attributed; package UxAS.Comms.LMCP_Net_Client is pragma Elaborate_Body; type LMCP_Object_Network_Client_Base is abstract tagged limited private; type LMCP_Object_Network_Client_Base_Reference is access all LMCP_Object_Network_Client_Base; type Any_LMCP_Object_Network_Client_Base is access all LMCP_Object_Network_Client_Base'Class; procedure Construct_Client (This : in out LMCP_Object_Network_Client_Base); -- the ctor, must be manually called in the SPARK version since no Controlled types allowed type Receive_Processing_Type is (LMCP, Serialized_LMCP); -- LMCP objects are de-serialized -- Serialized_LMCP objects are not de-serialized -- s_entityIdPrefix() { static std::string s_string("eid"); return (s_string); }; function Entity_Id_Prefix return String; -- s_serviceIdPrefix string (leading characters for indicating that a service ID follows) -- @return -- -- static std::string& -- s_serviceIdPrefix() { static std::string s_string(".sid"); return (s_string); }; function Service_Id_Prefix return String; -- s_serviceIdAllSuffix string (trailing characters that are appended to entity cast address -- to form cast-to-all services of a specific entity) -- @return -- -- static std::string& -- s_serviceIdAllSuffix() { static std::string s_string(".sidall"); return (s_string); }; function Service_Id_All_Suffix return String; -- Multi-cast entity-based subscription address string -- -- @param entityId UxAS entity ID. -- @return address string to used to send a message to all services hosted by -- a particular UxAS entity. -- -- static std::string -- getEntityCastAddress(const uint32_t entityId) function Entity_Cast_Address (Entity_Id : UInt32) return String; -- Multi-cast subscription address string that addresses a message -- to all services of a specific entity. -- -- @param entityId UxAS entity ID. -- @return address string to used to send a message to all services hosted by -- a particular UxAS entity. -- -- static std::string -- getEntityServicesCastAllAddress(const uint32_t entityId) function Get_Entity_Services_Cast_All_Address (Entity_Id : UInt32) return String; -- Uni-cast service-based subscription address string -- -- @param entityId UxAS entity ID. -- @param networkClientId UxAS bridge or service ID. -- @return address string to used to send a message to a specific service -- hosted by a particular UxAS entity. -- function Network_Client_Unicast_Address (Entity_Id : UInt32; Network_Client_Id : Int64) return String; -- Multi-cast entity-based subscription address string -- -- @param entityId UxAS entity ID. -- @return address string to used to send a message to all services hosted by -- a particular UxAS entity. -- -- static std::string -- getEntityCastAddress(const std::string entityId) function Entity_Cast_Address (Entity_Id : String) return String; -- Uni-cast service-based subscription address string -- -- @param entityId UxAS entity ID. -- @param networkClientId UxAS bridge or service ID. -- @return address string to used to send a message to a specific service -- hosted by a particular UxAS entity. -- -- static std::string -- getNetworkClientUnicastAddress(const uint32_t entityId, const std::string networkClientId) function Get_Network_Client_Unicast_Address (Entity_Id : UInt32; Network_Client_Id : String) return String; -- Uni-cast service-based subscription address string -- -- @param entityId UxAS entity ID. -- @param networkClientId UxAS bridge or service ID. -- @return address string to used to send a message to a specific service -- hosted by a particular UxAS entity. -- -- static std::string -- getNetworkClientUnicastAddress(const std::string& entityId, const std::string& networkClientId) function Get_Network_Client_Unicast_Address (Entity_Id : String; Network_Client_Id : String) return String; -- static std::string -- getNetworkClientUnicastAddress(const std::string& entityId, const int64_t& networkClientId) function Get_Network_Client_Unicast_Address (Entity_Id : String; Network_Client_Id : Int64) return String; -- static int64_t -- getUniqueEntitySendMessageId() procedure Get_Unique_Entity_Send_Message_Id (Value : out Int64); -- The getUniqueNetworkClientId returns a unique service ID. -- It returns the ID from a call to getUniqueNetworkClientId(), which are used as service IDs -- -- @return unique service ID. -- -- static int64_t -- getUniqueNetworkClientId() procedure Get_Unique_Network_Client_Id (Value : out Int64); -- Type name for the LmcpObjectNetworkClientBase class -- static const std::string& -- s_typeName() Type_Name : constant String := "LmcpObjectNetworkClientBase"; -- protected: but made public for sake of subclasses outside the package hierarchy ----------- -- -- To be overridden by subclasses -- The virtual configure method is invoked by the -- LmcpObjectNetworkClientBase class after completing its -- own configuration. -- -- @param xmlNode XML node containing object configurations. -- @return true if configuration succeeds; false if configuration fails. -- -- virtual -- bool -- configure(const pugi::xml_node& xmlNode) { return (true); }; procedure Configure (This : in out LMCP_Object_Network_Client_Base; XML_Node : DOM.Core.Element; Result : out Boolean) is abstract; -- The virtual initialize method is invoked by the -- LmcpObjectNetworkClientBase class after completing -- configurations and before startup. -- -- @return true if initialization succeeds; false if initialization fails. -- -- virtual -- bool -- initialize() -- { return (true); }; procedure Initialize (This : in out LMCP_Object_Network_Client_Base; Result : out Boolean); -- The virtual start method is invoked by the -- LmcpObjectNetworkClientBase class after initialization and -- before starting its own thread. -- -- @return true if start succeeds; false if start fails. -- -- virtual -- bool -- start() { return (true); }; procedure Start (This : in out LMCP_Object_Network_Client_Base; Result : out Boolean); -- The virtual terminate method can be implemented by -- inheriting classes to perform inheriting class termination logic -- (e.g., thread joining). -- -- virtual -- bool -- terminate() { return (true); }; procedure Stop (This : in out LMCP_Object_Network_Client_Base; Result : out Boolean); -- The virtual processReceivedLmcpMessage is -- repeatedly invoked by the LmcpObjectNetworkClientBase class in an -- infinite loop until termination. -- -- @param receivedLmcpObject received LMCP object. -- @return true if object is to terminate; false if object is to continue processing. -- -- virtual -- bool -- processReceivedLmcpMessage -- (std::unique_ptr<uxas::communications::data::LmcpMessage> receivedLmcpMessage) { return (false); }; procedure Process_Received_LMCP_Message (This : in out LMCP_Object_Network_Client_Base; Received_Message : not null Any_LMCP_Message; Should_Terminate : out Boolean); -- The virtual processReceivedSerializedLmcpMessage is -- repeatedly invoked by the LmcpObjectNetworkClientBase class in an -- infinite loop until termination. The payload of the AddressedAttributedMessage -- is a serialized LMCP object. -- -- @param receivedSerializedLmcpObject received AddressedAttributedMessage object with serialized LMCP object payload. -- @return true if object is to terminate; false if object is to continue processing. -- -- virtual -- bool -- processReceivedSerializedLmcpMessage -- (std::unique_ptr<uxas::communications::data::AddressedAttributedMessage> receivedSerializedLmcpMessage) { return (false); }; procedure Process_Received_Serialized_LMCP_Message (This : in out LMCP_Object_Network_Client_Base; Received_Message : not null Any_Addressed_Attributed_Message; Should_Terminate : out Boolean); -- end protected: ------------------------------------------------- -- The configureNetworkClient method must be invoked -- before calling the initializeAndStart -- method. It performs LmcpObjectNetworkClientBase-specific configuration -- and invokes the configure virtual method. -- -- @param subclassTypeName type name of the inheriting class. -- @param receiveProcessingType enumeration determining whether or not received LMCP message will be de-serialized. -- @param networkXmlNode XML node containing object configurations. -- @return true if configuration succeeds; false if configuration fails. -- -- bool -- configureNetworkClient -- (const std::string& subclassTypeName, ReceiveProcessingType receiveProcessingType, const pugi::xml_node& networkClientXmlNode); procedure Configure_Network_Client (This : in out LMCP_Object_Network_Client_Base; Subclass_Type_Name : String; Processing_Kind : Receive_Processing_Type; Network_Client_XML_Node : DOM.Core.Element; Result : out Boolean); -- The initializeAndStart routine must be invoked -- after calling the configureNetworkClient method. -- It performs the following steps: -- * LmcpObjectNetworkClientBase-specific initialization -- * inheriting class initialization (calls initialize virtual method) -- * inheriting class startup (calls start virtual method) -- * LmcpObjectNetworkClientBase-specific startup -- -- @return true if all initialization and startup succeeds; false if initialization or startup fails. -- -- bool -- initializeAndStart(); procedure Initialize_And_Start (This : in out LMCP_Object_Network_Client_Base; Result : out Boolean); -- bool -- getIsTerminationFinished() { return(m_isBaseClassTerminationFinished && m_isSubclassTerminationFinished); } function Is_Termination_Finished (This : LMCP_Object_Network_Client_Base) return Boolean; -- The addSubscriptionAddress can be invoked -- at any time to add specified message subscription address. -- -- @param address message subscription value -- @return true if address is added; false if address is not added. -- -- bool -- addSubscriptionAddress(const std::string& address); procedure Add_Subscription_Address (This : in out LMCP_Object_Network_Client_Base; Address : String; Success : out Boolean); -- The removeSubscriptionAddress can be invoked at any time to remove the -- specified message subscription address. -- -- @param address message subscription address -- @return true if address is removed; false if address is not removed. -- -- bool -- removeSubscriptionAddress(const std::string& address); procedure Remove_Subscription_Address (This : in out LMCP_Object_Network_Client_Base; Address : String; Success : out Boolean); -- The removeAllSubscriptionAddresses can be invoked at any time to remove -- message subscription addresses. -- -- @param address message subscription address -- @return true if address is removed; false if address is not removed. -- -- bool -- removeAllSubscriptionAddresses(); procedure Remove_All_Subscription_Addresses (This : in out LMCP_Object_Network_Client_Base; Success : out Boolean); -- The sendLmcpObjectLimitedCastMessage method can be -- invoked to send a uni-cast or multi-cast LMCP object message to the LMCP network. -- -- @param castAddress message publish address -- @param lmcpObject LMCP object to be uni-casted/multi-casted. -- -- void -- sendLmcpObjectLimitedCastMessage(const std::string& castAddress, std::unique_ptr<AVTAS::lmcp::Object> lmcpObject); procedure Send_LMCP_Object_Limited_Cast_Message (This : in out LMCP_Object_Network_Client_Base; CastAddress : String; Msg : not null AVTAS.LMCP.Object.Object_Any); -- These were public member data in the C++ version so we provide accessors. -- TODO: consider using discriminants for some of them. -- Unique ID for UxAS entity instance; value read from configuration XML -- uint32_t m_entityId; function Entity_Id (This : LMCP_Object_Network_Client_Base) return UInt32; -- String representation of the unique ID for UxAS entity instance; value read from configuration XML -- std::string m_entityIdString; function Entity_Id_String (This : LMCP_Object_Network_Client_Base) return String; -- Unique ID of the LMCP object communication network actor (e.g., bridge or service). -- int64_t m_networkId; function Network_Id (This : LMCP_Object_Network_Client_Base) return Int64; -- String representation of the unique ID of the LMCP object communication network actor (e.g., bridge or service). -- std::string m_networkIdString; function Network_Id_String (This : LMCP_Object_Network_Client_Base) return String; -- Unicast message address for messaging case of sending message to only this network client instance -- std::string m_entityIdNetworkIdUnicastString; function Entity_Id_Network_Id_Unicast_String (This : LMCP_Object_Network_Client_Base) return String; -- Name of subclass used for logging/messaging. -- std::string m_networkClientTypeName; function Network_Client_Type_Name (This : LMCP_Object_Network_Client_Base) return String; private -- The static member data in the C++ base class is duplicated in the Ada -- process via this implementation of the base class but is not coordinated. -- That is, both the Ada process and the C++ UxAS process have this base class -- present even though in our demo the C++ version doesn't have the validator -- subclass enabled. The base class has static member values that are -- incremented and used by the subclasses, such as the unique ID for -- automation requests, and the service id numbers. Hence they are duplicated. -- -- We hack this by hardcoding starting values in the Ada version that are far -- above what the C++ code will reach, thus ensuring they remain unique across -- the two versions. -- static int64_t s_uniqueEntitySendMessageId; Unique_Entity_Send_Message_Id : Int64 := 10_000; --1; -- For the Next_Network_Client_Id we could include all the services in -- the demo xml, and thus know how many would be in the C++ side, and then -- use that info to determine the ID for the validator, but a really large -- number should be OK for a temporary solution. -- static ID of network clients, used to create unique IDs. -- static uint32_t s_nextNetworkClientId; Next_Network_Client_Id : Int64 := 1000; -- 10; -- static entity service cast address. -- static std::string s_entityServicesCastAllAddress; Entity_Services_Cast_All_Address : Dynamic_String (Capacity => Cast_All_Address_Max_Length); task type Network_Client_Processor (Client : not null access LMCP_Object_Network_Client_Base); type Client_Thread_Reference is access Network_Client_Processor; -- we use a pointer to the tasks, rather than simply having the task object -- be a component of the record type, for the sake of potential SPARKifying type LMCP_Object_Network_Client_Base is abstract tagged limited record -- bool m_isConfigured{false}; Is_Configured : Boolean := False; -- bool m_isThreadStarted{false}; Is_Thread_Started : Boolean := False; -- ReceiveProcessingType m_receiveProcessingType; Processing_Type : Receive_Processing_Type := LMCP; -- Unique ID for UxAS entity instance; value read from configuration XML -- uint32_t m_entityId; Entity_Id : UInt32; -- String representation of the unique ID for UxAS entity instance; value read from configuration XML -- std::string m_entityIdString; Entity_Id_String : Dynamic_String (Capacity => Entity_Id_Max_Length); -- Unique ID of the LMCP object communication network actor (e.g., bridge or service). -- int64_t m_networkId; Network_Id : Int64; -- String representation of the unique ID of the LMCP object communication network actor (e.g., bridge or service). -- std::string m_networkIdString; Network_Id_String : Dynamic_String (Capacity => Network_Id_Max_Length); -- Unicast message address for messaging case of sending message to only this network client instance -- std::string m_entityIdNetworkIdUnicastString; Entity_Id_Network_Id_Unicast_String : Dynamic_String (Capacity => Unicast_Message_Max_Length); -- Name of subclass used for logging/messaging. -- std::string m_networkClientTypeName; Network_Client_Type_Name : Dynamic_String (Capacity => Network_Client_Type_Name_Max_Length); -- Pointer to the component's thread. -- std::unique_ptr<std::thread> m_networkClientThread; Network_Client_Thread : Client_Thread_Reference; -- std::set<std::string> m_preStartLmcpSubscriptionAddresses; Pre_Start_LMCP_Subscription_Addresses : Subscription_Address_Set; -- uxas::communications::LmcpObjectMessageReceiverPipe m_lmcpObjectMessageReceiverPipe; Message_Receiver_Pipe : LMCP_Object_Message_Receiver_Pipe; -- uxas::communications::LmcpObjectMessageSenderPipe m_lmcpObjectMessageSenderPipe; Message_Sender_Pipe : LMCP_Object_Message_Sender_Pipe; -- Multi-cast group address that is subscribed to and included in sent messages -- std::string m_messageSourceGroup; Message_Source_Group : Dynamic_String (Capacity => Msg_Source_Group_Max_Length); -- Type of UxAS entity instance; value read from configuration XML -- std::string m_entityType; Entity_Type : Dynamic_String (Capacity => Entity_Type_Max_Length); -- std::atomic<bool> m_isBaseClassKillServiceProcessingPermitted{true}; Is_Base_Class_Kill_Service_Processing_Permitted : Boolean := True with Atomic; -- std::atomic<bool> m_isTerminateNetworkClient{false}; Is_Terminate_Network_Client : Boolean := False with Atomic; -- std::atomic<bool> m_isBaseClassTerminationFinished{false}; Is_Base_Class_Termination_Finished : Boolean := False with Atomic; -- std::atomic<bool> m_isSubclassTerminationFinished{false}; Is_Subclass_Termination_Finished : Boolean := False with Atomic; -- uint32_t m_subclassTerminationAbortDuration_ms{10000}; Subclass_Termination_Abort_Duration : Duration := 10.0; -- uint32_t m_subclassTerminationWarnDuration_ms{3000}; Subclass_Termination_Warn_Duration : Duration := 3.0; -- uint32_t m_subclassTerminationAttemptPeriod_ms{500}; Subclass_Termination_Attempt_Period : Duration := 0.5; end record; -- The sendLmcpObjectBroadcastMessage method can be invoked to broadcast a -- LMCP object message on the LMCP network. -- -- @param lmcpObject LMCP object to be broadcasted. The message publish -- address is derived from the full LMCP object name. -- -- void -- sendLmcpObjectBroadcastMessage(std::unique_ptr<AVTAS::lmcp::Object> lmcpObject); procedure Send_LMCP_Object_Broadcast_Message (This : in out LMCP_Object_Network_Client_Base; Msg : not null AVTAS.LMCP.Object.Object_Any); -- The sendSerializedLmcpObjectMessage method can be invoked to -- send a AddressedAttributedMessage to the LMCP network. The -- AddressedAttributedMessage payload must be a serialized LMCP object string. -- -- @param serializedLmcpObject LMCP object to be sent (uni-cast/multi-cast/broadcast). -- -- void -- sendSerializedLmcpObjectMessage -- (std::unique_ptr<uxas::communications::data::AddressedAttributedMessage> serializedLmcpObject); procedure Send_Serialized_LMCP_Object_Message (This : in out LMCP_Object_Network_Client_Base; Msg : not null Addressed_Attributed_Message_Ref); -- The sendSharedLmcpObjectBroadcastMessage method can be invoked to broadcast -- a LMCP object message on the LMCP network. -- -- @param lmcpObject LMCP object to be broadcasted. The message publish -- address is derived from the full LMCP object name. -- -- void -- sendSharedLmcpObjectBroadcastMessage(const std::shared_ptr<AVTAS::lmcp::Object>& lmcpObject); procedure Send_Shared_LMCP_Object_Broadcast_Message (This : in out LMCP_Object_Network_Client_Base; Msg : not null AVTAS.LMCP.Object.Object_Any); -- The sendSharedLmcpObjectLimitedCastMessage method can be invoked to send a -- uni-cast or multi-cast LMCP object message to the LMCP network. -- -- @param castAddress message publish address -- @param lmcpObject LMCP object to be uni-casted/multi-casted. -- -- void -- sendSharedLmcpObjectLimitedCastMessage(const std::string& castAddress, const std::shared_ptr<AVTAS::lmcp::Object>& lmcpObject); procedure Send_Shared_LMCP_Object_Limited_Cast_Message (This : in out LMCP_Object_Network_Client_Base; Cast_Address : String; Msg : not null AVTAS.LMCP.Object.Object_Any); end UxAS.Comms.LMCP_Net_Client;
29,919
ada
52
onox/orka
orka_plugin_gltf/src/orka-gltf.ads
<filename>orka_plugin_gltf/src/orka-gltf.ads -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Strings.Bounded; with Ada.Strings.Unbounded; with JSON.Types; with GL.Types; private package Orka.glTF is pragma Preelaborate; package SU renames Ada.Strings.Unbounded; Maximum_Name_Length : constant := 64; package Name_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => Maximum_Name_Length); function To_String (Value : Name_Strings.Bounded_String) return String renames Name_Strings.To_String; package Types is new JSON.Types (Long_Integer, GL.Types.Single); subtype Natural_Optional is Integer range -1 .. Integer'Last; Undefined : constant := Natural_Optional'First; end Orka.glTF;
29,920
ada
1
LaudateCorpus1/RosettaCodeData
Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada
type Priority is range 1..4; type Infix is record Precedence : Priority; Expression : Unbounded_String; end record; package Expression_Stack is new Generic_Stack (Infix); use Expression_Stack; function Convert (RPN : String) return String is Arguments : Stack; procedure Pop ( Operation : Character; Precedence : Priority; Association : Priority ) is Right, Left : Infix; Result : Infix; begin Pop (Right, Arguments); Pop (Left, Arguments); Result.Precedence := Association; if Left.Precedence < Precedence then Append (Result.Expression, '('); Append (Result.Expression, Left.Expression); Append (Result.Expression, ')'); else Append (Result.Expression, Left.Expression); end if; Append (Result.Expression, ' '); Append (Result.Expression, Operation); Append (Result.Expression, ' '); if Right.Precedence < Precedence then Append (Result.Expression, '('); Append (Result.Expression, Right.Expression); Append (Result.Expression, ')'); else Append (Result.Expression, Right.Expression); end if; Push (Result, Arguments); end Pop; Pointer : Integer := RPN'First; begin while Pointer <= RPN'Last loop case RPN (Pointer) is when ' ' => Pointer := Pointer + 1; when '0'..'9' => declare Start : constant Integer := Pointer; begin loop Pointer := Pointer + 1; exit when Pointer > RPN'Last or else RPN (Pointer) not in '0'..'9'; end loop; Push ( ( 4, To_Unbounded_String (RPN (Start..Pointer - 1)) ), Arguments ); end; when '+' | '-' => Pop (RPN (Pointer), 1, 1); Pointer := Pointer + 1; when '*' | '/' => Pop (RPN (Pointer), 2, 2); Pointer := Pointer + 1; when '^' => Pop (RPN (Pointer), 4, 3); Pointer := Pointer + 1; when others => raise Constraint_Error with "Syntax"; end case; end loop; declare Result : Infix; begin Pop (Result, Arguments); return To_String (Result.Expression); end; end Convert;
29,921
ada
192
rocher/Ada_Drivers_Library
examples/shared/serial_ports/src/demo_serial_port_streaming.adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- ************************************************************************** -- NOTE: THIS PROGRAM REQUIRES THE RAVENSCAR-FULL-* RUNTIME LIBRARIES. -- Set the scenario variable accordingly. -- ************************************************************************** -- A demonstration of a higher-level USART interface using streams. In -- particular, the serial port is presented as a stream type, so these ports -- can be used with stream attributes to send values of arbitrary types, not -- just characters or Strings. For this demonstration, however, we simply -- read an incoming string from the stream (the serial port) and echo it back, -- surrounding it with single quotes. -- HOST COMPUTER SIDE: -- The incoming strings are intended to come from another program, presumably -- running on the host computer, connected to the target board with a -- serial cable that presents a serial port to the host operating system. The -- "README.md" file associated with this project describes such a cable. A -- sample host-side program is described below. -- Note that, because it uses the stream attributes String'Output and -- String'Input, which write and read the bounds as well as the characters, -- you will need to use a program on the host that uses streams to send -- and receive these String values. Here is a sample interactive program, -- hardcoded arbitrarily to use COM3 on Windows. Note that the source code for -- this program is included in the root of this project, not in the source dir -- for the project because it is not intended to be run on the target board. -- with GNAT.IO; use GNAT.IO; -- with GNAT.Serial_Communications; use GNAT.Serial_Communications; -- -- procedure Host is -- COM : aliased Serial_Port; -- COM3 : constant Port_Name := Name (3); -- -- Outgoing : String (1 .. 1024); -- arbitrary -- Last : Natural; -- begin -- COM.Open (COM3); -- COM.Set (Rate => B115200, Block => False); -- -- loop -- Put ("> "); -- Get_Line (Outgoing, Last); -- exit when Last = Outgoing'First - 1; -- -- Put_Line ("Sending: '" & Outgoing (1 .. Last) & "'"); -- String'Output (COM'Access, Outgoing (1 .. Last)); -- -- declare -- Incoming : constant String := String'Input (COM'Access); -- begin -- Put_Line ("From board: " & Incoming); -- end; -- end loop; -- -- COM.Close; -- end Host; -- You can change the COM port number, or even get it from the command line -- as an argument, but it must match what the host OS sees from the USB-COM -- cable. -- When running it, enter a string at the prompt (">") or just hit carriage -- return if you are ready to quit. If you enter a string, it will be sent to -- the target board, along with the bounds. The program (in this file) running -- on the target, echos it back so the host app will show that response from -- the board. -- TARGET BOARD SIDE: -- This file declares the main procedure for the program running on the target -- board. It simply echos the incoming strings, forever. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with Peripherals_Streaming; use Peripherals_Streaming; with Serial_IO.Streaming; use Serial_IO.Streaming; procedure Demo_Serial_Port_Streaming is begin Initialize (COM); Configure (COM, Baud_Rate => 115_200); loop declare Incoming : constant String := String'Input (COM'Access); begin String'Output (COM'Access, "'" & Incoming & "'"); end; end loop; end Demo_Serial_Port_Streaming;
29,922
ada
0
Lucretia/old_nehe_ada95
thirdparty/adasdl/thin/adasdl/AdaSDL_framebuff/sdltests/threadwin.adb
-- ----------------------------------------------------------------- -- -- -- -- This 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 software 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. -- -- -- -- ----------------------------------------------------------------- -- -- ----------------------------------------------------------------- -- -- This is a translation, to the Ada programming language, of the -- -- original C test files written by <NAME> - www.libsdl.org -- -- translation made by <NAME> - www.adapower.net/~avargas -- -- ----------------------------------------------------------------- -- with System.Address_To_Access_Conversions; with Interfaces.C; with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; with Ada.Characters.Handling; with GNAT.OS_Lib; with SDL.Types; use SDL.Types; with SDL.Video; with SDL.Thread; with SDL.Error; with SDL.Quit; with SDL.Keyboard; with SDL.Timer; with SDL_Framebuffer; with ThreadWin_Sprogs; use ThreadWin_Sprogs; procedure ThreadWin is package C renames Interfaces.C; use type C.int; use type C.size_t; package CL renames Ada.Command_Line; package CH renames Ada.Characters.Handling; package V renames SDL.Video; use type V.Surface_Flags; use type V.Surface_ptr; package Tr renames SDL.Thread; use type SDL.Init_Flags; package Er renames SDL.Error; package Kb renames SDL.Keyboard; package Tm renames SDL.Timer; package Fb renames SDL_Framebuffer; Screen_Width : constant := 640; Screen_Height : constant := 480; screen : V.Surface_ptr; icon : V.Surface_ptr; parsed : Boolean; buffer : Fb.Framebuffer_8bPointer; palette : V.Colors_Array (0 .. 255); init_flags : SDL.Init_Flags; video_bpp : Uint8; video_flags : V.Surface_Flags; mouse_thread : Tr.SDL_Thread_ptr; keybd_thread : Tr.SDL_Thread_ptr; argc : Integer := CL.Argument_Count; argv_i : Integer := 1; begin -- Set the options, based on command line arguments init_flags := SDL.INIT_VIDEO; video_bpp := 8; video_flags := V.SWSURFACE; parsed := True; while parsed loop -- If the threaded option is enabled, and the SDL library hasn't -- been compiled with threaded events enabled, then the mouse and -- keyboard won't respond. if argc >= 1 and then CL.Argument (argv_i) = "-threaded" then init_flags := init_flags or SDL.INIT_EVENTTHREAD; argc := argc - 1; argv_i := argv_i + 1; Put_Line ("Running with threaded events"); elsif argc >= 1 and then CL.Argument (argv_i) = "-fullscreen" then video_flags := video_flags or V.FULLSCREEN; argc := argc - 1; argv_i := argv_i + 1; elsif (argc >= 2) and then (CL.Argument (argv_i) = "-bpp") and then CH.Is_Digit (CL.Argument (argv_i + 1) (1)) then declare package Uint8_IO is new Modular_IO (Uint8); use Uint8_IO; last : Positive; begin Uint8_IO.Get (CL.Argument (argv_i), video_bpp, last); end; argc := argc - 2; argv_i := argv_i + 2; else parsed := False; end if; end loop; -- Initialize SDL with the requested flags if SDL.Init (init_flags) < 0 then Put_Line ("Couldn't initialize SDL: " & Er.Get_Error); GNAT.OS_Lib.OS_Exit (1); end if; SDL.Quit.atexit (SDL.SDL_Quit'Access); -- Set the icon -- this must be done before the first mode set LoadIconSurface ("icon.bmp", icon_mask, icon); if icon /= null then V.WM_SetIcon (icon, icon_mask.all); -- V.WM_SetIcon (icon, null); end if; -- Initialize the display screen := V.SetVideoMode (Screen_Width, Screen_Height, C.int (video_bpp), video_flags); if screen = null then Put_Line ("Couldn't set " & Integer'Image (Screen_Width) & "x" & Integer'Image (Screen_Height) & " video mode: " & Er.Get_Error); GNAT.OS_Lib.OS_Exit (1); end if; Put ("Running in "); if (screen.flags and V.FULLSCREEN) /= 0 then Put (" fullscreen"); else Put (" windowed"); end if; Put_Line (" mode"); -- Enable printable characters Kb.EnableUNICODE (1); -- Set an event filter that discards everything but QUIT; Ev.SetEventFilter (FilterEvents'Access); -- Create the event handling threads mouse_thread := Tr.CreateThread (HandleMouse'Access, System.Null_Address); keybd_thread := Tr.CreateThread (HandleKeyboard'Access, System.Null_Address); -- Set the surface pixels and refresh! for i in C.size_t range 0 .. 255 loop palette (i) := (Uint8 (255 - i), Uint8 (255 - i), Uint8 (255 - i),0); end loop; V.SetColors (screen, palette, C.int(palette'First), palette'Length); if V.LockSurface (screen) < 0 then Put_Line ("Couldn't lock display surface: " & Er.Get_Error); GNAT.OS_Lib.OS_Exit (2); end if; buffer := Fb.Get_Framebuffer (screen); for i in 0 .. screen.h - 1 loop Fb.Paint_Line_Unchecked (screen, buffer, (i * 255) / screen.h); buffer := Fb.Next_Line_Unchecked (screen, buffer); end loop; V.UnlockSurface (screen); V.UpdateRect (screen, 0, 0, 0, 0); -- Loop, wait for QUIT while not done loop if (init_flags and SDL.INIT_EVENTTHREAD) = 0 then Ev.PumpEvents; -- Need when event thread is off end if; if Ev.PeepEvents (null, 0, Ev.PEEKEVENT, Ev.QUITMASK) /= 0 then done := True; end if; -- Give up some CPU so the events can accumulate Tm.SDL_Delay (20); end loop; Tr.WaitThread (mouse_thread, null); Tr.WaitThread (keybd_thread, null); GNAT.OS_Lib.OS_Exit (0); end ThreadWin;
29,923
ada
0
djamal2727/Main-Bearing-Analytical-Model
Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_ch6.ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 6 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, 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. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for chapter 6 constructs with Types; use Types; package Exp_Ch6 is procedure Expand_N_Extended_Return_Statement (N : Node_Id); procedure Expand_N_Function_Call (N : Node_Id); procedure Expand_N_Procedure_Call_Statement (N : Node_Id); procedure Expand_N_Simple_Return_Statement (N : Node_Id); procedure Expand_N_Subprogram_Body (N : Node_Id); procedure Expand_N_Subprogram_Body_Stub (N : Node_Id); procedure Expand_N_Subprogram_Declaration (N : Node_Id); procedure Expand_Call (N : Node_Id); -- This procedure contains common processing for Expand_N_Function_Call, -- Expand_N_Procedure_Statement, and Expand_N_Entry_Call. procedure Freeze_Subprogram (N : Node_Id); -- generate the appropriate expansions related to Subprogram freeze -- nodes (e.g. the filling of the corresponding Dispatch Table for -- Primitive Operations) -- The following type defines the various forms of allocation used for the -- results of build-in-place function calls. type BIP_Allocation_Form is (Unspecified, Caller_Allocation, Secondary_Stack, Global_Heap, User_Storage_Pool); type BIP_Formal_Kind is -- Ada 2005 (AI-318-02): This type defines the kinds of implicit extra -- formals created for build-in-place functions. The order of these -- enumeration literals matches the order in which the formals are -- declared. See Sem_Ch6.Create_Extra_Formals. (BIP_Alloc_Form, -- Present if result subtype is unconstrained or tagged. Indicates -- whether the return object is allocated by the caller or callee, and -- if the callee, whether to use the secondary stack or the heap. See -- Create_Extra_Formals. BIP_Storage_Pool, -- Present if result subtype is unconstrained or tagged. If -- BIP_Alloc_Form = User_Storage_Pool, this is a pointer to the pool -- (of type access to Root_Storage_Pool'Class). Otherwise null. BIP_Finalization_Master, -- Present if result type needs finalization. Pointer to caller's -- finalization master. BIP_Task_Master, -- Present if result type contains tasks. Master associated with -- calling context. BIP_Activation_Chain, -- Present if result type contains tasks. Caller's activation chain BIP_Object_Access); -- Present for all build-in-place functions. Address at which to place -- the return object, or null if BIP_Alloc_Form indicates allocated by -- callee. -- -- ??? We might also need to be able to pass in a constrained flag. procedure Add_Extra_Actual_To_Call (Subprogram_Call : Node_Id; Extra_Formal : Entity_Id; Extra_Actual : Node_Id); -- Adds Extra_Actual as a named parameter association for the formal -- Extra_Formal in Subprogram_Call. function BIP_Formal_Suffix (Kind : BIP_Formal_Kind) return String; -- Ada 2005 (AI-318-02): Returns a string to be used as the suffix of names -- for build-in-place formal parameters of the given kind. function BIP_Suffix_Kind (E : Entity_Id) return BIP_Formal_Kind; -- Ada 2005 (AI-318-02): Returns the kind of the given BIP extra formal. function Build_In_Place_Formal (Func : Entity_Id; Kind : BIP_Formal_Kind) return Entity_Id; -- Ada 2005 (AI-318-02): Locates and returns the entity for the implicit -- build-in-place formal parameter of the given kind associated with the -- function Func, and returns its Entity_Id. It is a bug if not found; the -- caller should ensure this is called only when the extra formal exists. function Build_Procedure_Body_Form (Func_Id : Entity_Id; Func_Body : Node_Id) return Node_Id; -- Create a procedure body which emulates the behavior of function Func_Id. -- Func_Body is the root of the body of the function before its analysis. -- The returned node is the root of the procedure body which will replace -- the original function body, which is not needed for the C program. function Is_Build_In_Place_Entity (E : Entity_Id) return Boolean; -- Ada 2005 (AI-318-02): Returns True if E is a BIP entity. function Is_Build_In_Place_Result_Type (Typ : Entity_Id) return Boolean; -- Ada 2005 (AI-318-02): Returns True if functions returning the type use -- build-in-place protocols. For inherently limited types, this must be -- True in >= Ada 2005, and must be False in Ada 95. For other types, it -- can be True or False, and the decision should be based on efficiency, -- and should be the same for all language versions, so that mixed-dialect -- programs will work. -- -- For inherently limited types in Ada 2005, True means that calls will -- actually be build-in-place in all cases. For other types, build-in-place -- will be used when possible, but we need to make a copy at the call site -- in some cases, notably assignment statements. function Is_Build_In_Place_Function (E : Entity_Id) return Boolean; -- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic -- function, or access-to-function type for which -- Is_Build_In_Place_Result_Type is True. However, we never use -- build-in-place if the convention is other than Ada, because that would -- disturb mixed-language programs. function Is_Build_In_Place_Function_Call (N : Node_Id) return Boolean; -- Ada 2005 (AI-318-02): Returns True if N denotes a call to a function -- that requires handling as a build-in-place call (possibly qualified or -- converted). function Is_Null_Procedure (Subp : Entity_Id) return Boolean; -- Predicate to recognize stubbed procedures and null procedures, which -- can be inlined unconditionally in all cases. procedure Make_Build_In_Place_Call_In_Allocator (Allocator : Node_Id; Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs as the expression initializing an allocator, by passing access -- to the allocated object as an additional parameter of the function call. -- A new access object is declared that is initialized to the result of the -- allocator, passed to the function, and the allocator is rewritten to -- refer to that access object. Function_Call must denote either an -- N_Function_Call node for which Is_Build_In_Place_Call is True, or else -- an N_Qualified_Expression node applied to such a function call. procedure Make_Build_In_Place_Call_In_Anonymous_Context (Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs in a context that does not provide a separate object. A temporary -- object is created to act as the return object and an access to the -- temporary is passed as an additional parameter of the call. This occurs -- in contexts such as subprogram call actuals and object renamings. -- Function_Call must denote either an N_Function_Call node for which -- Is_Build_In_Place_Call is True, or else an N_Qualified_Expression node -- applied to such a function call. procedure Make_Build_In_Place_Call_In_Assignment (Assign : Node_Id; Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs as the right-hand side of an assignment statement by passing -- access to the left-hand side as an additional parameter of the function -- call. Assign must denote a N_Assignment_Statement. Function_Call must -- denote either an N_Function_Call node for which Is_Build_In_Place_Call -- is True, or an N_Qualified_Expression node applied to such a function -- call. procedure Make_Build_In_Place_Call_In_Object_Declaration (Obj_Decl : Node_Id; Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs as the expression initializing an object declaration by -- passing access to the declared object as an additional parameter of the -- function call. Function_Call must denote either an N_Function_Call node -- for which Is_Build_In_Place_Call is True, or an N_Qualified_Expression -- node applied to such a function call. procedure Make_Build_In_Place_Iface_Call_In_Allocator (Allocator : Node_Id; Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs as the expression initializing an allocator, by passing access -- to the allocated object as an additional parameter of the function call. -- Function_Call must denote an expression containing a BIP function call -- and an enclosing call to Ada.Tags.Displace to displace the pointer to -- the returned BIP object to reference the secondary dispatch table of -- an interface. procedure Make_Build_In_Place_Iface_Call_In_Anonymous_Context (Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs in a context that does not provide a separate object. A temporary -- object is created to act as the return object and an access to the -- temporary is passed as an additional parameter of the call. This occurs -- in contexts such as subprogram call actuals and object renamings. -- Function_Call must denote an expression containing a BIP function call -- and an enclosing call to Ada.Tags.Displace to displace the pointer to -- the returned BIP object to reference the secondary dispatch table of -- an interface. procedure Make_Build_In_Place_Iface_Call_In_Object_Declaration (Obj_Decl : Node_Id; Function_Call : Node_Id); -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that -- occurs as the expression initializing an object declaration by passing -- access to the declared object as an additional parameter of the function -- call. Function_Call must denote an expression containing a BIP function -- call and an enclosing call to Ada.Tags.Displace to displace the pointer -- to the returned BIP object to reference the secondary dispatch table of -- an interface. procedure Make_CPP_Constructor_Call_In_Allocator (Allocator : Node_Id; Function_Call : Node_Id); -- Handle a call to a CPP constructor that occurs as the expression that -- initializes an allocator, by passing access to the allocated object as -- an additional parameter of the constructor call. A new access object is -- declared that is initialized to the result of the allocator, passed to -- the constructor, and the allocator is rewritten to refer to that access -- object. Function_Call must denote a call to a CPP_Constructor function. function Might_Have_Tasks (Typ : Entity_Id) return Boolean; -- Return True when type Typ has tasks or when it is a limited class-wide -- type (or subtype), since it might have task components. function Needs_BIP_Alloc_Form (Func_Id : Entity_Id) return Boolean; -- Ada 2005 (AI-318-02): Return True if the function needs an implicit -- BIP_Alloc_Form parameter (see type BIP_Formal_Kind). function Needs_BIP_Finalization_Master (Func_Id : Entity_Id) return Boolean; -- Ada 2005 (AI-318-02): Return True if the result subtype of function -- Func_Id might need finalization actions. This includes build-in-place -- functions with tagged result types, since they can be invoked via -- dispatching calls, and descendant types may require finalization. function Needs_BIP_Task_Actuals (Func_Id : Entity_Id) return Boolean; -- Return True if the function returns an object of a type that has tasks. function Unqual_BIP_Iface_Function_Call (Expr : Node_Id) return Node_Id; -- Return the inner BIP function call removing any qualification from Expr -- including qualified expressions, type conversions, references, unchecked -- conversions and calls to displace the pointer to the object, if Expr is -- an expression containing a call displacing the pointer to the BIP object -- to reference the secondary dispatch table of an interface; otherwise -- return Empty. end Exp_Ch6;
29,924
ada
1
ForYouEyesOnly/Space-Convoy
Sources/Library/exceptions.adb
-- -- Jan & <NAME>, Australia, July 2011 -- with Ada.Task_Identification; use Ada.Task_Identification; with Ada.Text_IO; use Ada.Text_IO; package body Exceptions is procedure Show_Exception (Exception_Identifier : Exception_Occurrence; Optional_Message : String := "") is begin Put_Line (Current_Error, "Task " & Image (Current_Task) & " reports: "); Put_Line (Current_Error, Exception_Information (Exception_Identifier)); if Optional_Message /= "" then Put_Line (Current_Error, "Additional message: " & Optional_Message); end if; end Show_Exception; end Exceptions;
29,925
ada
1
LaudateCorpus1/RosettaCodeData
Task/Loop-over-multiple-arrays-simultaneously/Ada/loop-over-multiple-arrays-simultaneously.ada
<gh_stars>1-10 with Ada.Text_IO; use Ada.Text_IO; procedure Array_Loop_Test is type Array_Index is range 1..3; A1 : array (Array_Index) of Character := "abc"; A2 : array (Array_Index) of Character := "ABC"; A3 : array (Array_Index) of Integer := (1, 2, 3); begin for Index in Array_Index'Range loop Put_Line (A1 (Index) & A2 (Index) & Integer'Image (A3 (Index))(2)); end loop; end Array_Loop_Test;
29,926
ada
5
onox/wayland-ada
wayland_ada_scanner/src/aida/aida-deepend-xml_dom_parser.ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 - 2019 <NAME> <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Containers.Vectors; with Aida.XML_SAX_Parse; pragma Elaborate_All (Aida.XML_SAX_Parse); package Aida.Deepend.XML_DOM_Parser is type Attribute is limited private; function Name (This : Attribute) return String with Global => null; function Value (This : Attribute) return String with Global => null; type Attribute_Ptr is access all Attribute; type Attribute_Index is new Positive; package Attribute_Vectors is new Ada.Containers.Vectors (Index_Type => Attribute_Index, Element_Type => Attribute_Ptr, "=" => "="); type Node_Kind_Id is ( Node_Kind_Tag, Node_Kind_Comment, Node_Kind_CDATA, Node_Kind_Text ); type Node; type Node_Ptr is access all Node; package Node_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Node_Ptr); type Attributes_Ref ( Element : not null access constant Attribute_Vectors.Vector ) is limited null record with Implicit_Dereference => Element; type Child_Nodes_Ref ( Element : not null access constant Node_Vectors.Vector ) is limited null record with Implicit_Dereference => Element; type XML_Tag is private; function Attributes (This : aliased XML_Tag) return Attributes_Ref with Global => null; function Child_Nodes (This : aliased XML_Tag) return Child_Nodes_Ref with Global => null; function Name (This : XML_Tag) return String with Global => null; type Node (Id : Node_Kind_Id := Node_Kind_Tag) is record case Id is when Node_Kind_Tag => Tag : aliased XML_Tag; when Node_Kind_Comment | Node_Kind_CDATA | Node_Kind_Text => Text : not null String_Ptr := Empty_String'Access; -- It would be cool to specify that this can only be set once. -- To be improved in the future! end case; end record; procedure Parse (XML_Message : String; Call_Result : in out Aida.Call_Result; Root_Node : out Node_Ptr) with Global => null, Pre => (not Call_Result.Has_Failed and XML_Message'Length > 0 and XML_Message'Last < Integer'Last - 4); private type Attribute is limited record My_Name : String_Ptr; My_Value : String_Ptr; end record; type XML_Tag is record My_Name : String_Ptr; My_Child_Nodes : aliased Node_Vectors.Vector; My_Attributes : aliased Attribute_Vectors.Vector; end record; end Aida.Deepend.XML_DOM_Parser;
29,927
ada
0
reznikmm/gela
source/oasis/program-elements-signed_integer_types.ads
<reponame>reznikmm/gela -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Type_Definitions; with Program.Lexical_Elements; with Program.Elements.Expressions; package Program.Elements.Signed_Integer_Types is pragma Pure (Program.Elements.Signed_Integer_Types); type Signed_Integer_Type is limited interface and Program.Elements.Type_Definitions.Type_Definition; type Signed_Integer_Type_Access is access all Signed_Integer_Type'Class with Storage_Size => 0; not overriding function Lower_Bound (Self : Signed_Integer_Type) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Upper_Bound (Self : Signed_Integer_Type) return not null Program.Elements.Expressions.Expression_Access is abstract; type Signed_Integer_Type_Text is limited interface; type Signed_Integer_Type_Text_Access is access all Signed_Integer_Type_Text'Class with Storage_Size => 0; not overriding function To_Signed_Integer_Type_Text (Self : in out Signed_Integer_Type) return Signed_Integer_Type_Text_Access is abstract; not overriding function Range_Token (Self : Signed_Integer_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Double_Dot_Token (Self : Signed_Integer_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Signed_Integer_Types;
29,928
ada
24
svn2github/matreshka
source/league/ucd/matreshka-internals-unicode-ucd-core_0024.ads
<reponame>svn2github/matreshka ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, <NAME> <<EMAIL>> -- -- 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$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_0024 is pragma Preelaborate; Group_0024 : aliased constant Core_Second_Stage := (16#00# .. 16#26# => -- 2400 .. 2426 (Other_Symbol, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#27# .. 16#3F# => -- 2427 .. 243F (Unassigned, Neutral, Other, Other, Other, Unknown, (Pattern_Syntax => True, others => False)), 16#40# .. 16#4A# => -- 2440 .. 244A (Other_Symbol, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#4B# .. 16#5F# => -- 244B .. 245F (Unassigned, Neutral, Other, Other, Other, Unknown, (Pattern_Syntax => True, others => False)), 16#9C# .. 16#B5# => -- 249C .. 24B5 (Other_Symbol, Ambiguous, Other, Other, Other, Ambiguous, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#B6# .. 16#CF# => -- 24B6 .. 24CF (Other_Symbol, Ambiguous, Other, A_Letter, Upper, Ambiguous, (Other_Alphabetic | Other_Uppercase | Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | Uppercase | Changes_When_NFKC_Casefolded => True, others => False)), 16#D0# .. 16#E9# => -- 24D0 .. 24E9 (Other_Symbol, Ambiguous, Other, A_Letter, Lower, Ambiguous, (Other_Alphabetic | Other_Lowercase | Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | Lowercase | Changes_When_NFKC_Casefolded => True, others => False)), 16#EA# => -- 24EA (Other_Number, Neutral, Other, Other, Other, Ambiguous, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#EB# .. 16#FE# => -- 24EB .. 24FE (Other_Number, Ambiguous, Other, Other, Other, Ambiguous, (Grapheme_Base => True, others => False)), 16#FF# => -- 24FF (Other_Number, Ambiguous, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), others => (Other_Number, Ambiguous, Other, Other, Other, Ambiguous, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False))); end Matreshka.Internals.Unicode.Ucd.Core_0024;
29,929
ada
3
charlie5/aIDE
applet/aide/source/palettes/aide-palette.adb
<gh_stars>1-10 package body aIDE.Palette is procedure dummy is begin null; end dummy; end aIDE.Palette;
29,930
ada
0
jpuente/Temperature_Sensor
src/mqtt.ads
<reponame>jpuente/Temperature_Sensor ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, Universidad Politécnica de Madrid -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- MQTT client with GNAT.Sockets; use GNAT.Sockets; with GNAT.Sockets.MQTT; use GNAT.Sockets.MQTT; package MQTT is Server_Name : constant String := "xxx.dit.upm.es"; Client_Name : constant String := "xxx"; Port : constant GNAT.Sockets.Port_Type := 1883; QoS : QoS_Level := Exactly_Once; Topic_Text : constant String := "test/temperature"; procedure Publish (Message_Text : String); end MQTT;
29,931
ada
0
ekoeppen/MSP430_Generic_Ada_Drivers
common/cbor_codec.ads
<reponame>ekoeppen/MSP430_Generic_Ada_Drivers with Interfaces; use Interfaces; generic with procedure Write (Data : Unsigned_8); with function Read return Unsigned_8; package CBOR_Codec is pragma Preelaborate; type Major_Type is (Unsigned_Integer, Negative_Integer, Byte_String, UTF8_String, Item_Array, Item_Map, Tag, Simple_Or_Float) with Size => 3; for Major_Type use ( Unsigned_Integer => 0, Negative_Integer => 1, Byte_String => 2, UTF8_String => 3, Item_Array => 4, Item_Map => 5, Tag => 6, Simple_Or_Float => 7); Date_Time_String_Tag : constant Natural := 0; Epoch_Time_Tag : constant Natural := 1; Positive_Bignum_Tag : constant Natural := 2; Negative_Bignum_Tag : constant Natural := 3; Decimal_Fraction_Tag : constant Natural := 4; Bigfloat_Tag : constant Natural := 5; Base64_URL_Expected_Tag : constant Natural := 21; Base64_Expected_Tag : constant Natural := 22; Base16_Expected_Tag : constant Natural := 23; CBOR_Data_Tag : constant Natural := 24; URI_String_Tag : constant Natural := 32; Base64_URL_String_Tag : constant Natural := 33; Base64_String_Tag : constant Natural := 34; Regexp_Tag : constant Natural := 35; MIME_Message_Tag : constant Natural := 36; procedure Encode_Integer (Value : Integer); procedure Encode_Byte_String (Value : String); procedure Encode_UTF8_String (Value : String); procedure Encode_Array (Count : Natural); procedure Encode_Map (Count : Natural); procedure Encode_Tag (Value : Natural); procedure Encode_Null; procedure Encode_False; procedure Encode_True; procedure Encode_Undefined; procedure Encode_Simple_Value (Value : Integer); procedure Encode_Float (Value : Short_Float); procedure Encode_Float (Value : Float); procedure Encode_Decimal_Fraction (Value : Integer; Mantissa : Integer); function Decode_Integer (Value : out Integer) return Boolean; function Decode_Byte_String (Size : out Natural) return Boolean; function Decode_UTF8_String return Boolean; function Decode_Array (Count : out Natural) return Boolean; function Decode_Map return Boolean; function Decode_Tag (Value : out Integer) return Boolean; function Decode_Null return Boolean; function Decode_Boolean return Boolean; function Decode_Undefined return Boolean; function Decode_Simple_Value return Boolean; function Decode_Float return Boolean; function Decode_Decimal_Fraction (Value : out Integer; Mantissa : out Integer) return Boolean; end CBOR_Codec;
29,932
ada
0
Letractively/ada-awa
awa/plugins/awa-workspaces/src/model/awa-workspaces-models.adb
----------------------------------------------------------------------- -- AWA.Workspaces.Models -- AWA.Workspaces.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095 ----------------------------------------------------------------------- -- Copyright (C) 2013 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; package body AWA.Workspaces.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; use type ADO.Objects.Object_Record; function Workspace_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Key; function Workspace_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Key; function "=" (Left, Right : Workspace_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Workspace_Ref'Class; Impl : out Workspace_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Workspace_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Workspace_Ref) is Impl : Workspace_Access; begin Impl := new Workspace_Impl; Impl.Version := 0; Impl.Create_Date := ADO.DEFAULT_TIME; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Workspace -- ---------------------------------------- procedure Set_Id (Object : in out Workspace_Ref; Value : in ADO.Identifier) is Impl : Workspace_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Workspace_Ref) return ADO.Identifier is Impl : constant Workspace_Access := Workspace_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; function Get_Version (Object : in Workspace_Ref) return Integer is Impl : constant Workspace_Access := Workspace_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Create_Date (Object : in out Workspace_Ref; Value : in Ada.Calendar.Time) is Impl : Workspace_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 3, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Workspace_Ref) return Ada.Calendar.Time is Impl : constant Workspace_Access := Workspace_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Owner (Object : in out Workspace_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Workspace_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Owner, Value); end Set_Owner; function Get_Owner (Object : in Workspace_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Workspace_Access := Workspace_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Owner; end Get_Owner; -- Copy of the object. procedure Copy (Object : in Workspace_Ref; Into : in out Workspace_Ref) is Result : Workspace_Ref; begin if not Object.Is_Null then declare Impl : constant Workspace_Access := Workspace_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Workspace_Access := new Workspace_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Version := Impl.Version; Copy.Create_Date := Impl.Create_Date; Copy.Owner := Impl.Owner; end; end if; Into := Result; end Copy; procedure Find (Object : in out Workspace_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Workspace_Access := new Workspace_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Workspace_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Workspace_Access := new Workspace_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Workspace_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Workspace_Access := new Workspace_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Workspace_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Workspace_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Workspace_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Workspace_Impl) is type Workspace_Impl_Ptr is access all Workspace_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Workspace_Impl, Workspace_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Workspace_Impl_Ptr := Workspace_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Workspace_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WORKSPACE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Workspace_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Workspace_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WORKSPACE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- owner_id Value => Object.Owner); Object.Clear_Modified (4); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; procedure Create (Object : in out Workspace_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WORKSPACE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_2_1_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_3_1_NAME, -- owner_id Value => Object.Owner); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Workspace_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WORKSPACE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Workspace_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Workspace_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Workspace_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Workspace_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Create_Date := Stmt.Get_Time (2); if not Stmt.Is_Null (3) then Object.Owner.Set_Key_Value (Stmt.Get_Identifier (3), Session); end if; Object.Version := Stmt.Get_Integer (1); ADO.Objects.Set_Created (Object); end Load; function Workspace_Feature_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_FEATURE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Feature_Key; function Workspace_Feature_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_FEATURE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Feature_Key; function "=" (Left, Right : Workspace_Feature_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Workspace_Feature_Ref'Class; Impl : out Workspace_Feature_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Workspace_Feature_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Workspace_Feature_Ref) is Impl : Workspace_Feature_Access; begin Impl := new Workspace_Feature_Impl; Impl.Limit := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Workspace_Feature -- ---------------------------------------- procedure Set_Id (Object : in out Workspace_Feature_Ref; Value : in ADO.Identifier) is Impl : Workspace_Feature_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Workspace_Feature_Ref) return ADO.Identifier is Impl : constant Workspace_Feature_Access := Workspace_Feature_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Limit (Object : in out Workspace_Feature_Ref; Value : in Integer) is Impl : Workspace_Feature_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 2, Impl.Limit, Value); end Set_Limit; function Get_Limit (Object : in Workspace_Feature_Ref) return Integer is Impl : constant Workspace_Feature_Access := Workspace_Feature_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Limit; end Get_Limit; procedure Set_Workspace (Object : in out Workspace_Feature_Ref; Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is Impl : Workspace_Feature_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 3, Impl.Workspace, Value); end Set_Workspace; function Get_Workspace (Object : in Workspace_Feature_Ref) return AWA.Workspaces.Models.Workspace_Ref'Class is Impl : constant Workspace_Feature_Access := Workspace_Feature_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Workspace; end Get_Workspace; -- Copy of the object. procedure Copy (Object : in Workspace_Feature_Ref; Into : in out Workspace_Feature_Ref) is Result : Workspace_Feature_Ref; begin if not Object.Is_Null then declare Impl : constant Workspace_Feature_Access := Workspace_Feature_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Workspace_Feature_Access := new Workspace_Feature_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Limit := Impl.Limit; Copy.Workspace := Impl.Workspace; end; end if; Into := Result; end Copy; procedure Find (Object : in out Workspace_Feature_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Workspace_Feature_Access := new Workspace_Feature_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Workspace_Feature_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Workspace_Feature_Access := new Workspace_Feature_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Workspace_Feature_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Workspace_Feature_Access := new Workspace_Feature_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Workspace_Feature_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Workspace_Feature_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Workspace_Feature_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Workspace_Feature_Impl) is type Workspace_Feature_Impl_Ptr is access all Workspace_Feature_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Workspace_Feature_Impl, Workspace_Feature_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Workspace_Feature_Impl_Ptr := Workspace_Feature_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Workspace_Feature_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WORKSPACE_FEATURE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Workspace_Feature_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Workspace_Feature_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WORKSPACE_FEATURE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_2_NAME, -- limit Value => Object.Limit); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_2_NAME, -- workspace_id Value => Object.Workspace); Object.Clear_Modified (3); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Workspace_Feature_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WORKSPACE_FEATURE_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- limit Value => Object.Limit); Query.Save_Field (Name => COL_2_2_NAME, -- workspace_id Value => Object.Workspace); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Workspace_Feature_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WORKSPACE_FEATURE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Workspace_Feature_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Workspace_Feature_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Workspace_Feature_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "limit" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Limit)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Workspace_Feature_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Limit := Stmt.Get_Integer (1); if not Stmt.Is_Null (2) then Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (2), Session); end if; ADO.Objects.Set_Created (Object); end Load; function Workspace_Member_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_MEMBER_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Member_Key; function Workspace_Member_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WORKSPACE_MEMBER_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Workspace_Member_Key; function "=" (Left, Right : Workspace_Member_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Workspace_Member_Ref'Class; Impl : out Workspace_Member_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Workspace_Member_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Workspace_Member_Ref) is Impl : Workspace_Member_Access; begin Impl := new Workspace_Member_Impl; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Workspace_Member -- ---------------------------------------- procedure Set_Id (Object : in out Workspace_Member_Ref; Value : in ADO.Identifier) is Impl : Workspace_Member_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Workspace_Member_Ref) return ADO.Identifier is Impl : constant Workspace_Member_Access := Workspace_Member_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Member (Object : in out Workspace_Member_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Workspace_Member_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 2, Impl.Member, Value); end Set_Member; function Get_Member (Object : in Workspace_Member_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Workspace_Member_Access := Workspace_Member_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Member; end Get_Member; procedure Set_Workspace (Object : in out Workspace_Member_Ref; Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is Impl : Workspace_Member_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 3, Impl.Workspace, Value); end Set_Workspace; function Get_Workspace (Object : in Workspace_Member_Ref) return AWA.Workspaces.Models.Workspace_Ref'Class is Impl : constant Workspace_Member_Access := Workspace_Member_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Workspace; end Get_Workspace; -- Copy of the object. procedure Copy (Object : in Workspace_Member_Ref; Into : in out Workspace_Member_Ref) is Result : Workspace_Member_Ref; begin if not Object.Is_Null then declare Impl : constant Workspace_Member_Access := Workspace_Member_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Workspace_Member_Access := new Workspace_Member_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Member := Impl.Member; Copy.Workspace := Impl.Workspace; end; end if; Into := Result; end Copy; procedure Find (Object : in out Workspace_Member_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Workspace_Member_Access := new Workspace_Member_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Workspace_Member_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Workspace_Member_Access := new Workspace_Member_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Workspace_Member_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Workspace_Member_Access := new Workspace_Member_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Workspace_Member_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Workspace_Member_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Workspace_Member_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Workspace_Member_Impl) is type Workspace_Member_Impl_Ptr is access all Workspace_Member_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Workspace_Member_Impl, Workspace_Member_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Workspace_Member_Impl_Ptr := Workspace_Member_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Workspace_Member_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WORKSPACE_MEMBER_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Workspace_Member_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Workspace_Member_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WORKSPACE_MEMBER_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_3_NAME, -- member_id Value => Object.Member); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_3_NAME, -- workspace_id Value => Object.Workspace); Object.Clear_Modified (3); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Workspace_Member_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WORKSPACE_MEMBER_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_3_NAME, -- member_id Value => Object.Member); Query.Save_Field (Name => COL_2_3_NAME, -- workspace_id Value => Object.Workspace); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Workspace_Member_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WORKSPACE_MEMBER_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Workspace_Member_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Workspace_Member_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Workspace_Member_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Workspace_Member_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); if not Stmt.Is_Null (1) then Object.Member.Set_Key_Value (Stmt.Get_Identifier (1), Session); end if; if not Stmt.Is_Null (2) then Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (2), Session); end if; ADO.Objects.Set_Created (Object); end Load; end AWA.Workspaces.Models;
29,933
ada
0
Tim-Tom/project-euler
Ada/src/Problem_51.adb
with Ada.Text_IO; with Ada.Containers.Ordered_Maps; with PrimeUtilities; package body Problem_51 is package IO renames Ada.Text_IO; type Number_Range is new Integer range 0 .. 999_999_999; type Converted_Range is new Integer range 0 .. Integer(Number_Range'Last + 1)*11/10; type Magnitude is new Positive range 1 .. 9; type Family_Count is Record base_example : Number_Range; count : Positive; end Record; package Family_Map is new Ada.Containers.Ordered_Maps(Key_Type => Converted_Range, Element_Type => Family_Count); package Range_Primes is new PrimeUtilities(Num => Number_Range); procedure Solve is gen : Range_Primes.Prime_Generator := Range_Primes.Make_Generator; families : Family_Map.Map; prime : Number_Range; prime_magnitude : Magnitude := 1; function Get_Magnitude(num : Number_Range) return Magnitude is begin if num >= 100_000_000 then return 9; elsif num >= 10_000_000 then return 8; elsif num >= 1_000_000 then return 7; elsif num >= 100_000 then return 6; elsif num >= 10_000 then return 5; elsif num >= 1_000 then return 4; elsif num >= 100 then return 3; elsif num >= 10 then return 2; else return 1; end if; end; pragma Pure_Function(Get_Magnitude); Function Generate_Families(prime : Number_Range) return Number_Range is Function Gen_Families_Rec(number : Number_Range; so_far : Converted_Range; Keep : Number_Range) return Number_Range is found : Number_Range := 0; begin if number /= 0 then declare quotient : constant Number_Range := number / 10; remainder : constant Number_Range := number mod 10; begin found := Gen_Families_Rec(quotient, (so_far*11) + Converted_Range(remainder), keep); if found /= 0 then return found; elsif keep = 11 or keep = remainder then found := Gen_Families_Rec(quotient, so_far*11 + 10, remainder); if found /= 0 then return found; end if; end if; end; elsif keep /= 11 then declare use Family_Map; location : constant Family_Map.Cursor := families.Find(so_far); element : Family_Count; begin if location = Family_Map.No_Element then element.base_example := prime; element.count := 1; families.Insert(so_far, element); else element := Family_Map.Element(location); element.count := element.count + 1; families.Replace_Element(location, element); if element.count = 8 then return element.base_example; end if; end if; end; end if; return 0; end Gen_Families_Rec; begin return Gen_Families_Rec(prime, 0, 11); end Generate_Families; begin loop Range_Primes.Next_Prime(gen, prime); exit when prime = 1; if prime_magnitude /= Get_Magnitude(prime) then prime_magnitude := Get_Magnitude(prime); families.Clear; end if; declare found : constant Number_Range := Generate_Families(prime); begin if found /= 0 then IO.Put_Line(Number_Range'Image(found)); exit; end if; end; end loop; end Solve; end Problem_51;
29,934
ada
0
Letractively/ada-gen
src/gnat/mlib-tgt.ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M L I B . T G T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2009, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. 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 provides a set of target dependent routines to build static, -- dynamic and shared libraries. There are several packages providing -- the actual routines. This package calls them indirectly by means of -- access-to-subprogram values. Each target-dependent package initializes -- these values in its elaboration block. with Prj; use Prj; package MLib.Tgt is function Support_For_Libraries return Library_Support; -- Indicates how building libraries by gnatmake is supported by the GNAT -- implementation for the platform. function Standalone_Library_Auto_Init_Is_Supported return Boolean; -- Indicates if when building a dynamic Standalone Library, -- automatic initialization is supported. If it is, then it is the default, -- unless attribute Library_Auto_Init has the value "false". function Archive_Builder return String; -- Returns the name of the archive builder program, usually "ar" function Archive_Builder_Options return String_List_Access; -- A list of options to invoke the Archive_Builder, usually "cr" for "ar" function Archive_Builder_Append_Options return String_List_Access; -- A list of options to use with the archive builder to append object -- files ("q", for example). function Archive_Indexer return String; -- Returns the name of the program, if any, that generates an index to the -- contents of an archive, usually "ranlib". If there is no archive indexer -- to be used, returns an empty string. function Archive_Indexer_Options return String_List_Access; -- A list of options to invoke the Archive_Indexer, usually empty function Dynamic_Option return String; -- gcc option to create a dynamic library. -- For Unix, returns "-shared", for Windows returns "-mdll". function Libgnat return String; -- System dependent static GNAT library function Archive_Ext return String; -- System dependent static library extension, without leading dot. -- For Unix and Windows, return "a". function Object_Ext return String; -- System dependent object extension, without leading dot. -- On Unix, returns "o". function DLL_Prefix return String; -- System dependent dynamic library prefix. -- On Windows, returns "". On other platforms, returns "lib". function DLL_Ext return String; -- System dependent dynamic library extension, without leading dot. -- On Windows, returns "dll". On Unix, usually returns "so", but not -- always, e.g. on HP-UX the extension for shared libraries is "sl". function PIC_Option return String; -- Position independent code option function Is_Object_Ext (Ext : String) return Boolean; -- Returns True iff Ext is an object file extension function Is_C_Ext (Ext : String) return Boolean; -- Returns True iff Ext is a C file extension function Is_Archive_Ext (Ext : String) return Boolean; -- Returns True iff Ext is an extension for a library function Default_Symbol_File_Name return String; -- Returns the name of the symbol file when Library_Symbol_File is not -- specified. Return the empty string when symbol files are not supported. procedure Build_Dynamic_Library (Ofiles : Argument_List; Options : Argument_List; Interfaces : Argument_List; Lib_Filename : String; Lib_Dir : String; Symbol_Data : Symbol_Record; Driver_Name : Name_Id := No_Name; Lib_Version : String := ""; Auto_Init : Boolean := False); -- Build a dynamic/relocatable library -- -- Ofiles is the list of all object files in the library -- -- Options is a list of options to be passed to the tool -- (gcc or other) that effectively builds the dynamic library. -- -- Interfaces is the list of ALI files for the interfaces of a SAL. -- It is empty if the library is not a SAL. -- -- Lib_Filename is the name of the library, without any prefix or -- extension. For example, on Unix, if Lib_Filename is "toto", the -- name of the library file will be "libtoto.so". -- -- Lib_Dir is the directory path where the library will be located -- -- For OSes that support symbolic links, Lib_Version, if non null, -- is the actual file name of the library. For example on Unix, if -- Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1", -- "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which -- will be the actual library file. -- -- Symbol_Data is used for some platforms, including VMS, to generate -- the symbols to be exported by the library. -- -- Note: Depending on the OS, some of the parameters may not be taken into -- account. For example, on Linux, Interfaces, Symbol_Data and Auto_Init -- are ignored. function Library_Exists_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean; -- Return True if the library file for a library project already exists. -- This function can only be called for library projects. function Library_File_Name_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return File_Name_Type; -- Returns the file name of the library file of a library project. -- This function can only be called for library projects. function Library_Major_Minor_Id_Supported return Boolean; -- Indicates if major and minor ids are supported for libraries. -- If they are supported, then a Library_Version such as libtoto.so.1.2 -- will have a major id of 1 and a minor id of 2. Then libtoto.so, -- libtoto.so.1 and libtoto.so.1.2 will be created, all three designating -- the same file. private No_Argument_List : constant Argument_List := (1 .. 0 => null); -- Access to subprogram types for indirection type String_Function is access function return String; type Is_Ext_Function is access function (Ext : String) return Boolean; type String_List_Access_Function is access function return String_List_Access; type Build_Dynamic_Library_Function is access procedure (Ofiles : Argument_List; Options : Argument_List; Interfaces : Argument_List; Lib_Filename : String; Lib_Dir : String; Symbol_Data : Symbol_Record; Driver_Name : Name_Id := No_Name; Lib_Version : String := ""; Auto_Init : Boolean := False); type Library_Exists_For_Function is access function (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean; type Library_File_Name_For_Function is access function (Project : Project_Id; In_Tree : Project_Tree_Ref) return File_Name_Type; type Boolean_Function is access function return Boolean; type Library_Support_Function is access function return Library_Support; function Archive_Builder_Default return String; Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access; function Archive_Builder_Options_Default return String_List_Access; Archive_Builder_Options_Ptr : String_List_Access_Function := Archive_Builder_Options_Default'Access; function Archive_Builder_Append_Options_Default return String_List_Access; Archive_Builder_Append_Options_Ptr : String_List_Access_Function := Archive_Builder_Append_Options_Default'Access; function Archive_Ext_Default return String; Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access; function Archive_Indexer_Default return String; Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access; function Archive_Indexer_Options_Default return String_List_Access; Archive_Indexer_Options_Ptr : String_List_Access_Function := Archive_Indexer_Options_Default'Access; function Default_Symbol_File_Name_Default return String; Default_Symbol_File_Name_Ptr : String_Function := Default_Symbol_File_Name_Default'Access; Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function; function DLL_Ext_Default return String; DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access; function DLL_Prefix_Default return String; DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access; function Dynamic_Option_Default return String; Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access; function Is_Object_Ext_Default (Ext : String) return Boolean; Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access; function Is_C_Ext_Default (Ext : String) return Boolean; Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access; function Is_Archive_Ext_Default (Ext : String) return Boolean; Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access; function Libgnat_Default return String; Libgnat_Ptr : String_Function := Libgnat_Default'Access; function Library_Exists_For_Default (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean; Library_Exists_For_Ptr : Library_Exists_For_Function := Library_Exists_For_Default'Access; function Library_File_Name_For_Default (Project : Project_Id; In_Tree : Project_Tree_Ref) return File_Name_Type; Library_File_Name_For_Ptr : Library_File_Name_For_Function := Library_File_Name_For_Default'Access; function Object_Ext_Default return String; Object_Ext_Ptr : String_Function := Object_Ext_Default'Access; function PIC_Option_Default return String; PIC_Option_Ptr : String_Function := PIC_Option_Default'Access; function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean; Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function := Standalone_Library_Auto_Init_Is_Supported_Default'Access; function Support_For_Libraries_Default return Library_Support; Support_For_Libraries_Ptr : Library_Support_Function := Support_For_Libraries_Default'Access; function Library_Major_Minor_Id_Supported_Default return Boolean; Library_Major_Minor_Id_Supported_Ptr : Boolean_Function := Library_Major_Minor_Id_Supported_Default'Access; end MLib.Tgt;
29,935
ada
1
jweese/Ada_Vent_19
lib/space_image_format.adb
<reponame>jweese/Ada_Vent_19 with Ada.Text_IO; package body Space_Image_Format is procedure Get_Pixel(P: out Pixel) is C: Character; begin Ada.Text_IO.Get(C); P := Pixel(C); end Get_Pixel; procedure Get_Layer(L: out Layer) is begin for Row in Height_Range loop for Col in Width_Range loop Get_Pixel(L(Col, Row)); end loop; end loop; end Get_Layer; type Color_Stack is array (Positive range <>) of Color; function To_Color(P: Pixel) return Color is (case P is when '0' => Black, when '1' => White, when '2' => Transparent, when others => raise Constraint_Error); function Get_Stack( LS: Layer_Stack; W: Width_Range; H: Height_Range) return Color_Stack is Result: Color_Stack(LS'Range); begin for I in LS'Range loop Result(I) := To_Color(LS(I)(W, H)); end loop; return Result; end Get_Stack; function Visible(CS: Color_Stack) return Visible_Color is begin for C of CS loop if C in Visible_Color'Range then return C; end if; end loop; raise Constraint_Error; end Visible; function To_Image(S: Layer_Stack) return Image is Result: Image; begin for Row in Height_Range loop for Col in Width_Range loop Result(Col, Row) := Visible(Get_Stack(S, Col, Row)); end loop; end loop; return Result; end To_Image; procedure Put_Image(I: in Image) is function Render(VC: Visible_Color) return Character is (case VC is when Black => ' ', when White => 'X'); Line: String(1 .. Width); begin for Row in Height_Range loop for Col in Width_Range loop Line(Width_Range'Pos(Col)) := Render(I(Col, Row)); end loop; Ada.Text_IO.Put_Line(Line); end loop; end Put_Image; end Space_Image_Format;
29,936
ada
0
Chester-Gillon/ibv_message_parsing
ibv_message_passing_ada_project/source/ibv_message_overlay_gdb_test/ibv_message_overlay_gdb_test.adb
-- @file ibv_controller_process_main.adb -- @date 13 May 2018 -- @author <NAME> -- @details Example program created to demonstrate a GDB crash when using: -- - Eclipse Oxygen 4.7.3a -- - GNATbench Integration with CDT 2.8.1.20140109 -- - GNAT GPL 2017 -- - GDB 7.10 (in the GNAT GPL installation) -- -- Steps to recreate: -- 1) When single stepping the program when get to the first statement with msgs in scope, in the Variables -- window double-click on msgs to try and expand the contents (which fails). -- 2) On the next single step, when msgs is still in scope, GDB crashes with a SISEGV. -- -- Following an upgrade to GNAT Community 2018 which uses GDB 8.1: -- - GDB no longer crashes -- - msgs can be expanded and the contents viewed. with System; with Interfaces.C; use Interfaces.C; with stddef_h; with ibv_controller_worker_messages_h; procedure ibv_message_overlay_gdb_test is function malloc (size : stddef_h.size_t) return System.Address; pragma Import (C, malloc, "malloc"); procedure free (buffer : System.Address); pragma Import (C, free, "free"); tx_buffer : constant System.Address := malloc (ibv_controller_worker_messages_h.controller_to_worker_msgs'Size / 8); begin declare msgs : ibv_controller_worker_messages_h.controller_to_worker_msgs; pragma Import (C, msgs); for msgs'Address use tx_buffer; begin msgs.sum_integers.request_id := Interfaces.C.unsigned (10); msgs.sum_integers.num_integers_to_sum := 30; msgs.sum_integers.integers_to_sum := (others => 16#deaddead#); end; free (tx_buffer); end ibv_message_overlay_gdb_test;
29,937
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c95086e.ada
-- C95086E.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT CONSTRAINT_ERROR IS NOT RAISED BEFORE OR AFTER THE ENTRY -- CALL FOR IN OUT ARRAY PARAMETERS, WHERE THE ACTUAL PARAMETER HAS THE -- FORM OF A TYPE CONVERSION. THE FOLLOWING CASES ARE TESTED: -- (A) OK CASE. -- (B) FORMAL CONSTRAINED, BOTH FORMAL AND ACTUAL HAVE SAME NUMBER -- COMPONENTS PER DIMENSION, BUT ACTUAL INDEX BOUNDS LIE OUTSIDE -- FORMAL INDEX SUBTYPE. -- (C) FORMAL CONSTRAINED, FORMAL AND ACTUAL HAVE DIFFERENT NUMBER -- COMPONENTS PER DIMENSION, BOTH FORMAL AND ACTUAL ARE NULL -- ARRAYS. -- (D) FORMAL CONSTRAINED, ACTUAL NULL, WITH INDEX BOUNDS OUTSIDE -- FORMAL INDEX SUBTYPE. -- (E) FORMAL UNCONSTRAINED, ACTUAL NULL, WITH INDEX BOUNDS OUTSIDE -- FORMAL INDEX SUBTYPE FOR NULL DIMENSIONS ONLY. -- RJW 2/3/86 -- TMB 11/15/95 ELIMINATED INCOMPATIBILITY WITH ADA95 -- TMB 11/19/96 FIXED SLIDING PROBLEM IN SECTION D WITH REPORT; USE REPORT; PROCEDURE C95086E IS BEGIN TEST ("C95086E", "CHECK THAT CONSTRAINT_ERROR IS NOT RAISED " & "BEFORE OR AFTER THE ENTRY CALL FOR IN OUT ARRAY " & "PARAMETERS, WITH THE ACTUAL HAVING THE FORM OF A TYPE " & "CONVERSION"); --------------------------------------------- DECLARE -- (A) SUBTYPE INDEX IS INTEGER RANGE 1..5; TYPE ARRAY_TYPE IS ARRAY (INDEX RANGE <>, INDEX RANGE <>) OF BOOLEAN; SUBTYPE FORMAL IS ARRAY_TYPE (1..3, 1..3); SUBTYPE ACTUAL IS ARRAY_TYPE (1..3, 1..3); AR : ACTUAL := (1..3 => (1..3 => TRUE)); CALLED : BOOLEAN := FALSE; TASK T IS ENTRY E (X : IN OUT FORMAL); END T; TASK BODY T IS BEGIN ACCEPT E (X : IN OUT FORMAL) DO CALLED := TRUE; END E; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED IN TASK - (A)"); END T; BEGIN -- (A) T.E (FORMAL (AR)); EXCEPTION WHEN CONSTRAINT_ERROR => IF NOT CALLED THEN FAILED ("EXCEPTION RAISED BEFORE CALL - (A)"); ELSE FAILED ("EXCEPTION RAISED ON RETURN - (A)"); END IF; WHEN OTHERS => FAILED ("EXCEPTION RAISED - (A)"); END; -- (A) --------------------------------------------- DECLARE -- (B) SUBTYPE INDEX IS INTEGER RANGE 1..3; TYPE FORMAL IS ARRAY (INDEX, INDEX) OF BOOLEAN; TYPE ACTUAL IS ARRAY (3..5, 3..5) OF BOOLEAN; AR : ACTUAL := (3..5 => (3..5 => FALSE)); CALLED : BOOLEAN := FALSE; TASK T IS ENTRY E (X : IN OUT FORMAL); END T; TASK BODY T IS BEGIN ACCEPT E (X : IN OUT FORMAL) DO CALLED := TRUE; X(3, 3) := TRUE; END E; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED IN TASK - (B)"); END T; BEGIN -- (B) T.E (FORMAL (AR)); IF AR(5, 5) /= TRUE THEN FAILED ("INCORRECT RETURNED VALUE - (B)"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => IF NOT CALLED THEN FAILED ("EXCEPTION RAISED BEFORE CALL - (B)"); ELSE FAILED ("EXCEPTION RAISED ON RETURN - (B)"); END IF; WHEN OTHERS => FAILED ("EXCEPTION RAISED - (B)"); END; -- (B) --------------------------------------------- DECLARE -- (C) SUBTYPE INDEX IS INTEGER RANGE 1..5; TYPE ARRAY_TYPE IS ARRAY (INDEX RANGE <>, INDEX RANGE <>) OF CHARACTER; SUBTYPE FORMAL IS ARRAY_TYPE (2..0, 1..3); AR : ARRAY_TYPE (2..1, 1..3) := (2..1 => (1..3 => ' ')); CALLED : BOOLEAN := FALSE; TASK T IS ENTRY E (X : IN OUT FORMAL); END T; TASK BODY T IS BEGIN ACCEPT E (X : IN OUT FORMAL) DO IF X'LAST /= 0 AND X'LAST(2) /= 3 THEN FAILED ("WRONG BOUNDS PASSED - (C)"); END IF; CALLED := TRUE; X := (2..0 => (1..3 => 'A')); END E; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED IN TASK - (C)"); END T; BEGIN -- (C) T.E (FORMAL (AR)); IF AR'LAST /= 1 AND AR'LAST(2) /= 3 THEN FAILED ("BOUNDS CHANGED - (C)"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => IF NOT CALLED THEN FAILED ("EXCEPTION RAISED BEFORE CALL - (C)"); ELSE FAILED ("EXCEPTION RAISED ON RETURN - (C)"); END IF; WHEN OTHERS => FAILED ("EXCEPTION RAISED - (C)"); END; -- (C) --------------------------------------------- DECLARE -- (D) SUBTYPE INDEX IS INTEGER RANGE 1..3; TYPE FORMAL IS ARRAY (INDEX RANGE 1..3, INDEX RANGE 3..1) OF CHARACTER; TYPE ACTUAL IS ARRAY (3..5, 5..3) OF CHARACTER; AR : ACTUAL := (3..5 => (5..3 => ' ')); CALLED : BOOLEAN := FALSE; TASK T IS ENTRY E (X : IN OUT FORMAL); END T; TASK BODY T IS BEGIN ACCEPT E (X : IN OUT FORMAL) DO IF X'LAST /= 3 AND X'LAST(2) /= 1 THEN FAILED ("WRONG BOUNDS PASSED - (D)"); END IF; CALLED := TRUE; X := (1..3 => (3..1 => 'A')); END E; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED IN TASK - (D)"); END T; BEGIN -- (D) T.E (FORMAL (AR)); IF AR'LAST /= 5 AND AR'LAST(2) /= 3 THEN FAILED ("BOUNDS CHANGED - (D)"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => IF NOT CALLED THEN FAILED ("EXCEPTION RAISED BEFORE CALL - (D)"); ELSE FAILED ("EXCEPTION RAISED ON RETURN - (D)"); END IF; WHEN OTHERS => FAILED ("EXCEPTION RAISED - (D)"); END; -- (D) --------------------------------------------- DECLARE -- (E) SUBTYPE INDEX IS INTEGER RANGE 1..3; TYPE FORMAL IS ARRAY (INDEX RANGE <>, INDEX RANGE <>) OF CHARACTER; TYPE ACTUAL IS ARRAY (POSITIVE RANGE 5..2, POSITIVE RANGE 1..3) OF CHARACTER; AR : ACTUAL := (5..2 => (1..3 => ' ')); CALLED : BOOLEAN := FALSE; TASK T IS ENTRY E (X : IN OUT FORMAL); END T; TASK BODY T IS BEGIN ACCEPT E (X : IN OUT FORMAL) DO IF X'LAST /= 2 AND X'LAST(2) /= 3 THEN FAILED ("WRONG BOUNDS PASSED - (E)"); END IF; CALLED := TRUE; X := (3..1 => (1..3 => ' ')); END E; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED IN TASK - (E)"); END T; BEGIN -- (E) T.E (FORMAL (AR)); IF AR'LAST /= 2 AND AR'LAST(2) /= 3 THEN FAILED ("BOUNDS CHANGED - (E)"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => IF NOT CALLED THEN FAILED ("EXCEPTION RAISED BEFORE CALL - (E)"); ELSE FAILED ("EXCEPTION RAISED ON RETURN - (E)"); END IF; WHEN OTHERS => FAILED ("EXCEPTION RAISED - (E)"); END; -- (E) --------------------------------------------- RESULT; END C95086E;
29,938
ada
0
Fabien-Chouteau/libriscv
src/libriscv-sim-log.adb
<reponame>Fabien-Chouteau/libriscv<filename>src/libriscv-sim-log.adb ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, <NAME> -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body LibRISCV.Sim.Log is ------------- -- Set_Arg -- ------------- function Set_Arg (S : String) return Boolean is function Handle_Item (Item : String) return Boolean is Enable : constant Boolean := Item (Item'First) /= '-'; Substr : constant String := Item ((if not Enable then Item'First + 1 else Item'First) .. Item'Last); begin if Substr = "console" then Console := Enable; elsif Substr = "info" then Info := Enable; elsif Substr = "decode" then Decode := Enable; elsif Substr = "exec" then Exec := Enable; elsif Substr = "except" then Except := Enable; elsif Substr = "mem" then Mem_Access := Enable; elsif Substr = "csr" then CSRs := Enable; elsif Substr = "elf" then Elf := Enable; else Put_Line ("Log topics:"); Put_Line (" - console"); Put_Line (" - info"); Put_Line (" - decode"); Put_Line (" - exec"); Put_Line (" - except"); Put_Line (" - mem"); Put_Line (" - csr"); Put_Line (" - elf"); return False; end if; return True; end Handle_Item; From, To : Integer; begin From := S'First; To := S'First - 1; loop To := To + 1; if To > S'Last or else S (To) = ',' then if To > From then if not Handle_Item (S (From .. To - 1)) then return False; end if; end if; To := To + 1; From := To; end if; exit when To > S'Last; end loop; return True; end Set_Arg; end LibRISCV.Sim.Log;
29,939
ada
23
TejasAvinashShetty/code2tex
hello_worlds/ADA.ada
with Ada.Text_Io; procedure Hello_World is begin Ada.Text_Io.Put_Line("Hello World!"); end;
29,940
ada
18
kraileth/ravenadm
src/portscan-packager.adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with File_Operations; with PortScan.Log; with Parameters; with Unix; with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Text_IO; package body PortScan.Packager is package FOP renames File_Operations; package LOG renames PortScan.Log; package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package TIO renames Ada.Text_IO; package PM renames Parameters; -------------------------------------------------------------------------------------------- -- exec_phase_package -------------------------------------------------------------------------------------------- function exec_phase_package (specification : PSP.Portspecs; log_handle : in out TIO.File_Type; log_name : String; phase_name : String; seq_id : port_id; port_prefix : String; rootdir : String) return Boolean is procedure metadata (position : subpackage_crate.Cursor); procedure package_it (position : subpackage_crate.Cursor); namebase : constant String := HT.USS (all_ports (seq_id).port_namebase); conbase : constant String := "/construction/" & namebase; spkgdir : constant String := rootdir & "/construction/metadata/"; wrkdir : constant String := rootdir & conbase; chspkgdir : constant String := "/construction/metadata/"; newpkgdir : constant String := "/construction/new_packages"; stagedir : constant String := conbase & "/stage"; display : constant String := "/+DISPLAY"; pkgvers : constant String := HT.USS (all_ports (seq_id).pkgversion); usrgrp_pkg : constant String := specification.get_field_value (PSP.sp_ug_pkg); ug_install : constant String := wrkdir & "/users-groups-install.sh"; ug_desinst : constant String := wrkdir & "/users-groups-deinstall.sh"; still_good : Boolean := True; procedure metadata (position : subpackage_crate.Cursor) is type three is range 1 .. 3; function convert_prepost (prepost : three) return String; function convert_stage (stage : three) return String; subpackage : constant String := HT.USS (subpackage_crate.Element (position).subpackage); message_file : constant String := wrkdir & "/.PKG_DISPLAY." & subpackage; descript_file : constant String := wrkdir & "/.PKG_DESC." & subpackage; scr_preinst : constant String := spkgdir & subpackage & "/pkg-pre-install"; scr_pstdeinst : constant String := spkgdir & subpackage & "/pkg-post-deinstall"; descript : String := "/+DESC"; manifest : String := "/+MANIFEST"; function convert_prepost (prepost : three) return String is begin case prepost is when 1 => return "pre-"; when 2 => return ""; when 3 => return "post-"; end case; end convert_prepost; function convert_stage (stage : three) return String is begin case stage is when 1 => return "install"; when 2 => return "upgrade"; when 3 => return "deinstall"; end case; end convert_stage; begin DIR.Create_Path (spkgdir & subpackage); if DIR.Exists (message_file) then DIR.Copy_File (Source_Name => message_file, Target_Name => spkgdir & subpackage & display); end if; if DIR.Exists (descript_file) then DIR.Copy_File (Source_Name => descript_file, Target_Name => spkgdir & subpackage & descript); end if; for action in three'Range loop for psp in three'Range loop declare script_file : String := wrkdir & "/pkg-" & convert_prepost (psp) & convert_stage (action) & "." & subpackage; pkg_script : String := spkgdir & subpackage & "/pkg-" & convert_prepost (psp) & convert_stage (action); begin if DIR.Exists (script_file) then DIR.Copy_File (Source_Name => script_file, Target_Name => pkg_script); end if; end; end loop; end loop; if subpackage = usrgrp_pkg then if DIR.Exists (ug_install) then FOP.concatenate_file (basefile => scr_preinst, another_file => ug_install); end if; if DIR.Exists (ug_desinst) then FOP.concatenate_file (basefile => scr_pstdeinst, another_file => ug_desinst); end if; end if; write_package_manifest (spec => specification, port_prefix => port_prefix, subpackage => subpackage, seq_id => seq_id, pkgversion => pkgvers, filename => spkgdir & subpackage & manifest); end metadata; procedure package_it (position : subpackage_crate.Cursor) is subpackage : constant String := HT.USS (subpackage_crate.Element (position).subpackage); package_list : constant String := conbase & "/.manifest." & subpackage & ".mktmp"; FORCE_POST_PATTERNS : constant String := "rmdir mkfontscale mkfontdir fc-cache " & "fonts.dir fonts.scale gtk-update-icon-cache gio-querymodules gtk-query-immodules " & "load-octave-pkg ocamlfind update-desktop-database update-mime-database " & "gdk-pixbuf-query-loaders catalog.ports glib-compile-schemas ccache-update-links"; MORE_ENV : constant String := " RAVENSW_DBDIR=/var/db/pkg8" & " PLIST_KEYWORDS_DIR=/xports/Mk/Keywords "; PKG_CREATE : constant String := "/usr/bin/ravensw create"; PKG_CREATE_ARGS : constant String := " --root-dir " & stagedir & " --metadata " & chspkgdir & subpackage & " --plist " & package_list & " --out-dir " & newpkgdir & " --verbose "; namebase : constant String := specification.get_namebase; pkgname : String := namebase & "-" & subpackage & "-" & HT.USS (all_ports (seq_id).port_variant) & "-" & pkgvers; package_cmd : constant String := PM.chroot_cmd & rootdir & " /usr/bin/env FORCE_POST=" & LAT.Quotation & FORCE_POST_PATTERNS & LAT.Quotation & MORE_ENV & PKG_CREATE & PKG_CREATE_ARGS & pkgname; move_cmd : constant String := PM.chroot_cmd & rootdir & " /bin/mv " & newpkgdir & "/" & pkgname & arc_ext & " /packages/All/"; link_cmd : constant String := PM.chroot_cmd & rootdir & " /bin/ln -sf /packages/All/" & pkgname & arc_ext & " /packages/Latest/" & pkgname & arc_ext; begin if still_good then if DIR.Exists (spkgdir & subpackage & display) then dump_pkg_message_to_log (display_file => spkgdir & subpackage & display, log_handle => log_handle); end if; if not DIR.Exists (rootdir & package_list) then still_good := False; TIO.Put_Line (log_handle, "=> The package list " & package_list & " for the " & subpackage & " subpackage does not exist."); end if; TIO.Put_Line (log_handle, "===> Building " & pkgname & " subpackage"); TIO.Close (log_handle); still_good := execute_command (package_cmd, log_name); if still_good then still_good := execute_command (move_cmd, log_name); end if; if still_good and then namebase = "pkg" then still_good := execute_command (link_cmd, log_name); end if; TIO.Open (File => log_handle, Mode => TIO.Append_File, Name => log_name); end if; end package_it; begin LOG.log_phase_begin (log_handle, phase_name); all_ports (seq_id).subpackages.Iterate (metadata'Access); check_deprecation (specification, log_handle); if not create_package_directory_if_necessary (log_handle) or else not create_latest_package_directory_too (log_handle) then return False; end if; DIR.Create_Directory (rootdir & newpkgdir); all_ports (seq_id).subpackages.Iterate (package_it'Access); LOG.log_phase_end (log_handle); return still_good; exception when others => return False; end exec_phase_package; -------------------------------------------------------------------------------------------- -- create_package_directory_if_necessary -------------------------------------------------------------------------------------------- function create_package_directory_if_necessary (log_handle : TIO.File_Type) return Boolean is packagedir : String := HT.USS (PM.configuration.dir_repository); begin if DIR.Exists (packagedir) then return True; end if; DIR.Create_Directory (packagedir); return True; exception when others => TIO.Put_Line (log_handle, "=> Can't create directory " & packagedir); return False; end create_package_directory_if_necessary; -------------------------------------------------------------------------------------------- -- create_package_directory_if_necessary -------------------------------------------------------------------------------------------- function create_latest_package_directory_too (log_handle : TIO.File_Type) return Boolean is packagedir : String := HT.USS (PM.configuration.dir_packages) & "/Latest"; begin if DIR.Exists (packagedir) then return True; end if; DIR.Create_Directory (packagedir); return True; exception when others => TIO.Put_Line (log_handle, "=> Can't create directory " & packagedir); return False; end create_latest_package_directory_too; -------------------------------------------------------------------------------------------- -- dump_pkg_message_to_log -------------------------------------------------------------------------------------------- procedure dump_pkg_message_to_log (display_file : String; log_handle : TIO.File_Type) is File_Size : Natural := Natural (DIR.Size (display_file)); begin if File_Size = 0 then DIR.Delete_File (display_file); else declare contents : String := FOP.get_file_contents (display_file); begin TIO.Put_Line (log_handle, contents); end; end if; end dump_pkg_message_to_log; -------------------------------------------------------------------------------------------- -- check_deprecation -------------------------------------------------------------------------------------------- procedure check_deprecation (spec : PSP.Portspecs; log_handle : TIO.File_Type) is deprecated : String := spec.get_field_value (PSP.sp_deprecated); expire_date : String := spec.get_field_value (PSP.sp_expiration); begin if deprecated /= "" then TIO.Put_Line (log_handle, "===> NOTICE:" & LAT.LF & LAT.LF & "This port is deprecated; you may wish to consider avoiding its packages." & LAT.LF & LAT.LF & deprecated & LAT.Full_Stop & LAT.LF & "It is scheduled to be removed on or after " & expire_date & LAT.LF ); end if; end check_deprecation; -------------------------------------------------------------------------------------------- -- quote -------------------------------------------------------------------------------------------- function quote (thetext : String) return String is begin return LAT.Quotation & thetext & LAT.Quotation; end quote; -------------------------------------------------------------------------------------------- -- write_package_manifest -------------------------------------------------------------------------------------------- procedure write_package_manifest (spec : PSP.Portspecs; port_prefix : String; subpackage : String; seq_id : port_id; pkgversion : String; filename : String) is procedure single_if_defined (name, value, not_value : String); procedure array_if_defined (name, value : String); function short_desc return String; file_handle : TIO.File_Type; variant : String := HT.USS (all_ports (seq_id).port_variant); procedure single_if_defined (name, value, not_value : String) is begin if value /= "" and then value /= not_value then TIO.Put_Line (file_handle, name & ": " & quote (value)); end if; end single_if_defined; procedure array_if_defined (name, value : String) is -- No identified need for quoting begin if value /= "" then TIO.Put_Line (file_handle, name & ": [ " & value & " ]"); end if; end array_if_defined; function short_desc return String is begin if spec.get_subpackage_length (variant) = 1 then return spec.get_tagline (variant); else return spec.get_tagline (variant) & " (" & subpackage & ")"; end if; end short_desc; name : String := quote (spec.get_namebase & "-" & subpackage & "-" & variant); origin : String := quote (spec.get_namebase & ":" & variant); begin TIO.Create (File => file_handle, Mode => TIO.Out_File, Name => filename); TIO.Put_Line (file_handle, LAT.Left_Curly_Bracket & LAT.LF & "name: " & name & LAT.LF & "version: " & quote (pkgversion) & LAT.LF & "origin: " & origin & LAT.LF & "comment: <<EOD" & LAT.LF & short_desc & LAT.LF & "EOD" & LAT.LF & "maintainer: " & quote (spec.get_field_value (PSP.sp_contacts)) & LAT.LF & "prefix: " & quote (port_prefix) & LAT.LF & "categories: [ " & spec.get_field_value (PSP.sp_keywords) & " ]" & LAT.LF & "licenselogic: " & quote (spec.get_license_scheme) ); -- We prefer "none" to "WWW : UNKNOWN" in the package manifest single_if_defined ("www", spec.get_field_value (PSP.sp_homepage), ""); array_if_defined ("licenses", spec.get_field_value (PSP.sp_licenses)); array_if_defined ("users", spec.get_field_value (PSP.sp_users)); array_if_defined ("groups", spec.get_field_value (PSP.sp_groups)); TIO.Put_Line (file_handle, "deps: {"); write_down_run_dependencies (file_handle, seq_id, subpackage); TIO.Put_Line (file_handle, "}"); TIO.Put_Line (file_handle, "options: {" & spec.get_options_list (variant) & " }"); write_package_annotations (spec, file_handle); -- Closing Curly Brace for manifest TIO.Put_Line (file_handle, "}"); TIO.Close (file_handle); exception when others => if TIO.Is_Open (file_handle) then TIO.Close (file_handle); end if; end write_package_manifest; -------------------------------------------------------------------------------------------- -- write_complete_metapackage_deps -------------------------------------------------------------------------------------------- procedure write_complete_metapackage_deps (spec : PSP.Portspecs; file_handle : TIO.File_Type; variant : String; pkgversion : String) is namebase : constant String := spec.get_namebase; num_subpackages : constant Natural := spec.get_subpackage_length (variant); begin for spkg in 1 .. num_subpackages loop declare subpackage : constant String := spec.get_subpackage_item (variant, spkg); begin if subpackage /= spkg_complete then TIO.Put_Line (file_handle, " " & quote (namebase & LAT.Hyphen & subpackage & LAT.Hyphen & variant) & " : {"); TIO.Put_Line (file_handle, " version : " & quote (pkgversion) & "," & LAT.LF & " origin : " & quote (namebase & LAT.Colon & variant) & LAT.LF & " },"); end if; end; end loop; end write_complete_metapackage_deps; -------------------------------------------------------------------------------------------- -- write_down_run_dependencies -------------------------------------------------------------------------------------------- procedure write_down_run_dependencies (file_handle : TIO.File_Type; seq_id : port_id; subpackage : String) is procedure scan (position : subpackage_crate.Cursor); procedure write_pkg_dep (pkgname, pkgversion, portkey : String); procedure assemble_origins (dep_position : spkg_id_crate.Cursor); found_subpackage : Boolean := False; procedure write_pkg_dep (pkgname, pkgversion, portkey : String) is begin TIO.Put_Line (file_handle, " " & quote (pkgname) & " : {"); TIO.Put_Line (file_handle, " version : " & quote (pkgversion) & "," & LAT.LF & " origin : " & quote (portkey) & LAT.LF & " },"); end write_pkg_dep; procedure assemble_origins (dep_position : spkg_id_crate.Cursor) is sprec : subpackage_identifier renames spkg_id_crate.Element (dep_position); namebase : String := HT.USS (all_ports (sprec.port).port_namebase); variant : String := HT.USS (all_ports (sprec.port).port_variant); portkey : String := namebase & LAT.Colon & variant; pkgversion : String := HT.USS (all_ports (sprec.port).pkgversion); pkgname : String := namebase & LAT.Hyphen & HT.USS (sprec.subpackage) & LAT.Hyphen & variant; begin write_pkg_dep (pkgname, pkgversion, portkey); end assemble_origins; procedure scan (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); begin if not found_subpackage then if HT.equivalent (rec.subpackage, subpackage) then found_subpackage := True; rec.spkg_run_deps.Iterate (assemble_origins'Access); end if; end if; end scan; begin all_ports (seq_id).subpackages.Iterate (scan'Access); end write_down_run_dependencies; -------------------------------------------------------------------------------------------- -- write_package_annotations -------------------------------------------------------------------------------------------- procedure write_package_annotations (spec : PSP.Portspecs; file_handle : TIO.File_Type) is num_notes : constant Natural := spec.get_list_length (PSP.sp_notes); begin if num_notes = 0 then return; end if; TIO.Put_Line (file_handle, "annotations: {"); for note in 1 .. num_notes loop declare nvpair : String := spec.get_list_item (PSP.sp_notes, note); key : String := HT.part_1 (nvpair, "="); value : String := HT.part_2 (nvpair, "="); begin TIO.Put_Line (file_handle, key & ": <<EOD" & LAT.LF & value & LAT.LF & "EOD"); end; end loop; TIO.Put_Line (file_handle, "}"); end write_package_annotations; -------------------------------------------------------------------------------------------- -- execute_command -------------------------------------------------------------------------------------------- function execute_command (command : String; name_of_log : String) return Boolean is use type Unix.process_exit; pid : Unix.pid_t; status : Unix.process_exit; hangmonitor : constant Boolean := True; truecommand : constant String := ravenexec & " " & name_of_log & " " & command; begin pid := Unix.launch_process (truecommand); if Unix.fork_failed (pid) then return False; end if; loop delay 0.25; status := Unix.process_status (pid); if status = Unix.exited_normally then return True; end if; if status = Unix.exited_with_error then return False; end if; end loop; end execute_command; end PortScan.Packager;
29,941
ada
1
Hathoute/ENSEEIHT
PIM/Projet/src/lca.ads
<gh_stars>1-10 with SDA_Exceptions; use SDA_Exceptions; -- Définition de structures de données associatives sous forme d'une liste -- chaînée associative (LCA). generic type T_Cle is private; type T_Donnee is private; package LCA is type T_LCA is private; -- Initialiser une Sda. La Sda est vide. procedure Initialiser(Sda: out T_LCA) with Post => Est_Vide (Sda); -- Est-ce qu'une Sda est vide ? function Est_Vide (Sda : T_LCA) return Boolean; -- Obtenir le nombre d'éléments d'une Sda. function Taille (Sda : in T_LCA) return Integer with Post => Taille'Result >= 0 and (Taille'Result = 0) = Est_Vide (Sda); -- Enregistrer une Donnée associée à une Clé dans une Sda. -- Si la clé est déjà présente dans la Sda, sa donnée est changée. procedure Enregistrer (Sda : in out T_LCA ; Cle : in T_Cle ; Donnee : in T_Donnee) with Post => Cle_Presente (Sda, Cle) and then (La_Donnee (Sda, Cle) = Donnee) -- donnée insérée -- and then (if not (Cle_Presente (Sda, Cle)'Old) then Taille (Sda) = Taille (Sda)'Old) -- and then (if Cle_Presente (Sda, Cle)'Old then Taille (Sda) = Taille (Sda)'Old + 1) ; -- Supprimer la Donnée associée à une Clé dans une Sda. -- Exception : Cle_Absente_Exception si Clé n'est pas utilisée dans la Sda procedure Supprimer (Sda : in out T_LCA ; Cle : in T_Cle) with Post => Taille (Sda) = Taille (Sda)'Old - 1 -- un élément de moins and not Cle_Presente (Sda, Cle); -- la clé a été supprimée -- Savoir si une Clé est présente dans une Sda. function Cle_Presente (Sda : in T_LCA ; Cle : in T_Cle) return Boolean; -- Obtenir la donnée associée à une Cle dans la Sda. -- Exception : Cle_Absente_Exception si Clé n'est pas utilisée dans l'Sda function La_Donnee (Sda : in T_LCA ; Cle : in T_Cle) return T_Donnee; -- Supprimer tous les éléments d'une Sda. procedure Vider (Sda : in out T_LCA) with Post => Est_Vide (Sda); -- Appliquer un traitement (Traiter) pour chaque couple d'une Sda. generic with procedure Traiter (Cle : in T_Cle; Donnee: in T_Donnee); procedure Pour_Chaque (Sda : in T_LCA); private type T_Cellule; type T_LCA is access T_Cellule; type T_Cellule is record Cle : T_Cle; Donnee : T_Donnee; Suivant : T_LCA; end record; end LCA;
29,942
ada
24
svn2github/matreshka
source/amf/uml/amf-uml-extends.ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- 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. ------------------------------------------------------------------------------ -- A relationship from an extending use case to an extended use case that -- specifies how and when the behavior defined in the extending use case can -- be inserted into the behavior defined in the extended use case. ------------------------------------------------------------------------------ limited with AMF.UML.Constraints; with AMF.UML.Directed_Relationships; limited with AMF.UML.Extension_Points.Collections; with AMF.UML.Named_Elements; limited with AMF.UML.Use_Cases; package AMF.UML.Extends is pragma Preelaborate; type UML_Extend is limited interface and AMF.UML.Directed_Relationships.UML_Directed_Relationship and AMF.UML.Named_Elements.UML_Named_Element; type UML_Extend_Access is access all UML_Extend'Class; for UML_Extend_Access'Storage_Size use 0; not overriding function Get_Condition (Self : not null access constant UML_Extend) return AMF.UML.Constraints.UML_Constraint_Access is abstract; -- Getter of Extend::condition. -- -- References the condition that must hold when the first extension point -- is reached for the extension to take place. If no constraint is -- associated with the extend relationship, the extension is unconditional. not overriding procedure Set_Condition (Self : not null access UML_Extend; To : AMF.UML.Constraints.UML_Constraint_Access) is abstract; -- Setter of Extend::condition. -- -- References the condition that must hold when the first extension point -- is reached for the extension to take place. If no constraint is -- associated with the extend relationship, the extension is unconditional. not overriding function Get_Extended_Case (Self : not null access constant UML_Extend) return AMF.UML.Use_Cases.UML_Use_Case_Access is abstract; -- Getter of Extend::extendedCase. -- -- References the use case that is being extended. not overriding procedure Set_Extended_Case (Self : not null access UML_Extend; To : AMF.UML.Use_Cases.UML_Use_Case_Access) is abstract; -- Setter of Extend::extendedCase. -- -- References the use case that is being extended. not overriding function Get_Extension (Self : not null access constant UML_Extend) return AMF.UML.Use_Cases.UML_Use_Case_Access is abstract; -- Getter of Extend::extension. -- -- References the use case that represents the extension and owns the -- extend relationship. not overriding procedure Set_Extension (Self : not null access UML_Extend; To : AMF.UML.Use_Cases.UML_Use_Case_Access) is abstract; -- Setter of Extend::extension. -- -- References the use case that represents the extension and owns the -- extend relationship. not overriding function Get_Extension_Location (Self : not null access constant UML_Extend) return AMF.UML.Extension_Points.Collections.Ordered_Set_Of_UML_Extension_Point is abstract; -- Getter of Extend::extensionLocation. -- -- An ordered list of extension points belonging to the extended use case, -- specifying where the respective behavioral fragments of the extending -- use case are to be inserted. The first fragment in the extending use -- case is associated with the first extension point in the list, the -- second fragment with the second point, and so on. (Note that, in most -- practical cases, the extending use case has just a single behavior -- fragment, so that the list of extension points is trivial.) end AMF.UML.Extends;
29,943
ada
4
reznikmm/jupyter
examples/hello_world/hello_world.adb
<reponame>reznikmm/jupyter<gh_stars>1-10 -- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with League.JSON.Values; package body Hello_World is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function "-" (Text : Wide_Wide_String) return League.JSON.Values.JSON_Value is (League.JSON.Values.To_JSON_Value (+Text)); -------------------- -- Create_Session -- -------------------- overriding procedure Create_Session (Self : aliased in out Kernel; Session_Id : Positive; Result : out Jupyter.Kernels.Session_Access) is Object : constant Session_Access := new Session; begin Result := Jupyter.Kernels.Session_Access (Object); Self.Map.Insert (Session_Id, Object); end Create_Session; ------------- -- Execute -- ------------- overriding procedure Execute (Self : aliased in out Session; IO_Pub : not null Jupyter.Kernels.IO_Pub_Access; Execution_Counter : Positive; Code : League.Strings.Universal_String; Silent : Boolean; User_Expressions : League.JSON.Objects.JSON_Object; Allow_Stdin : Boolean; Stop_On_Error : Boolean; Expression_Values : out League.JSON.Objects.JSON_Object; Error : in out Jupyter.Kernels.Execution_Error) is pragma Unreferenced (Execution_Counter, User_Expressions, Allow_Stdin, Stop_On_Error, Expression_Values, Error, Self); Data : League.JSON.Objects.JSON_Object; Meta : League.JSON.Objects.JSON_Object; begin Expression_Values := League.JSON.Objects.Empty_JSON_Object; if not Silent then Data.Insert (+"text/plain", League.JSON.Values.To_JSON_Value (Code)); IO_Pub.Execute_Result (Data => Data, Metadata => Meta, Transient => League.JSON.Objects.Empty_JSON_Object); end if; end Execute; ----------------- -- Get_Session -- ----------------- overriding function Get_Session (Self : aliased in out Kernel; Session_Id : Positive) return Jupyter.Kernels.Session_Access is Result : constant Session_Access := Self.Map (Session_Id); begin return Jupyter.Kernels.Session_Access (Result); end Get_Session; ----------------- -- Kernel_Info -- ----------------- overriding procedure Kernel_Info (Self : aliased in out Kernel; Result : out League.JSON.Objects.JSON_Object) is pragma Unreferenced (Self); Language : League.JSON.Objects.JSON_Object; begin Language.Insert (+"name", -"Hello World"); Language.Insert (+"version", -"2012"); Language.Insert (+"mimetype", -"text/x-ada"); Language.Insert (+"file_extension", -".adb"); Language.Insert (+"pygments_lexer", -"ada"); Language.Insert (+"codemirror_mode", -"ada"); Result.Insert (+"protocol_version", -"5.3"); Result.Insert (+"implementation", -"dummy"); Result.Insert (+"implementation_version", -"0.1.0"); Result.Insert (+"language_info", Language.To_JSON_Value); Result.Insert (+"banner", -"Some banner."); Result.Insert (+"status", -"ok"); end Kernel_Info; end Hello_World;
29,944
ada
1
faelys/natools-web
src/natools-web-reload_pages.adb
<reponame>faelys/natools-web<filename>src/natools-web-reload_pages.adb ------------------------------------------------------------------------------ -- Copyright (c) 2015, <NAME> -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Natools.S_Expressions.Atom_Ref_Constructors; with Natools.Web.Error_Pages; with Natools.Web.Exchanges; with Natools.Web.Sites.Updates; package body Natools.Web.Reload_Pages is overriding procedure Respond (Object : in out Reload_Page; Exchange : in out Sites.Exchange; Extra_Path : in S_Expressions.Atom) is begin if Extra_Path'Length > 0 then return; end if; Check_Method : declare use Exchanges; Allowed : Boolean; begin Error_Pages.Check_Method (Exchange, POST, Allowed); if not Allowed then return; end if; end Check_Method; Sites.Updates.Reload (Exchange.Site.all); Error_Pages.See_Other (Exchange, Object.Target.Query); end Respond; overriding procedure Load (Object : in out Loader; Builder : in out Sites.Site_Builder; Path : in S_Expressions.Atom) is begin Sites.Insert (Builder, Path, Reload_Page'(Target => Object.Target)); end Load; function Create (File : in S_Expressions.Atom) return Sites.Page_Loader'Class is begin return Loader' (Target => S_Expressions.Atom_Ref_Constructors.Create (File)); end Create; end Natools.Web.Reload_Pages;
29,945
ada
0
reznikmm/webidl
source/lexer/generated/webidl-scanners-on_accept.adb
<reponame>reznikmm/webidl<gh_stars>0 separate (WebIDL.Scanners) procedure On_Accept (Self : not null access WebIDL.Scanner_Handlers.Handler'Class; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean) is begin case Rule is when 1 => Self.Delimiter (Scanner, Rule, Token, Skip); when 2 => Self.Ellipsis (Scanner, Rule, Token, Skip); when 3 => Self.Integer (Scanner, Rule, Token, Skip); when 4 => Self.Decimal (Scanner, Rule, Token, Skip); when 5 => Self.Identifier (Scanner, Rule, Token, Skip); when 6 => Self.String (Scanner, Rule, Token, Skip); when 7 => Self.Whitespace (Scanner, Rule, Token, Skip); when 8 => Self.Line_Comment (Scanner, Rule, Token, Skip); when 9 => Self.Comment_Start (Scanner, Rule, Token, Skip); when 10 => Self.Comment_End (Scanner, Rule, Token, Skip); when 11 => Self.Comment_Text (Scanner, Rule, Token, Skip); when others => raise Constraint_Error; end case; end On_Accept;
29,946
ada
4
faelys/gela-asis
source/libgela/gela-source_buffers.ads
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ -- Purpose: -- Abstract interface to source text buffers. -- -- Such buffer contains source represented as array of code units. -- Direct pointer (cursor) to code units provided to speed access up. -- User is responsible to watch pointer stay in buffer boundaries. -- Special code unit value (End_Of_File) is returned when end of -- source buffer is reached. with Interfaces.C.Pointers; package Gela.Source_Buffers is pragma Preelaborate; type Cursor is private; type Source_Buffer is abstract tagged private; function Buffer_Start (Object : Source_Buffer) return Cursor is abstract; subtype Code_Unit is Character; function Element (Object : Cursor) return Code_Unit; procedure Next (Object : in out Cursor); function "-" (Left, Right : Cursor) return Integer; End_Of_File : constant Code_Unit; Use_Error : exception; private pragma Inline (Element); pragma Inline (Next); pragma Inline ("-"); End_Of_File : constant Code_Unit := Code_Unit'Val (0); type Code_Unit_Array is array (Positive range <>) of aliased Code_Unit; package Pointers is new Interfaces.C.Pointers (Index => Positive, Element => Code_Unit, Element_Array => Code_Unit_Array, Default_Terminator => End_Of_File); type Cursor is new Pointers.Pointer; type Source_Buffer is abstract tagged null record; end Gela.Source_Buffers; ------------------------------------------------------------------------------ -- Copyright (c) 2008, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. -- -- Authors: -- <NAME> -- <NAME> -- <NAME> ------------------------------------------------------------------------------
29,947
ada
6
adnio/Ada_Drivers_Library
arch/ARM/Nordic/drivers/nrf51-temperature.adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with NRF51_SVD.TEMP; use NRF51_SVD.TEMP; with HAL; use HAL; package body nRF51.Temperature is type RAW_Temp is delta 0.25 range Temp_Celcius'First * 4.0 .. Temp_Celcius'Last * 4.0; ---------- -- Read -- ---------- function Read return Temp_Celcius is Raw : RAW_Temp; begin -- Clear event TEMP_Periph.EVENTS_DATARDY := 0; -- Start temperature measurement TEMP_Periph.TASKS_START := 1; while TEMP_Periph.EVENTS_DATARDY = 0 loop null; end loop; Raw := RAW_Temp (TEMP_Periph.TEMP); return Temp_Celcius (Raw / 4); end Read; end nRF51.Temperature;
29,948
ada
0
sciencylab/lagrangian-solver
drivers/ad_test.adb
<gh_stars>0 with Numerics, Numerics.Sparse_Matrices, Auto_Differentiation, Ada.Text_IO; use Numerics, Numerics.Sparse_Matrices, Auto_Differentiation, Ada.Text_IO; -- with Forward_AD, Forward_AD.Hamiltonian, Ada.Text_IO, Numerics; -- use Forward_AD, Forward_AD.Hamiltonian, Ada.Text_IO, Numerics; procedure AD_Test is A : AD_Type := Var (1.3, 1, 3); -- Q : Real_Array := (1.0, 2.0, 3.0); -- V : Real_Array := Q; -- function Hamiltonian (Q : in out Real_Array) return Real is -- begin -- return 0.0; -- end Hamiltonian; P : Sparse_Matrix := Zero (1); begin -- A := Var (30.0, 1, 2); -- -- B := A * A; -- Var (3.0, 2, 2); -- -- Put_Line ("------ A ----------------------"); -- Print (A); -- -- Put_Line ("------ B ----------------------"); -- -- Print (B); -- Put_Line ("------ A * B ----------------------"); -- A := Func (Q, V, 0.0); -- Print (A); null; end AD_Test;
29,949
ada
2
reznikmm/webdriver
source/webdriver-elements.adb
-- Copyright (c) 2017 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body WebDriver.Elements is --------------- -- Send_Keys -- --------------- procedure Send_Keys (Self : access Element'Class; Text : League.Strings.Universal_String) is List : League.String_Vectors.Universal_String_Vector; begin List.Append (Text); Self.Send_Keys (List); end Send_Keys; end WebDriver.Elements;
29,950
ada
3
daveshields/AdaEd
bugs/bug04.ada
generic package gene is end gene; with text_io; package body gene is -- Different error message with/without line below commented out --package flt_io is new text_io.float_io(float); procedure test is begin text_io.new_line; end; end gene; with gene; procedure bug1 is package my_pkg is new gene; begin null; end bug1;
29,951
ada
1
io7m/coreland-opengl-ada
opengl.ads
<gh_stars>1-10 package OpenGL is pragma Pure (OpenGL); end OpenGL;
29,952
ada
5
jhumphry/SPARK_SipHash
src/general-provable/siphash-general_spark.ads
-- SipHash.General_SPARK -- Implementing SipHash over a general private type -- Copyright (c) 2015, <NAME> - see LICENSE file for details with Integer_Storage_IO; -- This generic function will calculate SipHash for any private type of definite -- size generic type T is private; type Hash_Type is mod <>; Buffer_Size : System.Storage_Elements.Storage_Count; with procedure Write(Buffer : out System.Storage_Elements.Storage_Array; Item : in T); function SipHash.General_SPARK (m : T) return Hash_Type with Global => (Input => (Initial_Hash_State, Integer_Storage_IO.Heap)); -- gnatprove insists on a Global referencing a Integer_Storage_IO.Heap -- abstract state, even though this is supposed to be generic and not tied -- to Integer_Storage_IO.
29,953
ada
1
ForYouEyesOnly/Space-Convoy
Sources/Globe_3d/unzip/unzip-decompress-huffman.ads
<filename>Sources/Globe_3d/unzip/unzip-decompress-huffman.ads -- UnZip.Decompress.Huffman --------------------------- -- Huffman tree generation and deletion. -- Originally from info - zip's unzip, data structure rewritten by <NAME> private package UnZip.Decompress.Huffman is type HufT_table; type p_HufT_table is access HufT_table; type HufT is record extra_bits : Natural; bits : Natural; n : Natural; next_table : p_HufT_table; end record; invalid : constant := 99; -- invalid value for extra bits type HufT_table is array (Integer range <>) of aliased HufT; type p_HufT is access all HufT; -- Linked list just for destroying Huffman tables type Table_list; type p_Table_list is access Table_list; type Table_list is record table : p_HufT_table; next : p_Table_list; end record; type Length_array is array (Integer range <>) of Natural; empty : constant Length_array (1 .. 0) := (others => 0); -- Free huffman tables starting with table where t points to procedure HufT_free (tl : in out p_Table_list); -- Build huffman table from code lengths given by array b.all procedure HufT_build (b : Length_array; s : Integer; d, e : Length_array; tl : out p_Table_list; m : in out Integer; huft_incomplete : out Boolean); -- Possible exceptions occuring in huft_build huft_error, -- bad tree constructed huft_out_of_memory : exception; -- not enough memory end UnZip.Decompress.Huffman;
29,954
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c34011b.ada
-- C34011B.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT A DERIVED TYPE DECLARATION IS NOT CONSIDERED EXACTLY -- EQUIVALENT TO AN ANONYMOUS DECLARATION OF THE DERIVED TYPE -- FOLLOWED BY A SUBTYPE DECLARATION OF THE DERIVED SUBTYPE. IN -- PARTICULAR, CHECK THAT CONSTRAINT_ERROR CAN BE RAISED WHEN THE -- SUBTYPE INDICATION OF THE DERIVED TYPE DECLARATION IS ELABORATED -- (EVEN THOUGH THE CONSTRAINT WOULD SATISFY THE DERIVED (BASE) -- TYPE). -- HISTORY: -- JRK 09/04/87 CREATED ORIGINAL TEST. -- EDS 07/29/98 AVOID OPTIMIZATION WITH REPORT; USE REPORT; PROCEDURE C34011B IS SUBTYPE BOOL IS BOOLEAN RANGE FALSE .. FALSE; SUBTYPE FLT IS FLOAT RANGE -10.0 .. 10.0; SUBTYPE DUR IS DURATION RANGE 0.0 .. 10.0; SUBTYPE INT IS INTEGER RANGE 0 .. 10; TYPE ARR IS ARRAY (INT RANGE <>) OF INTEGER; TYPE REC (D : INT := 0) IS RECORD I : INTEGER; END RECORD; PACKAGE PT IS TYPE PRIV (D : POSITIVE := 1) IS PRIVATE; PRIVATE TYPE PRIV (D : POSITIVE := 1) IS RECORD I : INTEGER; END RECORD; END PT; USE PT; TYPE ACC_ARR IS ACCESS ARR; TYPE ACC_REC IS ACCESS REC; BEGIN TEST ("C34011B", "CHECK THAT CONSTRAINT_ERROR CAN BE RAISED " & "WHEN THE SUBTYPE INDICATION OF A DERIVED TYPE " & "DECLARATION IS ELABORATED"); BEGIN DECLARE TYPE T IS NEW BOOL RANGE FALSE .. BOOL(IDENT_BOOL(TRUE)); BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T := T(IDENT_BOOL(TRUE)); BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR" & " AT PROPER PLACE - BOOL " & T'IMAGE(T1) ); --USE T1); END; FAILED ("EXCEPTION NOT RAISED - BOOL"); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - BOOL"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - BOOL"); END; BEGIN DECLARE TYPE T IS NEW POSITIVE RANGE IDENT_INT (0) .. 10; BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T := T(IDENT_INT(1)); BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR - POSITIVE " & T'IMAGE(T1)); --USE T1 END; FAILED ("EXCEPTION NOT RAISED - POSITIVE" ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - POSITIVE"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - POSITIVE"); END; BEGIN DECLARE TYPE T IS NEW FLT RANGE 0.0 .. FLT(IDENT_INT(20)); BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T := T(IDENT_INT(0)); BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR" & " AT PROPER PLACE " & T'IMAGE(T1) ); --USE T1 EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR" & " AT PROPER PLACE "); END; FAILED ("EXCEPTION NOT RAISED - FLT" ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - FLT"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - FLT"); END; BEGIN DECLARE TYPE T IS NEW DUR RANGE DUR(IDENT_INT(-1)) .. 5.0; BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T := T(IDENT_INT(2)); BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR" & " AT PROPER PLACE " & T'IMAGE(T1) ); -- USE T1 EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); END; FAILED ("EXCEPTION NOT RAISED - DUR " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - DUR"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - DUR"); END; BEGIN DECLARE TYPE T IS NEW ARR (IDENT_INT (-1) .. 10); BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T := (OTHERS => IDENT_INT(3)); BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR " & "AT PROPER PLACE " & INTEGER'IMAGE(T1(1)) ); --USE T1 EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); END; FAILED ("EXCEPTION NOT RAISED - ARR " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - ARR"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - ARR"); END; BEGIN DECLARE TYPE T IS NEW REC (IDENT_INT (11)); BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T; BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR " & "AT PROPER PLACE " & INTEGER'IMAGE(T1.D) ); --USE T1 END; FAILED ("EXCEPTION NOT RAISED - REC " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - REC"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - REC"); END; BEGIN DECLARE TYPE T IS NEW PRIV (IDENT_INT (0)); --RAISES C_E BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T; BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR " & "AT PROPER PLACE " & INTEGER'IMAGE(T1.D) ); --USE T1 END; FAILED ("EXCEPTION NOT RAISED - PRIV " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - PRIV"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - PRIV"); END; BEGIN DECLARE TYPE T IS NEW ACC_ARR (0 .. IDENT_INT (11)); --RAISES C_E BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T; BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR " & "AT PROPER PLACE " & INTEGER'IMAGE(T1(1)) ); --USE T1 END; FAILED ("EXCEPTION NOT RAISED - ACC_ARR " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - ACC_ARR"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - ACC_ARR"); END; BEGIN DECLARE TYPE T IS NEW ACC_REC (IDENT_INT (-1)); --RAISES C_E BEGIN DECLARE -- DEFINE AN OBJECT OF TYPE T AND USE IT TO AVOID OPTIMIZATION T1 : T; BEGIN FAILED ("DID NOT RAISE CONSTRAINT_ERROR AT PROPER PLACE"); EXCEPTION WHEN OTHERS => FAILED ("DID NOT RAISE CONSTRAINT_ERROR " & "AT PROPER PLACE " & INTEGER'IMAGE(T1.D) ); --USE T1 END; FAILED ("EXCEPTION NOT RAISED - ACC_REC " ); EXCEPTION WHEN OTHERS => FAILED ("WRONG HANDLER ENTERED - ACC_REC"); END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - ACC_REC"); END; RESULT; END C34011B;
29,955
ada
12
TUM-EI-RCS/StratoX
software/hal/boards/stm32_common/sdram/stm32-sdram.ads
<gh_stars>10-100 with System; package STM32.SDRAM is procedure Initialize; function Base_Address return System.Address; function Reserve (Amount : Word; Align : Word := Standard'Maximum_Alignment) return System.Address; end STM32.SDRAM;
29,956
ada
0
mstewartgallus/linted
src/linted-drawer/src/linted-drawer.adb
<reponame>mstewartgallus/linted -- Copyright 2016,2017 <NAME> -- -- 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.Command_Line; with Ada.Unchecked_Conversion; with Interfaces.C; with Interfaces.C.Strings; with XCB; with XCB.XProto; with Libc.Stdint; with Linted.Env; with Linted.Errors; with Linted.GPU; with Linted.KOs; with Linted.Logs; with Linted.Poller; with Linted.Triggers; with Linted.Update_Reader; with Linted.Update; with Linted.Windows; with Linted.Window_Notifier; package body Linted.Drawer with Spark_Mode => Off is package Command_Line renames Ada.Command_Line; package C renames Interfaces.C; package C_Strings renames Interfaces.C.Strings; use type C.size_t; use type Interfaces.Unsigned_32; use type Errors.Error; use type XCB.xcb_connection_t_access; use type XCB.xcb_generic_error_t_access; use type C.unsigned_char; use type C.C_float; task Main_Task; package My_Trigger is new Triggers.Handle; Window_Opts : aliased array (1 .. 2) of aliased Libc.Stdint.uint32_t := (XCB.XProto.XCB_EVENT_MASK_STRUCTURE_NOTIFY, 0); function Read_Window (Object : KOs.KO) return Windows.Window; function XCB_Conn_Error (Connection : XCB.xcb_connection_t_access) return Errors.Error; procedure Get_New_Window (Window_KO : KOs.KO; Connection : XCB.xcb_connection_t_access; Context : GPU.Context_Access; Window : out Windows.Window); task body Main_Task is Err : Errors.Error; Window_KO : KOs.KO; Window_Notifier_KO : KOs.KO; Updater_KO : KOs.KO; Connection : XCB.xcb_connection_t_access; Context : GPU.Context_Access; Window : Windows.Window; Poll_Future : Poller.Future; Poll_Future_Live : Boolean := False; Read_Future : Update_Reader.Future; Read_Future_Live : Boolean := False; Window_Future : Window_Notifier.Future; Window_Future_Live : Boolean := False; begin if Command_Line.Argument_Count < 3 then raise Constraint_Error with "At least three arguments"; end if; declare Maybe_Window_KO : constant KOs.KO_Results.Result := KOs.Open (Command_Line.Argument (1), KOs.Read_Write); begin if Maybe_Window_KO.Erroneous then raise Constraint_Error with "Erroneous window path"; end if; Window_KO := Maybe_Window_KO.Data; end; declare Maybe_Window_Notifier_KO : constant KOs.KO_Results.Result := KOs.Open (Command_Line.Argument (2), KOs.Read_Write); begin if Maybe_Window_Notifier_KO.Erroneous then raise Constraint_Error with "Erroneous window notifier path"; end if; Window_Notifier_KO := Maybe_Window_Notifier_KO.Data; end; declare Maybe_Updater_KO : constant KOs.KO_Results.Result := KOs.Open (Command_Line.Argument (3), KOs.Read_Write); begin if Maybe_Updater_KO.Erroneous then raise Constraint_Error with "Erroneous updater path"; end if; Updater_KO := Maybe_Updater_KO.Data; end; declare Display : String := Env.Get ("DISPLAY"); Display_C_Str : aliased C.char_array := C.To_C (Display); begin Logs.Log (Logs.Info, "Display = " & Display); Connection := XCB.xcb_connect (C_Strings.To_Chars_Ptr (Display_C_Str'Unchecked_Access), null); end; if null = Connection then raise Storage_Error with "Cannot create XCB connection"; end if; Err := XCB_Conn_Error (Connection); if Err /= Errors.Success then raise Program_Error with Errors.To_String (Err); end if; Err := GPU.Context_Create (Context); if Err /= Errors.Success then raise Program_Error with Errors.To_String (Err); end if; Window_Notifier.Read (Window_Notifier_KO, My_Trigger.Signal_Handle, Window_Future); Window_Future_Live := True; Poller.Poll (KOs.KO (XCB.xcb_get_file_descriptor (Connection)), (Poller.Readable => True, Poller.Writable => False), My_Trigger.Signal_Handle, Poll_Future); Poll_Future_Live := True; Update_Reader.Read (Updater_KO, My_Trigger.Signal_Handle, Read_Future); Read_Future_Live := True; Get_New_Window (Window_KO, Connection, Context, Window); Logs.Log (Logs.Info, "Window: " & Windows.Window'Image (Window)); loop Triggers.Wait (My_Trigger.Wait_Handle); if Read_Future_Live then declare Read_Event : Update_Reader.Event; Init : Boolean; begin Update_Reader.Read_Poll (Read_Future, Read_Event, Init); if Init then Read_Future_Live := False; declare GPU_Update : GPU.Update; begin GPU_Update.X_Position := C.C_float (Read_Event.Data.X_Position) * (1.0 / 4096.0); GPU_Update.Y_Position := C.C_float (Read_Event.Data.Y_Position) * (1.0 / 4096.0); GPU_Update.Z_Position := C.C_float (Read_Event.Data.Z_Position) * (1.0 / 4096.0); GPU_Update.MX_Position := C.C_float (Read_Event.Data.MX_Position) * (1.0 / 4096.0); GPU_Update.MY_Position := C.C_float (Read_Event.Data.MY_Position) * (1.0 / 4096.0); GPU_Update.MZ_Position := C.C_float (Read_Event.Data.MZ_Position) * (1.0 / 4096.0); GPU_Update.Z_Rotation := C.C_float (Read_Event.Data.Z_Rotation) * (6.28318530717958647692528 / (C.C_float (Update.Nat'Last) + 1.0)); GPU_Update.X_Rotation := C.C_float (Read_Event.Data.X_Rotation) * (6.28318530717958647692528 / (C.C_float (Update.Nat'Last) + 1.0)); GPU.Update_State (Context, GPU_Update); end; Update_Reader.Read (Updater_KO, My_Trigger.Signal_Handle, Read_Future); Read_Future_Live := True; end if; end; end if; if Window_Future_Live then declare Ck : XCB.xcb_void_cookie_t; X : C.int; No_Opts : aliased array (1 .. 2) of aliased Libc.Stdint.uint32_t := (0, 0); Init : Boolean; begin Window_Notifier.Read_Poll (Window_Future, Init); if Init then Window_Future_Live := False; Ck := XCB.XProto.xcb_change_window_attributes (Connection, XCB.XProto.xcb_window_t (Window), Libc.Stdint.uint32_t (XCB.XProto.XCB_CW_EVENT_MASK), No_Opts (1)'Unchecked_Access); Err := XCB_Conn_Error (Connection); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; X := XCB.xcb_flush (Connection); Get_New_Window (Window_KO, Connection, Context, Window); Logs.Log (Logs.Info, "Window: " & Windows.Window'Image (Window)); X := XCB.xcb_flush (Connection); Window_Notifier.Read (Window_Notifier_KO, My_Trigger.Signal_Handle, Window_Future); Window_Future_Live := True; end if; end; end if; if Poll_Future_Live then declare Poll_Event : Poller.Event; Window_Destroyed : Boolean := False; My_Event : access XCB.xcb_generic_event_t; Init : Boolean; procedure Free (Event : access XCB.xcb_generic_event_t); pragma Import (C, Free, "free"); begin Poller.Poll_Poll (Poll_Future, Poll_Event, Init); if Init then Poll_Future_Live := False; loop My_Event := XCB.xcb_poll_for_event (Connection); if null = My_Event then exit; end if; case My_Event.response_type and not 16#80# is when XCB.XProto.XCB_CONFIGURE_NOTIFY => declare type A is access all XCB.xcb_generic_event_t; type B is access all XCB.XProto .xcb_configure_notify_event_t; function Convert is new Ada.Unchecked_Conversion (A, B); Configure : B := Convert (My_Event); begin GPU.Resize (Context, C.unsigned (Configure.width), C.unsigned (Configure.height)); end; when XCB.XProto.XCB_UNMAP_NOTIFY => GPU.Hide (Context); when XCB.XProto.XCB_MAP_NOTIFY => GPU.Show (Context); when XCB.XProto.XCB_DESTROY_NOTIFY => Window_Destroyed := True; when others => -- Unknown event type, ignore it null; end case; Free (My_Event); end loop; if Window_Destroyed then Err := GPU.Remove_Window (Context); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; end if; declare X : C.int; begin X := XCB.xcb_flush (Connection); end; Poller.Poll (KOs.KO (XCB.xcb_get_file_descriptor (Connection)), (Poller.Readable => True, Poller.Writable => False), My_Trigger.Signal_Handle, Poll_Future); Poll_Future_Live := True; end if; end; end if; end loop; end Main_Task; function Read_Window (Object : KOs.KO) return Windows.Window is Bytes : C.size_t; Err : Errors.Error; Data : Windows.Storage; W : Windows.Window; begin declare Buf : aliased Windows.Storage; begin Err := KOs.Pread (Object, Buf (1)'Address, Windows.Storage_Size, 0, Bytes); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; Data := Buf; end; pragma Assert (Bytes = 4); Windows.From_Storage (Data, W); return W; end Read_Window; function XCB_Conn_Error (Connection : XCB.xcb_connection_t_access) return Errors.Error is (case XCB.xcb_connection_has_error (Connection) is when 0 => Errors.Success, when XCB.XCB_CONN_ERROR => Errors.Protocol, when XCB.XCB_CONN_CLOSED_EXT_NOTSUPPORTED => Errors.Unimplemented, when XCB.XCB_CONN_CLOSED_MEM_INSUFFICIENT => Errors.Out_Of_Memory, when XCB.XCB_CONN_CLOSED_REQ_LEN_EXCEED => Errors.Invalid_Parameter, when XCB.XCB_CONN_CLOSED_PARSE_ERR => Errors.Invalid_Parameter, when others => raise Constraint_Error); procedure Get_New_Window (Window_KO : KOs.KO; Connection : XCB.xcb_connection_t_access; Context : GPU.Context_Access; Window : out Windows.Window) is New_Window : Windows.Window; Geom_CK : XCB.XProto.xcb_get_geometry_cookie_t; Width : C.unsigned; Height : C.unsigned; X : C.int; Ck : XCB.xcb_void_cookie_t; Err : Errors.Error; begin New_Window := Read_Window (Window_KO); Ck := XCB.XProto.xcb_change_window_attributes_checked (Connection, XCB.XProto.xcb_window_t (New_Window), Libc.Stdint.uint32_t (XCB.XProto.XCB_CW_EVENT_MASK), Window_Opts (1)'Unchecked_Access); Err := XCB_Conn_Error (Connection); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; declare Error : XCB.xcb_generic_error_t_access; Reply : access XCB.XProto.xcb_get_geometry_reply_t; procedure Free (Event : access XCB.XProto.xcb_get_geometry_reply_t); pragma Import (C, Free, "free"); begin Error := XCB.xcb_request_check (Connection, Ck); Err := XCB_Conn_Error (Connection); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; if Error /= null then raise Program_Error; end if; end; Geom_CK := XCB.XProto.xcb_get_geometry (Connection, XCB.XProto.xcb_window_t (New_Window)); Err := XCB_Conn_Error (Connection); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; declare Error : XCB.xcb_generic_error_t_access; Reply : access XCB.XProto.xcb_get_geometry_reply_t; procedure Free (Event : access XCB.XProto.xcb_get_geometry_reply_t); pragma Import (C, Free, "free"); begin Reply := XCB.XProto.xcb_get_geometry_reply (Connection, Geom_CK, Error); Err := XCB_Conn_Error (Connection); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; if Error /= null then raise Program_Error; end if; Width := C.unsigned (Reply.width); Height := C.unsigned (Reply.height); Free (Reply); end; X := XCB.xcb_flush (Connection); Err := GPU.Remove_Window (Context); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; Err := GPU.Set_X11_Window (Context, GPU.X11_Window (New_Window)); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; GPU.Resize (Context, Width, Height); if Err /= 0 then raise Program_Error with Errors.To_String (Err); end if; Window := New_Window; end Get_New_Window; end Linted.Drawer;
29,957
ada
0
thierr26/ada-apsepp
src/apsepp-abstract_test_case.ads
-- Copyright (C) 2019 <NAME> <<EMAIL>> -- MIT license. Please refer to the LICENSE file. with Apsepp.Test_Node_Class.Case_Stub; use Apsepp.Test_Node_Class.Case_Stub; use Apsepp.Test_Node_Class; package Apsepp.Abstract_Test_Case is type Test_Routine_Array is array (Test_Routine_Index range <>) of Test_Routine; type Test_Case is abstract limited new Test_Case_Stub with private; not overriding function Routine_Array (Obj : Test_Case) return Test_Routine_Array is abstract; overriding function Routine_Count (Obj : Test_Case) return Test_Routine_Count is (Test_Case'Class (Obj).Routine_Array'Length); overriding function Routine (Obj : Test_Case; K : Test_Routine_Index) return Test_Routine is (Test_Case'Class (Obj).Routine_Array (K)); procedure Run_Body (Obj : Test_Node_Interfa'Class; Outcome : out Test_Outcome; Kind : Run_Kind; Cond : not null access function return Boolean) renames Test_Node_Class.Case_Stub.Run_Body; private type Test_Case is abstract limited new Test_Case_Stub with null record; end Apsepp.Abstract_Test_Case;
29,958
ada
3
stcarrez/ada-css
src/css-core.adb
<gh_stars>1-10 ----------------------------------------------------------------------- -- css-core -- Core CSS API definition -- Copyright (C) 2017 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; package body CSS.Core is -- ------------------------------ -- Get a printable representation of the source file name and line number. -- ------------------------------ function To_String (Loc : in Location) return String is begin return Util.Log.Locations.To_String (Loc); end To_String; -- ------------------------------ -- Returns the CSS type ("text/css"). -- ------------------------------ function Get_Type (Sheet : in Stylesheet) return String is pragma Unreferenced (Sheet); begin return "text/css"; end Get_Type; -- ------------------------------ -- Get the parent CSS stylesheet if there is one or return null. -- ------------------------------ function Get_Parent (Sheet : in Stylesheet) return Stylesheet_Access is begin return Sheet.Parent; end Get_Parent; -- ------------------------------ -- Get the href attribute (stylesheet location). -- ------------------------------ function Get_Href (Sheet : in Stylesheet) return String is begin return Ada.Strings.Unbounded.To_String (Sheet.Href); end Get_Href; -- ------------------------------ -- Get the source file information. -- ------------------------------ function Get_File_Info (Sheet : in Stylesheet) return Util.Log.Locations.File_Info_Access is begin return Sheet.File; end Get_File_Info; -- ------------------------------ -- Set the href attribute representing the stylesheet location. -- ------------------------------ procedure Set_Href (Sheet : in out Stylesheet; Href : in String) is begin Sheet.File := Util.Log.Locations.Create_File_Info (Href, Href'First); Ada.Strings.Unbounded.Set_Unbounded_String (Sheet.Href, Href); end Set_Href; -- ------------------------------ -- Create a location record to represent a CSS source position. -- ------------------------------ function Create_Location (Sheet : in Stylesheet_Access; Line : in Natural; Column : in Natural) return Location is begin return Util.Log.Locations.Create_Line_Info (Sheet.File, Line, Column); end Create_Location; function Create_Property_Name (Sheet : in Stylesheet; Name : in String) return CSSProperty_Name is Pos : constant String_Map.Cursor := Sheet.Strings.Find (Name'Unrestricted_Access); Res : CSSProperty_Name; begin if String_Map.Has_Element (Pos) then return String_Map.Element (Pos); end if; Res := new String '(Name); Sheet.Strings.Insert (Res.all'Access, Res); return Res; end Create_Property_Name; -- ------------------------------ -- Get the parent rule. Returns null when there is no parent. -- ------------------------------ function Get_Parent (Rule : in CSSRule) return CSSRule_Access is begin return Rule.Parent; end Get_Parent; -- ------------------------------ -- Get the stylesheet. -- ------------------------------ function Get_Stylesheet (Rule : in CSSRule) return Stylesheet_Access is begin return Rule.Sheet; end Get_Stylesheet; -- ------------------------------ -- Get the location of the rule. -- ------------------------------ function Get_Location (Rule : in CSSRule) return Location is begin return Rule.Loc; end Get_Location; overriding procedure Finalize (Sheet : in out Stylesheet) is procedure Free is new Ada.Unchecked_Deallocation (String, CSSProperty_Name); procedure Free is new Ada.Unchecked_Deallocation (String_Map.Map, String_Map_Access); begin if Sheet.Strings /= null then while not Sheet.Strings.Is_Empty loop declare Pos : String_Map.Cursor := Sheet.Strings.First; S : CSSProperty_Name := String_Map.Element (Pos); begin Sheet.Strings.Delete (Pos); Free (S); end; end loop; Free (Sheet.Strings); end if; end Finalize; -- ------------------------------ -- Set the source code location. -- ------------------------------ procedure Set_Location (Rule : in out CSSRule'Class; Line : in Natural; Column : in Natural; Sheet : in Stylesheet_Access) is begin Rule.Loc := Util.Log.Locations.Create_Line_Info (Sheet.File, Line, Column); end Set_Location; end CSS.Core;
29,959
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
stm32l0/stm32gd-usart-irq.ads
with Ada.Interrupts; with STM32_SVD.USART; with STM32_SVD; use STM32_SVD; generic with package USART is new STM32GD.USART.Peripheral (<>); IRQ : Ada.Interrupts.Interrupt_ID; package STM32GD.USART.IRQ is procedure Init; protected IRQ_Handler is entry Wait; private procedure Handler; pragma Attach_Handler (Handler, IRQ); Data_Available : Boolean := False; end IRQ_Handler; end STM32GD.USART.IRQ;
29,960
ada
0
My-Colaborations/ada-util
regtests/util-streams-buffered-tests.adb
----------------------------------------------------------------------- -- streams.buffered.tests -- Unit tests for buffered streams -- Copyright (C) 2010, 2011, 2017, 2018, 2019, 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Wide_Wide_Unbounded; with Ada.Streams.Stream_IO; with Util.Test_Caller; with Util.Streams.Texts; with Util.Streams.Files; package body Util.Streams.Buffered.Tests is pragma Wide_Character_Encoding (UTF8); use Util.Tests; use Util.Streams.Texts; package Caller is new Util.Test_Caller (Test, "Streams.Buffered"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Write, Read", Test_Read_Write'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Write, Flush (String)", Test_Write'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Write, Flush (Stream_Array)", Test_Write_Stream'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Read (UTF-8)", Test_Read_UTF_8'Access); end Add_Tests; -- ------------------------------ -- Write on a buffered stream and read what was written. -- ------------------------------ procedure Test_Read_Write (T : in out Test) is Stream : Print_Stream; Buf : Ada.Strings.Unbounded.Unbounded_String; begin Stream.Initialize (Size => 4); Stream.Write ("abcd"); Assert_Equals (T, 4, Integer (Stream.Get_Size), "Invalid size for stream"); Stream.Flush (Buf); Assert_Equals (T, 4, Ada.Strings.Unbounded.Length (Buf), "Invalid size for string"); Assert_Equals (T, "abcd", Ada.Strings.Unbounded.To_String (Buf), "Invalid stream content"); Assert_Equals (T, 0, Integer (Stream.Get_Size), "Invalid size for stream after Flush"); end Test_Read_Write; -- ------------------------------ -- Write on a buffer and force regular flush on a larger buffer -- ------------------------------ procedure Test_Write (T : in out Test) is Big_Stream : aliased Output_Buffer_Stream; Stream : Output_Buffer_Stream; Size : Stream_Element_Offset := 0; Count : constant Stream_Element_Offset := 1000; Max_Size : constant Stream_Element_Offset := (Count * (Count + 1)) / 2; begin Big_Stream.Initialize (Size => Natural (Max_Size)); Stream.Initialize (Output => Big_Stream'Access, Size => 13); for I in 1 .. Count loop declare S : Stream_Element_Array (1 .. I); begin for J in S'Range loop S (J) := Stream_Element (J mod 255); end loop; Stream.Write (S); Stream.Flush; Size := Size + I; Assert_Equals (T, 1, Integer (Stream.Write_Pos), "Stream must be flushed"); -- Verify that 'Big_Stream' holds the expected number of bytes. Assert_Equals (T, Integer (Size), Integer (Big_Stream.Write_Pos) - 1, "Target stream has an invalid write position at " & Stream_Element_Offset'Image (I)); end; end loop; end Test_Write; -- ------------------------------ -- Write on a buffer and force regular flush on a larger buffer -- ------------------------------ procedure Test_Write_Stream (T : in out Test) is Big_Stream : aliased Output_Buffer_Stream; Stream : Output_Buffer_Stream; Size : Stream_Element_Offset := 0; Count : constant Stream_Element_Offset := 200; Max_Size : constant Stream_Element_Offset := 5728500; begin Big_Stream.Initialize (Size => Natural (Max_Size)); for Buf_Size in 1 .. 19 loop Stream.Initialize (Output => Big_Stream'Access, Size => Buf_Size); for I in 1 .. Count loop for Repeat in 1 .. 5 loop declare S : Stream_Element_Array (1 .. I); begin for J in S'Range loop S (J) := Stream_Element'Val (J mod 255); end loop; for J in 1 .. Repeat loop Stream.Write (S); end loop; Stream.Flush; Size := Size + (I) * Stream_Element_Offset (Repeat); Assert_Equals (T, 1, Integer (Stream.Write_Pos), "Stream must be flushed"); -- Verify that 'Big_Stream' holds the expected number of bytes. Assert_Equals (T, Integer (Size), Integer (Big_Stream.Write_Pos) - 1, "Target stream has an invalid write position at " & Stream_Element_Offset'Image (I) & " with buffer " & Natural'Image (Buf_Size) & " repeat " & Natural'Image (Repeat)); end; end loop; end loop; end loop; Assert_Equals (T, Integer (Max_Size), Integer (Big_Stream.Get_Size), "Invalid final size"); end Test_Write_Stream; -- ------------------------------ -- Test reading UTF-8 file. -- ------------------------------ procedure Test_Read_UTF_8 (T : in out Test) is File : aliased Util.Streams.Files.File_Stream; Stream : Util.Streams.Buffered.Input_Buffer_Stream; Path : constant String := Util.Tests.Get_Path ("regtests/files/utf-8.txt"); begin Stream.Initialize (Input => File'Access, Size => 1024); File.Open (Ada.Streams.Stream_IO.In_File, Path); declare S : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; Expect : constant Wide_Wide_String := "àéúíòࠀ€ಜ࠴𝄞" & Wide_Wide_Character'Val (16#0A#); begin Stream.Read (S); declare Result : constant Wide_Wide_String := Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String (S); begin if Expect /= Result then T.Fail ("Invalid UTF-8 string"); end if; end; end; end Test_Read_UTF_8; end Util.Streams.Buffered.Tests;
29,961
ada
1
LaudateCorpus1/RosettaCodeData
Task/Substring/Ada/substring-1.ada
type String is array (Positive range <>) of Character;
29,962
ada
33
ytomino/drake
source/tasking/a-csquin.ads
pragma License (Unrestricted); -- Ada 2012 generic type Element_Type is private; package Ada.Containers.Synchronized_Queue_Interfaces is pragma Pure; type Queue is synchronized interface; procedure Enqueue ( Container : in out Queue; New_Item : Element_Type) is abstract with Synchronization => By_Entry; procedure Dequeue ( Container : in out Queue; Element : out Element_Type) is abstract with Synchronization => By_Entry; function Current_Use (Container : Queue) return Count_Type is abstract; function Peak_Use (Container : Queue) return Count_Type is abstract; end Ada.Containers.Synchronized_Queue_Interfaces;
29,963
ada
17
jrmarino/ravensource
bucket_34/gnatstudio/patches/patch-kernel_src_gtkada-search__entry.adb
<filename>bucket_34/gnatstudio/patches/patch-kernel_src_gtkada-search__entry.adb --- kernel/src/gtkada-search_entry.adb.orig 2021-06-18 05:08:58 UTC +++ kernel/src/gtkada-search_entry.adb @@ -21,13 +21,13 @@ with Gtk.Style_Context; use Gtk.Style_C with Gtk.Widget; use Gtk.Widget; with Gtkada.Handlers; use Gtkada.Handlers; with GPS.Intl; use GPS.Intl; +with Gtk.Main; package body Gtkada.Search_Entry is procedure On_Clear_Entry - (Self : access Gtk_Entry_Record'Class; - Pos : Gtk_Entry_Icon_Position; - Event : Gdk_Event); + (Self : access Gtk_Entry_Record'Class; + Pos : Gtk_Entry_Icon_Position); -- Called when the user presses the "clear" icon procedure On_Changed (Self : access Gtk_Widget_Record'Class); @@ -39,14 +39,14 @@ package body Gtkada.Search_Entry is function Get_Icon_Position (Self : access Gtkada_Search_Entry_Record'Class; - Event : Gdk_Event_Button) return Gtk_Entry_Icon_Position + Event : Gdk_Event) return Gtk_Entry_Icon_Position is Alloc : Gtk_Allocation; Rect : Gdk_Rectangle; X, Y : Gint; begin Self.Get_Allocation (Alloc); - Get_Position (Event.Window, X, Y); + Get_Position (Get_Window (Event), X, Y); Self.Get_Icon_Area (Gtk_Entry_Icon_Primary, Rect); @@ -62,14 +62,13 @@ package body Gtkada.Search_Entry is -------------------- procedure On_Clear_Entry - (Self : access Gtk_Entry_Record'Class; - Pos : Gtk_Entry_Icon_Position; - Event : Gdk_Event) + (Self : access Gtk_Entry_Record'Class; + Pos : Gtk_Entry_Icon_Position) is pragma Unreferenced (Pos); -- unreliable with gtk+ 3.8 begin - if Gtkada_Search_Entry (Self).Get_Icon_Position (Event.Button) = - Gtk_Entry_Icon_Secondary + if Gtkada_Search_Entry (Self).Get_Icon_Position ( + Gtk.Main.Get_Current_Event) = Gtk_Entry_Icon_Secondary then Self.Set_Text ("");
29,964
ada
32
robdaemon/AdaYaml
src/interface/yaml-dom-vectors.ads
<reponame>robdaemon/AdaYaml -- part of AdaYaml, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Containers.Indefinite_Vectors; package Yaml.Dom.Vectors is new Ada.Containers.Indefinite_Vectors (Positive, Document_Reference);
29,965
ada
1
Jellix/open_weather_map_api
src/open_weather_map-city_ids.ads
<filename>src/open_weather_map-city_ids.ads -------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>) -- -- 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); -------------------------------------------------------------------------------- --% @summary --% Open_Weather_Map.City_Ids -- --% @description --% Provides the Ada language version of city Ids. -- -- Please note that this list may change, the actual list can be downloaded -- from <http://bulk.openwathermap.org/sample/city.list.json.gz>). -------------------------------------------------------------------------------- package Open_Weather_Map.City_Ids is package Mexico is -- Mexico/Guerrero (B. smithii) Acapulco_de_Juarez : constant City_Id := 3533462; Chacalapa_Acapulco : constant City_Id := 3531263; Coyuca_de_Benitez : constant City_Id := 4012608; Las_Guacamayas : constant City_Id := 4026075; Tierra_Colorada : constant City_Id := 3515643; Xaltianguis : constant City_Id := 3514583; end Mexico; package India is -- India (P. Metallica) Giddalur : constant City_Id := 1271213; Nandyal : constant City_Id := 1261927; end India; end Open_Weather_Map.City_Ids;
29,966
ada
0
JCGobbi/Nucleo-STM32G474RE
bb-runtimes/src/a-intnam__zynqmp.ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . I N T E R R U P T S . N A M E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2012-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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Xilinx Ultrascale+ MPSoC version of this package pragma Restrictions (No_Elaboration_Code); package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; -- Software Generated Interrupts (SGI) SGI_0 : constant Interrupt_ID := 0; -- Reserved by the runtime SGI_1 : constant Interrupt_ID := 1; SGI_2 : constant Interrupt_ID := 2; SGI_3 : constant Interrupt_ID := 3; SGI_4 : constant Interrupt_ID := 4; SGI_5 : constant Interrupt_ID := 5; SGI_6 : constant Interrupt_ID := 6; SGI_7 : constant Interrupt_ID := 7; SGI_8 : constant Interrupt_ID := 8; SGI_9 : constant Interrupt_ID := 9; SGI_10 : constant Interrupt_ID := 10; SGI_11 : constant Interrupt_ID := 11; SGI_12 : constant Interrupt_ID := 12; SGI_13 : constant Interrupt_ID := 13; SGI_14 : constant Interrupt_ID := 14; SGI_15 : constant Interrupt_ID := 15; -- Private Peripheral Interrupts (PPI) Virtual_Maintenance_Interrupt : constant Interrupt_ID := 25; Hypervisor_Timer_Interrupt : constant Interrupt_ID := 26; Virtual_Timer_Interrupt : constant Interrupt_ID := 27; Legacy_FIQ_Interrupt : constant Interrupt_ID := 28; Secure_Physical_Timer_Interrupt : constant Interrupt_ID := 29; Non_Secure_Physical_Time_Interrupt : constant Interrupt_ID := 30; Legacy_IRQ_Interrupt : constant Interrupt_ID := 31; -- System Interrupts RPU0_AMP_Interrupt : constant Interrupt_ID := 40; RPU1_AMP_Interrupt : constant Interrupt_ID := 41; OCM_Interrupt : constant Interrupt_ID := 42; LPD_APB_Interrupt : constant Interrupt_ID := 43; RPU0_ECC_Interrupt : constant Interrupt_ID := 44; RPU1_ECC_Interrupt : constant Interrupt_ID := 45; NAND_Interrupt : constant Interrupt_ID := 46; QSPI_Interrupt : constant Interrupt_ID := 47; GPIO_Interrupt : constant Interrupt_ID := 48; I2C0_Interrupt : constant Interrupt_ID := 49; I2C1_Interrupt : constant Interrupt_ID := 50; SPI0_Interrupt : constant Interrupt_ID := 51; SPI1_Interrupt : constant Interrupt_ID := 52; UART0_Interrupt : constant Interrupt_ID := 53; UART1_Interrupt : constant Interrupt_ID := 54; CAN0_Interrupt : constant Interrupt_ID := 55; CAN1_Interrupt : constant Interrupt_ID := 56; LPD_APM_Interrupt : constant Interrupt_ID := 57; RTC_Alarm_Interrupt : constant Interrupt_ID := 58; RTC_Seconds_Interrupt : constant Interrupt_ID := 59; ClkMon_Interrupt : constant Interrupt_ID := 60; IPI_Ch7_Interrupt : constant Interrupt_ID := 61; IPI_Ch8_Interrupt : constant Interrupt_ID := 62; IPI_Ch9_Interrupt : constant Interrupt_ID := 63; IPI_Ch10_Interrupt : constant Interrupt_ID := 64; IPI_Ch2_Interrupt : constant Interrupt_ID := 65; IPI_Ch1_Interrupt : constant Interrupt_ID := 66; IPI_Ch0_Interrupt : constant Interrupt_ID := 67; TTC0_0_Interrupt : constant Interrupt_ID := 68; TTC0_1_Interrupt : constant Interrupt_ID := 69; TTC0_2_Interrupt : constant Interrupt_ID := 70; TTC1_0_Interrupt : constant Interrupt_ID := 71; TTC1_1_Interrupt : constant Interrupt_ID := 72; TTC1_2_Interrupt : constant Interrupt_ID := 73; TTC2_0_Interrupt : constant Interrupt_ID := 74; TTC2_1_Interrupt : constant Interrupt_ID := 75; TTC2_2_Interrupt : constant Interrupt_ID := 76; TTC3_0_Interrupt : constant Interrupt_ID := 77; TTC3_1_Interrupt : constant Interrupt_ID := 78; TTC3_2_Interrupt : constant Interrupt_ID := 79; SDIO0_Interrupt : constant Interrupt_ID := 80; SDIO1_Interrupt : constant Interrupt_ID := 81; SDIO0_Wakeup_Interrupt : constant Interrupt_ID := 82; SDIO1_Wakeup_Interrupt : constant Interrupt_ID := 83; LPD_SWDT_Interrupt : constant Interrupt_ID := 84; CSU_SWDT_Interrupt : constant Interrupt_ID := 85; LPD_ATB_Interrupt : constant Interrupt_ID := 86; AIB_Interrupt : constant Interrupt_ID := 87; SysMon_Interrupt : constant Interrupt_ID := 88; GEM0_Interrupt : constant Interrupt_ID := 89; GEM0_Wakeup_Interrupt : constant Interrupt_ID := 90; GEM1_Interrupt : constant Interrupt_ID := 91; GEM1_Wakeup_Interrupt : constant Interrupt_ID := 92; GEM2_Interrupt : constant Interrupt_ID := 93; GEM2_Wakeup_Interrupt : constant Interrupt_ID := 94; GEM3_Interrupt : constant Interrupt_ID := 95; GEM3_Wakeup_Interrupt : constant Interrupt_ID := 96; USB0_Endpoint0_Interrupt : constant Interrupt_ID := 97; USB0_Endpoint1_Interrupt : constant Interrupt_ID := 98; USB0_Endpoint2_Interrupt : constant Interrupt_ID := 99; USB0_Endpoint3_Interrupt : constant Interrupt_ID := 100; USB0_OTG_Interrupt : constant Interrupt_ID := 101; USB1_Endpoint0_Interrupt : constant Interrupt_ID := 102; USB1_Endpoint1_Interrupt : constant Interrupt_ID := 103; USB1_Endpoint2_Interrupt : constant Interrupt_ID := 104; USB1_Endpoint3_Interrupt : constant Interrupt_ID := 105; USB1_OTG_Interrupt : constant Interrupt_ID := 106; USB0_Wakeup_Interrupt : constant Interrupt_ID := 107; USB1_Wakeup_Interrupt : constant Interrupt_ID := 108; LPD_DMA_Ch0_Interrupt : constant Interrupt_ID := 109; LPD_DMA_Ch1_Interrupt : constant Interrupt_ID := 110; LPD_DMA_Ch2_Interrupt : constant Interrupt_ID := 111; LPD_DMA_Ch3_Interrupt : constant Interrupt_ID := 112; LPD_DMA_Ch4_Interrupt : constant Interrupt_ID := 113; LPD_DMA_Ch5_Interrupt : constant Interrupt_ID := 114; LPD_DMA_Ch6_Interrupt : constant Interrupt_ID := 115; LPD_DMA_Ch7_Interrupt : constant Interrupt_ID := 116; CSU_Interrupt : constant Interrupt_ID := 117; CSU_DMA_Interrupt : constant Interrupt_ID := 118; eFuse_Interrupt : constant Interrupt_ID := 119; XPPU_Interrupt : constant Interrupt_ID := 120; PL_PS_0_Interrupt : constant Interrupt_ID := 121; PL_PS_1_Interrupt : constant Interrupt_ID := 122; PL_PS_2_Interrupt : constant Interrupt_ID := 123; PL_PS_3_Interrupt : constant Interrupt_ID := 124; PL_PS_4_Interrupt : constant Interrupt_ID := 125; PL_PS_5_Interrupt : constant Interrupt_ID := 126; PL_PS_6_Interrupt : constant Interrupt_ID := 127; PL_PS_7_Interrupt : constant Interrupt_ID := 128; -- 7 reserved interrupts from 129 to 135 PL_PS_8_Interrupt : constant Interrupt_ID := 136; PL_PS_9_Interrupt : constant Interrupt_ID := 137; PL_PS_10_Interrupt : constant Interrupt_ID := 138; PL_PS_11_Interrupt : constant Interrupt_ID := 139; PL_PS_12_Interrupt : constant Interrupt_ID := 140; PL_PS_13_Interrupt : constant Interrupt_ID := 141; PL_PS_14_Interrupt : constant Interrupt_ID := 142; PL_PS_15_Interrupt : constant Interrupt_ID := 143; DDR_Interrupt : constant Interrupt_ID := 144; FPD_SWDT_Interrupt : constant Interrupt_ID := 145; PCIe_MSI0_Interrupt : constant Interrupt_ID := 146; PCIe_MSI1_Interrupt : constant Interrupt_ID := 147; PCIe_INTx_Interrupt : constant Interrupt_ID := 148; PCIe_DMA_Interrupt : constant Interrupt_ID := 149; PCIe_MSC_Interrupt : constant Interrupt_ID := 150; DisplayPort_Interrupt : constant Interrupt_ID := 151; FPD_APB_Interrupt : constant Interrupt_ID := 152; FPD_DTB_Interrupt : constant Interrupt_ID := 153; DPDMA_Interrupt : constant Interrupt_ID := 154; FPD_ATM_Interrupt : constant Interrupt_ID := 155; FPD_DMA_Ch0_Interrupt : constant Interrupt_ID := 156; FPD_DMA_Ch1_Interrupt : constant Interrupt_ID := 157; FPD_DMA_Ch2_Interrupt : constant Interrupt_ID := 158; FPD_DMA_Ch3_Interrupt : constant Interrupt_ID := 159; FPD_DMA_Ch4_Interrupt : constant Interrupt_ID := 160; FPD_DMA_Ch5_Interrupt : constant Interrupt_ID := 161; FPD_DMA_Ch6_Interrupt : constant Interrupt_ID := 162; FPD_DMA_Ch7_Interrupt : constant Interrupt_ID := 163; GPU_Interrupt : constant Interrupt_ID := 164; SATA_Interrupt : constant Interrupt_ID := 165; FPD_XMPU_Interrupt : constant Interrupt_ID := 166; APU_VCPUMNT_0_Interrupt : constant Interrupt_ID := 167; APU_VCPUMNT_1_Interrupt : constant Interrupt_ID := 168; APU_VCPUMNT_2_Interrupt : constant Interrupt_ID := 169; APU_VCPUMNT_3_Interrupt : constant Interrupt_ID := 170; CPU_CTI_0_Interrupt : constant Interrupt_ID := 171; CPU_CTI_1_Interrupt : constant Interrupt_ID := 172; CPU_CTI_2_Interrupt : constant Interrupt_ID := 173; CPU_CTI_3_Interrupt : constant Interrupt_ID := 174; PMU_Comm_0_Interrupt : constant Interrupt_ID := 175; PMU_Comm_1_Interrupt : constant Interrupt_ID := 176; PMU_Comm_2_Interrupt : constant Interrupt_ID := 177; PMU_Comm_3_Interrupt : constant Interrupt_ID := 178; APU_Comm_0_Interrupt : constant Interrupt_ID := 179; APU_Comm_1_Interrupt : constant Interrupt_ID := 180; APU_Comm_2_Interrupt : constant Interrupt_ID := 181; APU_Comm_3_Interrupt : constant Interrupt_ID := 182; L2_Cache_Interrupt : constant Interrupt_ID := 183; APU_ExtError_Interrupt : constant Interrupt_ID := 184; APU_RegError_Interrupt : constant Interrupt_ID := 185; CCI_Interrupt : constant Interrupt_ID := 186; SMMU_Interrupt : constant Interrupt_ID := 187; end Ada.Interrupts.Names;
29,967
ada
4
faelys/gela-asis
source/libgela/gela-hash-sha-b512.adb
<reponame>faelys/gela-asis ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ with Ada.Unchecked_Conversion; package body Gela.Hash.SHA.b512 is -- K Constants K : constant array (1 .. 80) of Interfaces.Unsigned_64 := (16#428A2F98D728AE22#, 16#7137449123EF65CD#, 16#B5C0FBCFEC4D3B2F#, 16#E9B5DBA58189DBBC#, 16#3956C25BF348B538#, 16#59F111F1B605D019#, 16#923F82A4AF194F9B#, 16#AB1C5ED5DA6D8118#, 16#D807AA98A3030242#, 16#12835B0145706FBE#, 16#243185BE4EE4B28C#, 16#550C7DC3D5FFB4E2#, 16#72BE5D74F27B896F#, 16#80DEB1FE3B1696B1#, 16#9BDC06A725C71235#, 16#C19BF174CF692694#, 16#E49B69C19EF14AD2#, 16#EFBE4786384F25E3#, 16#0FC19DC68B8CD5B5#, 16#240CA1CC77AC9C65#, 16#2DE92C6F592B0275#, 16#4A7484AA6EA6E483#, 16#5CB0A9DCBD41FBD4#, 16#76F988DA831153B5#, 16#983E5152EE66DFAB#, 16#A831C66D2DB43210#, 16#B00327C898FB213F#, 16#BF597FC7BEEF0EE4#, 16#C6E00BF33DA88FC2#, 16#D5A79147930AA725#, 16#06CA6351E003826F#, 16#142929670A0E6E70#, 16#27B70A8546D22FFC#, 16#2E1B21385C26C926#, 16#4D2C6DFC5AC42AED#, 16#53380D139D95B3DF#, 16#650A73548BAF63DE#, 16#766A0ABB3C77B2A8#, 16#81C2C92E47EDAEE6#, 16#92722C851482353B#, 16#A2BFE8A14CF10364#, 16#A81A664BBC423001#, 16#C24B8B70D0F89791#, 16#C76C51A30654BE30#, 16#D192E819D6EF5218#, 16#D69906245565A910#, 16#F40E35855771202A#, 16#106AA07032BBD1B8#, 16#19A4C116B8D2D0C8#, 16#1E376C085141AB53#, 16#2748774CDF8EEB99#, 16#34B0BCB5E19B48A8#, 16#391C0CB3C5C95A63#, 16#4ED8AA4AE3418ACB#, 16#5B9CCA4F7763E373#, 16#682E6FF3D6B2B8A3#, 16#748F82EE5DEFB2FC#, 16#78A5636F43172F60#, 16#84C87814A1F0AB72#, 16#8CC702081A6439EC#, 16#90BEFFFA23631E28#, 16#A4506CEBDE82BDE9#, 16#BEF9A3F7B2C67915#, 16#C67178F2E372532B#, 16#CA273ECEEA26619C#, 16#D186B8C721C0C207#, 16#EADA7DD6CDE0EB1E#, 16#F57D4F7FEE6ED178#, 16#06F067AA72176FBA#, 16#0A637DC5A2C898A6#, 16#113F9804BEF90DAE#, 16#1B710B35131C471B#, 16#28DB77F523047D84#, 16#32CAAB7B40C72493#, 16#3C9EBE0A15C9BEBC#, 16#431D67C49C100D4C#, 16#4CC5D4BECB3E42B6#, 16#597F299CFC657E2A#, 16#5FCB6FAB3AD6FAEC#, 16#6C44198C4A475817#); Hex_Chars : constant array (Interfaces.Unsigned_64 range 0 .. 15) of Character := ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); -- Stream_Element_Array8 -- subtype Stream_Element_Array8 is Ada.Streams.Stream_Element_Array (1 .. 8); -- Endian -- function Endian (Value : in Stream_Element_Array8) return Interfaces.Unsigned_64; -- Sigma0 -- function Sigma0 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; -- Sigma1 -- function Sigma1 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; -- E0 -- function E0 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; -- E1 -- function E1 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; -- Ch -- function Ch (X, Y, Z : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; -- Maj -- function Maj (X, Y, Z : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64; --------------- -- Calculate -- --------------- function Calculate (Value : in String) return SHA512 is H : Hasher_512; Res : SHA512; begin Update (H, Value); Result (H, Res); return Res; end Calculate; -------------------- -- Wide_Calculate -- -------------------- function Wide_Calculate (Value : in Wide_String) return SHA512 is H : Hasher_512; Res : SHA512; begin Wide_Update (H, Value); Result (H, Res); return Res; end Wide_Calculate; ------------------------- -- Wide_Wide_Calculate -- ------------------------- function Wide_Wide_Calculate (Value : in Wide_Wide_String) return SHA512 is H : Hasher_512; Res : SHA512; begin Wide_Wide_Update (H, Value); Result (H, Res); return Res; end Wide_Wide_Calculate; --------------- -- Calculate -- --------------- function Calculate (Value : in Ada.Streams.Stream_Element_Array) return SHA512 is H : Hasher_512; Res : SHA512; begin Update (H, Value); Result (H, Res); return Res; end Calculate; ------------ -- Update -- ------------ procedure Update (This : in out Hasher_512; Value : in Ada.Streams.Stream_Element_Array) is use Ada.Streams; Buffer : constant Stream_Element_Array := This.Internal_Buffer (1 .. This.Last) & Value; Index : Stream_Element_Offset := Buffer'First; begin while Index + 127 <= Buffer'Last loop Process (This, Buffer (Index .. Index + 127)); Index := Index + 128; end loop; This.Last := Buffer'Last - Index + 1; This.Internal_Buffer (1 .. This.Last) := Buffer (Index .. Buffer'Last); This.Length := This.Length + Value'Length; end Update; ------------- -- Process -- ------------- procedure Process (This : in out Hasher_512; Value : in Ada.Streams.Stream_Element_Array) is use Interfaces; use Ada.Streams; Hash : Hash_Array (1 .. 8) := This.Internal_Hash; W : Hash_Array (1 .. 80); Temp1, Temp2 : Interfaces.Unsigned_64; Position : Stream_Element_Offset; begin for Index in 1 .. 16 loop Position := Stream_Element_Offset (((Index - 1) * 8) + 1); W (Index) := Endian (Value (Position .. Position + 7)); end loop; for Index in 17 .. 80 loop W (Index) := Sigma1 (W (Index - 2)) + W (Index - 7) + Sigma0 (W (Index - 15)) + W (Index - 16); end loop; for Index in 1 .. 80 loop Temp1 := Hash (8) + E1 (Hash (5)) + Ch (Hash (5), Hash (6), Hash (7)) + K (Index) + W (Index); Temp2 := E0 (Hash (1)) + Maj (Hash (1), Hash (2), Hash (3)); Hash (8) := Hash (7); Hash (7) := Hash (6); Hash (6) := Hash (5); Hash (5) := Hash (4) + Temp1; Hash (4) := Hash (3); Hash (3) := Hash (2); Hash (2) := Hash (1); Hash (1) := Temp1 + Temp2; end loop; for Index in 1 .. 8 loop This.Internal_Hash (Index) := This.Internal_Hash (Index) + Hash (Index); end loop; end Process; ------------ -- Result -- ------------ procedure Result (This : in out Hasher_512; Value : out SHA512) is use Ada.Streams; use Interfaces; Last : Stream_Element_Array (1 .. 128) := (others => 0); Length : Unsigned_64 := Unsigned_64 (This.Length) * 8; Result_Position : Positive := Value'First; -- To_Hex -- procedure To_Hex (Item : in Unsigned_64) is V : Unsigned_64 := Item; Position : Integer := Result_Position + 15; begin for Index in 1 .. 8 loop Value (Position) := Hex_Chars (V and 16#0F#); Position := Position - 1; V := Shift_Right (V, 4); Value (Position) := Hex_Chars (V and 16#0F#); Position := Position - 1; V := Shift_Right (V, 4); end loop; Result_Position := Result_Position + 16; end To_Hex; begin Last (1 .. This.Last) := This.Internal_Buffer (1 .. This.Last); Last (This.Last + 1) := 16#80#; if This.Last > 112 then Process (This, Last); Last := (others => 0); end if; for Index in 121 .. 128 loop Last (Stream_Element_Offset (Index)) := Stream_Element ((Shift_Right (Length, (128 - Index) * 8)) and 16#FF#); end loop; Process (This, Last); for Index in 1 .. 8 loop To_Hex (This.Internal_Hash (Index)); end loop; end Result; ------------ -- Endian -- ------------ function Endian (Value : in Stream_Element_Array8) return Interfaces.Unsigned_64 is function To_I64 is new Ada.Unchecked_Conversion (Stream_Element_Array8, Interfaces.Unsigned_64); Temp : Stream_Element_Array8 := (Value (8), Value (7), Value (6), Value (5), Value (4), Value (3), Value (2), Value (1)); begin return To_I64 (Temp); end Endian; ------------ -- Sigma0 -- ------------ function Sigma0 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return Rotate_Right (Value, 1) xor Rotate_Right (Value, 8) xor Shift_Right (Value, 7); end Sigma0; ------------ -- Sigma1 -- ------------ function Sigma1 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return Rotate_Right (Value, 19) xor Rotate_Right (Value, 61) xor Shift_Right (Value, 6); end Sigma1; -------- -- E0 -- -------- function E0 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return Rotate_Right (Value, 28) xor Rotate_Right (Value, 34) xor Rotate_Right (Value, 39); end E0; -------- -- E1 -- -------- function E1 (Value : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return Rotate_Right (Value, 14) xor Rotate_Right (Value, 18) xor Rotate_Right (Value, 41); end E1; -------- -- Ch -- -------- function Ch (X, Y, Z : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return (X and Y) xor ((not X) and Z); end Ch; --------- -- Maj -- --------- function Maj (X, Y, Z : in Interfaces.Unsigned_64) return Interfaces.Unsigned_64 is use Interfaces; begin return (X and Y) xor (X and Z) xor (Y and Z); end Maj; end Gela.Hash.SHA.b512; ------------------------------------------------------------------------------ -- Copyright (c) 2006, <NAME> -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- 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 <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
29,968
ada
12
jquorning/ada-asf
src/asf-converters-sizes.adb
<reponame>jquorning/ada-asf<gh_stars>10-100 ----------------------------------------------------------------------- -- asf-converters-sizes -- Size converter -- Copyright (C) 2012 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Exceptions; with Ada.Strings.Unbounded; with Util.Locales; with Util.Strings; with Util.Properties.Bundles; with ASF.Locales; with ASF.Utils; with ASF.Applications.Main; package body ASF.Converters.Sizes is ONE_KB : constant Long_Long_Integer := 1_024; ONE_MB : constant Long_Long_Integer := ONE_KB * 1_024; ONE_GB : constant Long_Long_Integer := ONE_MB * 1_024; UNIT_GB : aliased constant String := "size_giga_bytes"; UNIT_MB : aliased constant String := "size_mega_bytes"; UNIT_KB : aliased constant String := "size_kilo_bytes"; UNIT_B : aliased constant String := "size_bytes"; -- ------------------------------ -- Convert the object value into a string. The object value is associated -- with the specified component. -- If the string cannot be converted, the Invalid_Conversion exception should be raised. -- ------------------------------ function To_String (Convert : in Size_Converter; Context : in ASF.Contexts.Faces.Faces_Context'Class; Component : in ASF.Components.Base.UIComponent'Class; Value : in Util.Beans.Objects.Object) return String is pragma Unreferenced (Convert); Bundle : ASF.Locales.Bundle; Locale : constant Util.Locales.Locale := Context.Get_Locale; begin begin ASF.Applications.Main.Load_Bundle (Context.Get_Application.all, Name => "sizes", Locale => Util.Locales.To_String (Locale), Bundle => Bundle); exception when E : Util.Properties.Bundles.NO_BUNDLE => Component.Log_Error ("Cannot localize sizes: {0}", Ada.Exceptions.Exception_Message (E)); end; -- Convert the value as an integer here so that we can raise -- the Invalid_Conversion exception. declare Size : constant Long_Long_Integer := Util.Beans.Objects.To_Long_Long_Integer (Value); Val : Integer; Values : ASF.Utils.Object_Array (1 .. 1); Result : Ada.Strings.Unbounded.Unbounded_String; Unit : Util.Strings.Name_Access; begin if Size >= ONE_GB then Val := Integer ((Size + ONE_GB / 2) / ONE_GB); Unit := UNIT_GB'Access; elsif Size >= ONE_MB then Val := Integer ((Size + ONE_MB / 2) / ONE_MB); Unit := UNIT_MB'Access; elsif Size >= ONE_KB then Val := Integer ((Size + ONE_KB / 2) / ONE_KB); Unit := UNIT_KB'Access; else Val := Integer (Size); Unit := UNIT_B'Access; end if; Values (1) := Util.Beans.Objects.To_Object (Val); ASF.Utils.Formats.Format (Bundle.Get (Unit.all), Values, Result); return Ada.Strings.Unbounded.To_String (Result); end; exception when E : others => raise ASF.Converters.Invalid_Conversion with Ada.Exceptions.Exception_Message (E); end To_String; -- ------------------------------ -- Convert the date string into an object for the specified component. -- If the string cannot be converted, the Invalid_Conversion exception should be raised. -- ------------------------------ function To_Object (Convert : in Size_Converter; Context : in ASF.Contexts.Faces.Faces_Context'Class; Component : in ASF.Components.Base.UIComponent'Class; Value : in String) return Util.Beans.Objects.Object is pragma Unreferenced (Convert, Context, Value); begin Component.Log_Error ("Conversion of string to a size is not implemented"); raise ASF.Converters.Invalid_Conversion with "Not implemented"; return Util.Beans.Objects.Null_Object; end To_Object; end ASF.Converters.Sizes;
29,969
ada
15
AdaCore/training_material
courses/fundamentals_of_ada/labs/prompts/040_statements/main.adb
<filename>courses/fundamentals_of_ada/labs/prompts/040_statements/main.adb with Ada.Text_IO; use Ada.Text_IO; procedure Main is type Days_Of_Week_T is (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); type Hours_Worked is digits 6; Total_Worked : Hours_Worked := 0.0; Hours_Today : Hours_Worked; Overtime : Hours_Worked; begin -- For each day in the Days_Of_Week_T loop -- Print prompt indicating which day we're asking for -- Loop "forever" Hours_Today := Hours_Worked'value (Get_Line); -- exit the main loop if hours worked < 0 if Hours_Today > 24.0 then Put_Line ("I don't believe you"); else -- exit the input loop if a reasonable number is reached null; end if; -- if hours worked > 8 then Overtime := Hours_Today - 8.0; Hours_Today := Hours_Today + 1.5 * Overtime; -- Calculate actual hours paid for based on day of the week -- Monday - Friday, just add hours worked -- Saturday - hours worked * 1.5 -- Sunday - hours worked * 2 Put_Line (Hours_Worked'image (Total_Worked)); end Main;
29,970
ada
7
Irvise/Ada_Scheme_Example
src/scheme_test.ads
<reponame>Irvise/Ada_Scheme_Example with Ada.Text_IO; use Ada.Text_IO; with Interfaces.C; use Interfaces.C; package Scheme_Test is procedure Adainit; pragma Import (C, AdaInit); procedure Adafinal; pragma Import (C, AdaFinal); function Hello_Ada(Num : Int) return Int with Export => True, Convention => C, External_Name => "hello_ada"; function Hello_Scheme (String : Char_Array) return Int with Import => True, Convention => C, External_Name => "hello_scheme"; end Scheme_Test;
29,971
ada
11
reznikmm/ada_lsp
tests/checkers.adb
<filename>tests/checkers.adb -- Copyright (c) 2017 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Streams; with Ada.Characters.Wide_Wide_Latin_1; with League.Stream_Element_Vectors; with League.Strings; with League.Text_Codecs; with League.String_Vectors; package body Checkers is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Pattern : constant Wide_Wide_String := "^(..[^\:]*)\:([0-9]+)\:(([0-9]+)\:)?\ ((warning\:|\(style\))?.*)"; -- 1 2 34 56 type Capture_Kinds is (File_Name, Line, Column_Group, Column, Message, Warning); pragma Unreferenced (Column_Group); type Capture_Array is array (Capture_Kinds) of League.Strings.Universal_String; procedure Decode (Got : Capture_Array; File : out LSP.Types.LSP_String; Item : out LSP.Messages.Diagnostic); ------------ -- Decode -- ------------ procedure Decode (Got : Capture_Array; File : out LSP.Types.LSP_String; Item : out LSP.Messages.Diagnostic) is From : constant Positive := Positive'Wide_Wide_Value (Got (Line).To_Wide_Wide_String); Col : Positive := 1; begin File := Got (File_Name); if not Got (Column).Is_Empty then Col := Positive'Wide_Wide_Value (Got (Column).To_Wide_Wide_String); end if; Item.span := (first => (LSP.Types.Line_Number (From - 1), LSP.Types.UTF_16_Index (Col - 1)), last => (LSP.Types.Line_Number (From - 1), LSP.Types.UTF_16_Index (Col - 1))); if Got (Warning).Is_Empty then Item.severity := (True, LSP.Messages.Error); elsif Got (Warning).Starts_With ("warning") then Item.severity := (True, LSP.Messages.Warning); elsif Got (Warning).Starts_With ("(style)") then Item.severity := (True, LSP.Messages.Hint); end if; Item.message := Got (Message); Item.source := (True, +"Compiler"); end Decode; ---------------- -- Initialize -- ---------------- not overriding procedure Initialize (Self : in out Checker; Project : LSP.Types.LSP_String) is begin Self.Project := Project; Self.Pattern := League.Regexps.Compile (+Pattern); Self.Compiler := GNAT.OS_Lib.Locate_Exec_On_Path ("gprbuild"); end Initialize; --------- -- Run -- --------- not overriding procedure Run (Self : in out Checker; File : LSP.Types.LSP_String; Result : in out LSP.Messages.Diagnostic_Vector) is Data : League.Stream_Element_Vectors.Stream_Element_Vector; Input : GNAT.OS_Lib.File_Descriptor; Name : aliased String := File.To_UTF_8_String; U : aliased String := "-u"; F : aliased String := "-f"; C : aliased String := "-c"; P : aliased String := "-P"; GPR : aliased String := Self.Project.To_UTF_8_String; Args : constant GNAT.OS_Lib.Argument_List (1 .. 6) := (U'Unchecked_Access, F'Unchecked_Access, C'Unchecked_Access, P'Unchecked_Access, GPR'Unchecked_Access, Name'Unchecked_Access); Code : Integer; begin Input := GNAT.OS_Lib.Create_File ("/tmp/ada-lsp.log", GNAT.OS_Lib.Binary); GNAT.OS_Lib.Spawn (Program_Name => Self.Compiler.all, Args => Args, Output_File_Descriptor => Input, Return_Code => Code); Input := GNAT.OS_Lib.Open_Read ("/tmp/ada-lsp.log", GNAT.OS_Lib.Binary); loop declare use type Ada.Streams.Stream_Element_Offset; Buffer : Ada.Streams.Stream_Element_Array (1 .. 512); Last : Ada.Streams.Stream_Element_Offset; begin Last := Ada.Streams.Stream_Element_Offset (GNAT.OS_Lib.Read (Input, Buffer'Address, Buffer'Length)); Data.Append (Buffer (1 .. Last)); exit when Last /= Buffer'Length; end; end loop; declare Text : constant League.Strings.Universal_String := League.Text_Codecs.Codec_For_Application_Locale.Decode (Data); Lines : constant League.String_Vectors.Universal_String_Vector := Text.Split (Ada.Characters.Wide_Wide_Latin_1.LF); begin for J in 1 .. Lines.Length loop declare Name : LSP.Types.LSP_String; Item : LSP.Messages.Diagnostic; Got : Capture_Array; Match : constant League.Regexps.Regexp_Match := Self.Pattern.Find_Match (Lines (J)); begin if Match.Is_Matched then for J in Got'Range loop Got (J) := Match.Capture (Capture_Kinds'Pos (J) + 1); end loop; Decode (Got, Name, Item); Result.Append (Item); end if; end; end loop; end; end Run; end Checkers;
29,972
ada
79
Roldak/OpenGLAda
tests/text/text_test.ads
-- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" package Text_Test is pragma Pure; end Text_Test;
29,973
ada
0
jfitz/code-stat
test/data/Ada-83/signup.adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Exceptions; use Ada.Exceptions; procedure Checkpres is -- input file: signups People : File_Type; -- output files: times.html, names.html Times : File_Type; Pos, Lno : Integer := 0; Buf : String (1 .. 1024) := (others => ' '); Last, First : Integer := 0; type Day_Record is record Month : Integer; Day : Integer; end record; type Day_Array is array (Natural range <>) of Day_Record; Presentation_Days : constant Day_Array := ((9, 23), (9, 30), (10, 7), (10, 14), (10, 21), (10, 28), (11, 04), (11, 18), (12, 2), (12, 9)); type String_Access is access String; type Student_Index is new Integer range -1 .. 52; Student_Names : array (Student_Index range 0 .. 52) of String_Access; Last_Student : Student_Index := Student_Names'First - 1; Name_Order : array (Student_Names'Range) of Student_Index; type Presentation is record Student : Student_Index := -1; Topic : String_Access := null; end record; type Slot_Index is new Integer; Slots : array (Slot_Index range 0 .. Presentation_Days'Length * 8 - 1) of Presentation; subtype Time_String is String (1 .. 5); Presentation_Times : constant array (0 .. 7) of Time_String := ("12:20", "12:30", "12:40", "12:50", "01:25", "01:35", "01:45", "01:55"); function Time (I : Slot_Index) return String is begin return Presentation_Times (Integer (I) mod 8); end Time; function Recitation (I : Slot_Index) return Positive is begin return 1 + (Integer (I) / 4) mod 2; end Recitation; function Month (I : Slot_Index) return Positive is begin return Presentation_Days (Integer (I) / 8).Month; end Month; function Day (I : Slot_Index) return Positive is begin return Presentation_Days (Integer (I) / 8).Day; end Day; procedure Error (Msg : String) is begin Put_Line (Msg); raise Data_Error; end Error; function Find_Slot (Month : Positive; Day : Positive; Recitation : Positive; Slot : Positive) return Slot_Index is J, K : Slot_Index; begin for I in Presentation_Days'range loop if Presentation_Days (I).Month = Month and then Presentation_Days (I).Day = Day then J := Slot_Index( I - Presentation_Days'First); K := J * 8 + Slot_Index (Recitation - 1) * 4 + Slot_Index (Slot) - 1; return Slots'First + Slot_Index (K); end if; end loop; Error ("problem with slot identification"); return -1; end Find_Slot; function Find_Slot (S : Student_Index) return Slot_Index is begin for I in Slots'range loop if Slots (I).Student = S then return I; end if; end loop; return -1; end Find_Slot; procedure Check_Topic (Topic : String; Section : Integer) is begin for I in Slots'range loop if Recitation (I) = Section then declare T : String_Access renames Slots (I).Topic; begin if T /= null and then T.all /= "TBD" and then T.all (T.all'First .. T.all'First + 2) = Topic (Topic'First .. Topic'First + 2) then Error ("""" & Topic & """" & " apparently duplicates """ & T.all & """"); end if; end; end if; end loop; end Check_Topic; procedure Sort_Names is I, J, K : Student_Index; begin for L in Name_Order'Range loop Name_Order (L) := L; end loop; I := Student_Names'First; Sort: while I < Last_Student loop -- items 1 .. I are sorted while Student_Names (Name_Order (I)).all <= Student_Names (Name_Order (I+1)).all loop -- items 1 .. I + 1 are sorted I := I + 1; if I >= Last_Student then exit Sort; end if; end loop; -- items 1 .. I are sorted; item I+1 < item I K := Name_Order (I + 1); J := I; I := J + 1; loop -- items 1 .. J are sorted; tsk < items J+1 .. I are sorted Name_Order (J + 1) := Name_Order (J); exit when J = 1 or else Student_Names (Name_Order (J - 1)).all <= Student_Names (K).all; J := J - 1; end loop; Name_Order (J) := K; end loop Sort; end Sort_Names; begin -- read in data from signup file -- line format: "student name" section month day section slot "topic" Open (People, In_File, "signups"); declare Month : Integer range 9 .. 12; Day : Integer range 1 .. 31; Section : Integer range 1 .. 2; Slot : Integer range 1 .. 4; I : Slot_Index; begin loop Get_Line (People, Buf, Last); exit when Last < Buf'First; Lno := Lno + 1; -- extract student name field if Last = Buf'Last then Error ("input line longer than " & Integer'Image (Last - 1)); end if; Pos := Buf'First; if Buf (Pos) /= '"' then Error ("missing "" at start of name field"); end if; Pos := Pos + 1; First := Pos; while Pos <= Last and then Buf (Pos) /= '"' loop Pos := Pos + 1; end loop; if Buf (Pos) /= '"' then Error ("missing "" at end of name field"); end if; Last_Student := Last_Student + 1; Student_Names (Last_Student) := new String'(Buf (First .. Pos - 1)); Get (Buf (Pos + 1 .. Last), Section, Pos); if Pos < Last then -- read month, day, section, and slot as integers Get (Buf (Pos + 1 .. Last), Month, Pos); Get (Buf (Pos + 1 .. Last), Day, Pos); Get (Buf (Pos + 1 .. Last), Slot, Pos); I := Find_Slot (Month, Day, Section, Slot); -- read topic loop Pos := Pos + 1; exit when Pos = Last or else Buf (Pos) /= ' '; end loop; if Buf (Pos) /= '"' then Error ("missing "" at start of topic field"); end if; Pos := Pos + 1; First := Pos; while Pos <= Last and then Buf (Pos) /= '"' loop Pos := Pos + 1; end loop; if Buf (Pos) /= '"' then Error ("missing "" at end of topic field"); end if; Check_Topic (Buf (First .. Pos - 1), Section); if Slots (I).Student /= -1 then Error ("conflicting assignments: " & Student_Names (Last_Student).all & "vs." & Student_Names (Slots (I).Student).all); -- don't bother freeing Name_String, -- since this is a one-shot program -- and the number of names is few else Slots (I).Student := Last_Student; Slots (I).Topic := new String' (Buf (First .. Pos - 1)); end if; end if; end loop; exception when End_Error => null; end; begin Open (Times, Out_File, "times.html"); exception when Name_Error => Create (Times, Out_File, "times.html"); end; Put_Line (Times, "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN""><HTML><HEAD>"); Put_Line (Times, "<TITLE>times.html</TITLE>"); Put_Line (Times, "<META HTTP-EQUIV=""CONTENT-TYPE"" CONTENT=""TEXT/HTML; CHARSET=ISO-8859-1"">"); Put_Line (Times, "<LINK REL=""stylesheet"" TYPE=""text/css"" href=""style.css"" title=""stylesheet"">"); Put_Line (Times, "</HEAD><BODY><TABLE WIDTH=""100%""><TR><TD BGCOLOR=""#660000"" ALIGN=RIGHT>"); Put_Line (Times, "<A HREF=""../index.html""><U><FONT COLOR=""CCCC99""><FONT SIZE=2>"); Put_Line (Times, "COP 4020: Programming Languages</FONT>&uarr;</FONT></U></A></TD></TR></TABLE>"); Put_Line (Times, "<CENTER><H1 ALIGN=""CENTER"">Presentation Schedule</H1></CENTER>"); Put_Line (Times, "<TABLE WIDTH=""100%""><TR><TD BGCOLOR=""#CCCC99""><B>Fall Term 2005</B></TD></TR></TABLE>"); Put_Line (Times, "<P></P><UL><LI><A HREF=""times.html#Name"">by name</A></LI>"); Put_Line (Times, "<LI><A HREF=""times.html#Time"">by time</A></LI></UL><HR>"); Put_Line (Times, "<A NAME=""Time"">"); Put_Line (Times, "<P></P><TABLE BORDER>"); Put_Line (Times, "<TR><TH>Month</TH><TH>Day</TH><TH>Time</TH><TH>Student</TH><TH>Topic</TH></TR>"); for I in Slots'Range loop if I mod 8 = 0 then Put (Times, "<TR><TD COLSPAN=5 BGCOLOR=""#ff6600""></TD></TR>"); end if; -- create html line for this slot, showing the person and topic Put (Times, "<TR><TD>"); Put (Times, Month (I)); Put (Times, "</TD><TD>"); Put (Times, Day (I)); Put (Times, "</TD><TD>"); Put (Times, Time (I)); if Slots(I).Student /= -1 then Put (Times, "</TD><TD>"); Put (Times, Student_Names (Slots(I).Student).all); Put (Times, "</TD><TD>"); Put (Times, Slots(I).Topic.all); end if; Put_Line (Times, "</TD></TR>"); end loop; Sort_Names; Put_Line (Times, "</TABLE><HR><TABLE BORDER><A NAME=""Name"">"); Put_Line (Times, "<TR><TH>Name</TH><TH>Month</TH><TH>Day</TH><TH>Time</TH><TH>Topic</TH></TR>"); declare I : Slot_Index; begin for S in Student_Names'First .. Last_Student loop -- create html line for this person, showing time and topic Put (Times, "<TR><TD>"); Put (Times, Student_Names (Name_Order (S)).all); I := Find_Slot (Name_Order(S)); if I >= Slots'First then Put (Times, "</TD><TD>"); Put (Times, Month (I)); Put (Times, "</TD><TD>"); Put (Times, Day (I)); Put (Times, "</TD><TD>"); Put (Times, Time (I)); Put (Times, "</TD><TD>"); Put (Times, Slots(I).Topic.all); end if; Put_Line (Times, "</TD></TR>"); end loop; end; Put_Line (Times, "</TABLE>"); Put_Line (Times, "<TABLE WIDTH=""100%""><TR><TD BGCOLOR=""#CCCC99""><FONT SIZE=""1"">&copy; 2005"); Put_Line (Times, "<A HREF=""http://www.cs.fsu.edu/~baker""><NAME></A>. <BR> ($Id: checkpres.adb,v 1.2 2005/09/08 20:36:47 baker Exp baker $)"); Put_Line (Times, "</FONT>&nbsp;</TD></TR></TABLE> </BODY> </HTML>"); Close (Times); exception when E : others => Put (Lno, 4); Put (": '"); Put (Buf (Buf'First .. Last)); Put_Line ("'"); Put (" "); for I in 1 .. Pos loop Put (' '); end loop; Put_Line ("^"); Put_Line (Ada.Exceptions.Exception_Name (E)); New_Line; raise; end Checkpres;
29,974
ada
17
jrmarino/ravensource
bucket_7E/matreshka/patches/patch-tools_configure_configure-tests-postgresql.adb
--- tools/configure/configure-tests-postgresql.adb.orig 2011-12-27 08:20:56 UTC +++ tools/configure/configure-tests-postgresql.adb @@ -187,7 +187,7 @@ package body Configure.Tests.PostgreSQL (PostgreSQL_Library_Options, +"""-L" & Self.Switches.Libdir - & """, ""-lpq"""); + & """, ""-lpq"", ""-Wl,-rpath,@PREFIX@/lib"""); Self.Report_Status ("yes (command line)"); @@ -197,7 +197,7 @@ package body Configure.Tests.PostgreSQL elsif Has_Pg_Config then Self.Report_Status ("yes (pg_config)"); Substitutions.Insert - (PostgreSQL_Library_Options, +"""-L" & Pg_Libdir & """, ""-lpq"""); + (PostgreSQL_Library_Options, +"""-L" & Pg_Libdir & """, ""-lpq"", ""-Wl,-rpath,@PREFIX@/lib"""); else Self.Report_Status ("no (pg_config not found)");
29,975
ada
0
hfegran/efx32_ada_examples
ada-blinky-full/src/morse.adb
<reponame>hfegran/efx32_ada_examples package body Morse is Dot_Duration : constant Time_Span := Milliseconds(100); Dash_Duration : constant Time_Span := Milliseconds(200); procedure Blink_Morse(LED: Led_No; Led_Color : Color; Duration : Time_Span) is Timeout : Time := Clock; begin Led_Set(LED, Led_Color); Timeout := Timeout + Duration; delay until Timeout; Led_Set(LED, Black); Timeout := Timeout + Dot_Duration; delay until Timeout; end Blink_Morse; procedure Dot is begin Blink_Morse(LED0, Yellow, Dot_Duration); end Dot; procedure Dash is begin Blink_Morse(LED0, Blue, Dash_Duration); end Dash; procedure Morse_Display (S : String) is Timeout : Time := Clock; begin for I of S loop case I is when 'a' => Dot; Dash; when 'b' => Dash; Dot; Dot; Dot; when 'c' => Dash; Dot; Dash; Dot; when 'd' => Dash; Dot; Dot; when 'e' => Dot; when 'f' => Dot; Dot; Dash; Dot; when 'g' => Dash; Dash; Dot; when 'h' => Dot; Dot; Dot; Dot; when 'i' => Dot; Dot; when 'j' => Dash; Dot; Dash; when 'k' => Dash; Dot; Dash; when 'l' => Dot; Dash; Dot; Dot; when 'm' => Dash; Dash; when 'n' => Dash; Dot; when 'o' => Dash; Dash; Dash; when 'p' => Dot; Dash; Dash; Dot; when 'q' => Dash; Dash; Dot; Dash; when 'r' => Dot; Dash; Dot; when 's' => Dot; Dot; Dot; when 't' => Dash; when 'u' => Dot; Dot; Dash; when 'v' => Dot; Dot; Dot; Dash; when 'w' => Dot; Dash; Dash; when 'x' => Dash; Dot; Dot; Dash; when 'y' => Dash; Dot; Dash; Dash; when 'z' => Dash; Dash; Dot; Dot; when 'A' => Dot; Dash; when 'B' => Dash; Dot; Dot; Dot; when 'C' => Dash; Dot; Dash; Dot; when 'D' => Dash; Dot; Dot; when 'E' => Dot; when 'F' => Dot; Dot; Dash; Dot; when 'G' => Dash; Dash; Dot; when 'H' => Dot; Dot; Dot; Dot; when 'I' => Dot; Dot; when 'J' => Dash; Dot; Dash; when 'K' => Dash; Dot; Dash; when 'L' => Dot; Dash; Dot; Dot; when 'M' => Dash; Dash; when 'N' => Dash; Dot; when 'O' => Dash; Dash; Dash; when 'P' => Dot; Dash; Dash; Dot; when 'Q' => Dash; Dash; Dot; Dash; when 'R' => Dot; Dash; Dot; when 'S' => Dot; Dot; Dot; when 'T' => Dash; when 'U' => Dot; Dot; Dash; when 'V' => Dot; Dot; Dot; Dash; when 'W' => Dot; Dash; Dash; when 'X' => Dash; Dot; Dot; Dash; when 'Y' => Dash; Dot; Dash; Dash; when 'Z' => Dash; Dash; Dot; Dot; when '1' => Dot; Dash; Dash; Dash; Dash; when '2' => Dot; Dot; Dash; Dash; Dash; when '3' => Dot; Dot; Dot; Dash; Dash; when '4' => Dot; Dot; Dot; Dot; Dash; when '5' => Dot; Dot; Dot; Dot; Dot; when '6' => Dash; Dot; Dot; Dot; Dot; when '7' => Dash; Dash; Dot; Dot; Dot; when '8' => Dash; Dash; Dash; Dot; Dot; when '9' => Dash; Dash; Dash; Dash; Dot; when '0' => Dash; Dash; Dash; Dash; Dash; when others => null; end case; Timeout := Clock; if I in 'a' .. 'z' or I in 'A' .. 'Z' or I in '0' .. '9' then delay until Timeout + 2 * Dot_Duration; elsif I = ' ' then delay until Timeout + 6 * Dot_Duration; end if; end loop; end Morse_Display; end Morse;
29,976
ada
12
TUM-EI-RCS/StratoX
software/hal/boards/pixracer_v1/hil/hil-timers.adb
-- Institution: Technische Universitaet Muenchen -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: <NAME> (<EMAIL>> with STM32.Timers; use STM32.Timers; with System.OS_Interface; -- @summary -- Target-specific implementation of HIL for Timers. Pixracer. package body HIL.Timers with SPARK_Mode => Off is procedure Initialize (t : in out HIL_Timer) is begin STM32.Timers.Enable (t); end Initialize; procedure Enable (t : in out HIL_Timer; ch : HIL.Timers.HIL_Timer_Channel) is begin if not STM32.Timers.Enabled (t) then STM32.Timers.Enable (t); end if; STM32.Timers.Enable_Channel (t, ch); end Enable; procedure Disable (t : in out HIL_Timer; ch : HIL.Timers.HIL_Timer_Channel) is begin -- STM32.Timers.Disable (t); -- we cannot disable the timer when channel is active STM32.Timers.Disable_Channel (t, ch); -- so we just let the timer do it's thing and disable the channel end Disable; procedure Calculate_Prescaler_and_Period (f : in Frequency_Type; Prescaler : out Short; Period : out Word) is TIM_CLK : constant := System.OS_Interface.Ticks_Per_Second; begin -- Frequency = 0.5 * TIM_CLK / ((Prescaler+1)*(Period+1)) -- TIM_CLK = timer clock input in Hz -- => period = TIM_CLK / (2*f (prescaler+1)) - 1 Prescaler := 0; period := Word (Float (TIM_CLK) / (2.0 * Float (f) * Float (Prescaler+1))); -- smallest: 1Hz => 84000000 < Word'Last -- largest: 1MHz => 84 -- largest: 1MHz => 84 end Calculate_Prescaler_and_Period; procedure Configure_OC_Toggle (This : in out HIL_Timer; Frequency : Frequency_Type; Channel : HIL_Timer_Channel) is Counter_Mode : constant Timer_Counter_Alignment_Mode := Up; Clk_Div : constant Timer_Clock_Divisor := Div1; Reps : constant Byte := 0; Prescaler : Short; Period : Word; begin -- 2. write ARR and CCRx to set event period. Counter decrements -- until zero, then starts at value=Period again. Calculate_Prescaler_and_Period (Frequency, Prescaler, Period); if Period >= 2**16 then Period := 2**16-1; end if; STM32.Timers.Configure (This, Prescaler => Prescaler, Period => Period, Clock_Divisor => Clk_Div, Counter_Mode => Counter_Mode, Repetitions => Reps); -- 3. configure output mode: toggle channel output every time we reach zero STM32.Timers.Configure_Channel_Output (This => This, Channel => Channel, Mode => Toggle, State => Enable, Pulse => Period, Polarity => High); -- 4. disable preload STM32.Timers.Set_Autoreload_Preload (This, False); -- 5. finally enable channel STM32.Timers.Enable_Channel (This, Channel); STM32.Timers.Enable (This); end Configure_OC_Toggle; -- procedure Set_Counter (This : in out HIL_Timer; Value : Word) renames STM32.Timers.Set_Counter; -- procedure Set_Autoreload (This : in out HIL_Timer; Value : Word) renames STM32.Timers.Set_Autoreload; end HIL.Timers;
29,977
ada
17
WinterAlexander/Ada-IntelliJ
src/main/resources/project-templates/ajis_hello/src_ada/hello.ads
package Hello is type Printer is abstract tagged null record; procedure Print_On_Console (P : Printer; V : String) is abstract; type Ada_Printer is new Printer with null record; procedure Print_On_Console (P : Ada_Printer; V : String); procedure Print_Messages (P : Printer'Class); end Hello;
29,978
ada
1
Fabien-Chouteau/tiled-code-gen
src/tcg-outputs-pdf.adb
<filename>src/tcg-outputs-pdf.adb ------------------------------------------------------------------------------ -- -- -- tiled-code-gen -- -- -- -- Copyright (C) 2018 <NAME> -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Directories; with Ada.Text_IO; with PDF_Out; use PDF_Out; with TCG.Palette; with TCG.Tilesets; with TCG.Tile_Layers; with TCG.Utils; package body TCG.Outputs.PDF is use type Palette.Color_Id; use type Palette.ARGB_Color; use type Tilesets.Master_Tile_Id; function Convert (C : Palette.ARGB_Color) return PDF_Out.Color_Type; procedure Draw_Square (Outfile : in out PDF_Out_File; Rect : Rectangle; Color : Color_Type); procedure Put_Palette_Info (Outfile : in out PDF_Out_File; Rect_Size : Real := 60.0; Colors_Per_Line : Natural := 3); procedure Draw_Tile (Outfile : in out PDF_Out_File; Id : Tilesets.Master_Tile_Id; Rect : Rectangle); procedure Put_Master_Tileset (Outfile : in out PDF_Out_File; Tile_Size : Real := 130.0; Tiles_Per_Line : Natural := 2); procedure Draw_Tile_Collision (Outfile : in out PDF_Out_File; Id : Tilesets.Master_Tile_Id; Rect : Rectangle); procedure Put_Master_Tileset_Collisions (Outfile : in out PDF_Out_File; Tile_Size : Real := 130.0; Tiles_Per_Line : Natural := 2); procedure Put_Map (Outfile : in out PDF_Out_File; M : Maps.Map); ------------- -- Convert -- ------------- function Convert (C : Palette.ARGB_Color) return PDF_Out.Color_Type is R : constant Real := Real (C.R) / Real (Palette.Component'Last); G : constant Real := Real (C.G) / Real (Palette.Component'Last); B : constant Real := Real (C.B) / Real (Palette.Component'Last); begin return (R, G, B); end Convert; ----------------- -- Draw_Square -- ----------------- procedure Draw_Square (Outfile : in out PDF_Out_File; Rect : Rectangle; Color : PDF_Out.Color_Type) is begin PDF_Out.Color (Outfile, Color); Draw (Outfile, Rect, fill); end Draw_Square; ---------------------- -- Put_Palette_Info -- ---------------------- procedure Put_Palette_Info (Outfile : in out PDF_Out_File; Rect_Size : Real := 60.0; Colors_Per_Line : Natural := 3) is Layout : constant Rectangle := PDF_Out.Layout (Outfile); Top_Margin : constant Real := 100.0; Left_Margin : constant Real := Rect_Size; Spacing : constant Real := (Layout.width - Left_Margin) / Real (Colors_Per_Line); X : Real := Layout.x_min + Left_Margin; Y : Real := Layout.y_min + Layout.height - Rect_Size - Top_Margin; Cnt : Natural := 1; C : Palette.ARGB_Color; begin Font_Size (Outfile, 40.0); Put_Line (Outfile, "Color Palette"); Font_Size (Outfile, 11.0); for Id in Palette.First_Id .. Palette.Last_Id loop C := Palette.Convert (Id); Draw_Square (Outfile, (X, Y, Rect_Size, Rect_Size), Convert (C)); Color (Outfile, PDF_Out.black); Put_XY (Outfile, X + Rect_Size * 1.3, Y + Rect_Size * 0.8, "Color #" & Id'Img); New_Line (Outfile); Put_Line (Outfile, "R:" & C.R'Img); Put_Line (Outfile, "G:" & C.G'Img); Put_Line (Outfile, "B:" & C.B'Img); if Palette.Transparent = Id then Put_Line (Outfile, "Transparent"); end if; if Cnt mod Colors_Per_Line = 0 then Y := Y - (Rect_Size + 20.0); X := Layout.x_min + Left_Margin; if Y <= Top_Margin then New_Page (Outfile); Y := Layout.y_min + Layout.height - Rect_Size - Top_Margin; end if; else X := X + Spacing; end if; Cnt := Cnt + 1; end loop; end Put_Palette_Info; --------------- -- Draw_Tile -- --------------- procedure Draw_Tile (Outfile : in out PDF_Out_File; Id : Tilesets.Master_Tile_Id; Rect : Rectangle) is Pix_W : constant Real := Rect.width / Real (Tilesets.Tile_Width); Pix_H : constant Real := Rect.height / Real (Tilesets.Tile_Height); C : Palette.ARGB_Color; begin for PX in 1 .. Tilesets.Tile_Width loop for PY in 1 .. Tilesets.Tile_Height loop C := Tilesets.Pix (Id, PX, (Tilesets.Tile_Height - PY + 1)); if C /= Palette.Transparent then Draw_Square (Outfile, (Rect.x_min + Real (PX - 1) * Pix_W, Rect.y_min + Real (PY - 1) * Pix_H, Pix_W, Pix_H), Convert (C)); end if; end loop; end loop; end Draw_Tile; ------------------------ -- Put_Master_Tileset -- ------------------------ procedure Put_Master_Tileset (Outfile : in out PDF_Out_File; Tile_Size : Real := 130.0; Tiles_Per_Line : Natural := 2) is Layout : constant Rectangle := PDF_Out.Layout (Outfile); Top_Margin : constant Real := 100.0; Left_Margin : constant Real := 50.0; Spacing : constant Real := (Layout.width - Left_Margin) / Real (Tiles_Per_Line); X : Real := Layout.x_min + Left_Margin; Y : Real := Layout.y_min + Layout.height - Tile_Size - Top_Margin; Cnt : Natural := 1; begin Font_Size (Outfile, 40.0); Put_Line (Outfile, "Tileset"); Font_Size (Outfile, 12.0); for Id in Tilesets.First_Id .. Tilesets.Last_Id loop if Id /= Tilesets.No_Tile then Draw_Tile (Outfile, Id, (X, Y, Tile_Size, Tile_Size)); end if; Color (Outfile, PDF_Out.black); Draw (Outfile, (X, Y, Tile_Size, Tile_Size), stroke); Put_XY (Outfile, X + Tile_Size * 1.1, Y + Tile_Size * 0.8, "Tile #" & Id'Img); New_Line (Outfile); if Id = Tilesets.No_Tile then Put_Line (Outfile, "No tile"); end if; New_Line (Outfile); if Cnt mod Tiles_Per_Line = 0 then Y := Y - (Tile_Size + 20.0); X := Layout.x_min + Left_Margin; if Y <= Top_Margin then New_Page (Outfile); Y := Layout.y_min + Layout.height - Tile_Size - Top_Margin; end if; else X := X + Spacing; end if; Cnt := Cnt + 1; end loop; end Put_Master_Tileset; ------------------------- -- Draw_Tile_Collision -- ------------------------- procedure Draw_Tile_Collision (Outfile : in out PDF_Out_File; Id : Tilesets.Master_Tile_Id; Rect : Rectangle) is Pix_W : constant Real := Rect.width / Real (Tilesets.Tile_Width); Pix_H : constant Real := Rect.height / Real (Tilesets.Tile_Height); begin for PX in 1 .. Tilesets.Tile_Width loop for PY in 1 .. Tilesets.Tile_Height loop if Tilesets.Collision (Id, PX, (Tilesets.Tile_Height - PY + 1)) then Draw_Square (Outfile, (Rect.x_min + Real (PX - 1) * Pix_W, Rect.y_min + Real (PY - 1) * Pix_H, Pix_W, Pix_H), (1.0, 0.0, 0.0)); end if; end loop; end loop; end Draw_Tile_Collision; ----------------------------------- -- Put_Master_Tileset_Collisions -- ----------------------------------- procedure Put_Master_Tileset_Collisions (Outfile : in out PDF_Out_File; Tile_Size : Real := 130.0; Tiles_Per_Line : Natural := 2) is Layout : constant Rectangle := PDF_Out.Layout (Outfile); Top_Margin : constant Real := 100.0; Left_Margin : constant Real := 50.0; Spacing : constant Real := (Layout.width - Left_Margin) / Real (Tiles_Per_Line); X : Real := Layout.x_min + Left_Margin; Y : Real := Layout.y_min + Layout.height - Tile_Size - Top_Margin; Cnt : Natural := 1; begin Font_Size (Outfile, 40.0); Put_Line (Outfile, "Tileset collisions"); Font_Size (Outfile, 12.0); for Id in Tilesets.First_Id .. Tilesets.Last_Id loop if Id /= Tilesets.No_Tile then Draw_Tile_Collision (Outfile, Id, (X, Y, Tile_Size, Tile_Size)); end if; Color (Outfile, PDF_Out.black); Draw (Outfile, (X, Y, Tile_Size, Tile_Size), stroke); Put_XY (Outfile, X + Tile_Size * 1.1, Y + Tile_Size * 0.8, "Tile #" & Id'Img); New_Line (Outfile); if Id = Tilesets.No_Tile then Put_Line (Outfile, "No tile"); end if; New_Line (Outfile); if Cnt mod Tiles_Per_Line = 0 then Y := Y - (Tile_Size + 20.0); X := Layout.x_min + Left_Margin; if Y <= Top_Margin then New_Page (Outfile); Y := Layout.y_min + Layout.height - Tile_Size - Top_Margin; end if; else X := X + Spacing; end if; Cnt := Cnt + 1; end loop; end Put_Master_Tileset_Collisions; ------------- -- Put_Map -- ------------- procedure Put_Map (Outfile : in out PDF_Out_File; M : Maps.Map) is Tile_Width : constant Natural := Maps.Tile_Width (M); Tile_Height : constant Natural := Maps.Tile_Height (M); Width : constant Natural := Maps.Width (M) * Tile_Width; Height : constant Natural := Maps.Height (M) * Tile_Height; Layout : constant Rectangle := PDF_Out.Layout (Outfile); Pix_W : constant Real := Layout.width / Real (Width); Pix_H : constant Real := Layout.height / Real (Height); Pix_Size : constant Real := Real'Min (Pix_W, Pix_H); C : Palette.ARGB_Color; T_Id : Tilesets.Master_Tile_Id; begin New_Page (Outfile); for Y in reverse 0 .. Height - 1 loop for X in 0 .. Width - 1 loop C := Palette.Transparent; for L in reverse Maps.First_Layer (M) .. Maps.Last_Layer (M) loop T_Id := Maps.Master_Tile (M, Tile_Layers.Tile (Maps.Layer (M, L), 1 + X / Tile_Width, 1 + Y / Tile_Height)); if T_Id /= Tilesets.No_Tile then C := Tilesets.Pix (T_Id, 1 + X mod Tile_Width, 1 + Y mod Tile_Height); end if; if C /= Palette.Transparent then Draw_Square (Outfile, (Layout.x_min + Real (X) * Pix_Size, Layout.y_min + Real (Width - 1 - Y) * Pix_Size, Pix_Size, Pix_Size), Convert (C)); exit; end if; end loop; end loop; end loop; Color (Outfile, PDF_Out.black); Font_Size (Outfile, 20.0); Put_XY (Outfile, 50.0, Layout.y_min + Layout.height - 30.0, Maps.Name (M)); New_Line (Outfile); Font_Size (Outfile, 12.0); for L in reverse Maps.First_Layer (M) .. Maps.Last_Layer (M) loop Put_Line (Outfile, " - " & Tile_Layers.Name (Maps.Layer (M, L))); end loop; end Put_Map; ----------------- -- Gen_PDF_Doc -- ----------------- procedure Gen_PDF_Doc (Directory : String; Filename : String; Map_List : TCG.Maps.List.List) is Outfile : PDF_Out_File; begin if not TCG.Utils.Make_Dir (Directory) then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Cannot create directory for documentation: '" & Directory & "'"); return; end if; Create (Outfile, Ada.Directories.Compose (Directory, Filename)); Title (Outfile, ""); Subject (Outfile, ""); Keywords (Outfile, "Tiled, maps, sprites, palette"); Creator_Application (Outfile, "Tiled_Code_Gen"); Page_Setup (Outfile, A4_portrait); Put_Palette_Info (Outfile); New_Page (Outfile); Put_Master_Tileset (Outfile, Tile_Size => 50.0, Tiles_Per_Line => 5); New_Page (Outfile); Put_Master_Tileset_Collisions (Outfile, Tile_Size => 50.0, Tiles_Per_Line => 5); for M of Map_List loop Put_Map (Outfile, M); end loop; Close (Outfile); end Gen_PDF_Doc; end TCG.Outputs.PDF;
29,979
ada
0
Fabien-Chouteau/offmt-tool
src/offmt_lib-fmt_data-unsigned_generic.adb
with Ada.Text_IO; with Ada.Strings.Fixed; with System.Storage_Elements; use System.Storage_Elements; package body Offmt_Lib.Fmt_Data.Unsigned_Generic is Size_In_Bytes : constant Natural := T'Size / 8; package T_IO is new Ada.Text_IO.Modular_IO (T); function Image (Val : T; Kind : Format_Kind) return String; ----------- -- Image -- ----------- function Image (Val : T; Kind : Format_Kind) return String is Result : String (1 .. (case Kind is when Decimal => Size_In_Bytes * 2 + 4, when Hexadecimal => Size_In_Bytes * 2 + 4, when Binary => T'Size + 4)); begin T_IO.Put (To => Result, Item => Val, Base => (case Kind is when Decimal => 10, when Hexadecimal => 16, when Binary => 2)); case Kind is when Decimal => return Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left); when Hexadecimal => declare Trim : constant String := Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left); begin -- Remove the '16#' and '#' from the hexadecimal image return Trim (Trim'First + 3 .. Trim'Last - 1); end; when Binary => declare Trim : constant String := Ada.Strings.Fixed.Trim (Result, Ada.Strings.Left); begin -- Remove the '2#' and '#' from the binary image return Trim (Trim'First + 2 .. Trim'Last - 1); end; end case; end Image; ---------------- -- From_Frame -- ---------------- overriding procedure From_Frame (This : in out Instance; Frame : in out Data_Frame) is function Shift_Left (Value : T; Amount : Natural) return T with Import, Convention => Intrinsic; Elt : Storage_Element; begin if Remaining (Frame) < Size_In_Bytes then raise Frame_Error with "Frame too short for U" & T'Size'Img; else This.Val := 0; for Cnt in 0 .. Size_In_Bytes - 1 loop Elt := Pop (Frame); This.Val := This.Val or Shift_Left (T (Elt), 8 * Cnt); end loop; end if; end From_Frame; ------------ -- Format -- ------------ overriding function Format (This : Instance; Kind : Format_Kind) return String is begin return Image (This.Val, Kind); end Format; --------- -- Put -- --------- overriding procedure Put (This : Instance; Kind : Format_Kind) is begin Ada.Text_IO.Put (This.Format (Kind)); end Put; ----------- -- Value -- ----------- function Value (This : Instance) return T is begin return This.Val; end Value; end Offmt_Lib.Fmt_Data.Unsigned_Generic;
29,980
ada
0
cortlandstarrett/mcada
example_relationships/src/many_to_many_associative.ads
<gh_stars>0 -- ************************************************************************************* -- -- The recipient is warned that this code should be handled in accordance -- with the HM Government Security Classification indicated throughout. -- -- This code and its contents shall not be used for other than UK Government -- purposes. -- -- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited. -- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in -- confidence and that it may not be copied, used or disclosed to others for any -- purpose except in accordance with DEFCON 91 (Edn 10/92). -- -- File Name: Many_To_Many_Associative.ads -- Version: As detailed by ClearCase -- Version Date: As detailed by ClearCase -- Creation Date: 03-11-99 -- Security Classification: Unclassified -- Project: SRLE (Sting Ray Life Extension) -- Author: <NAME> -- Section: Tactical Software/ Software Architecture -- Division: Underwater Systems Division -- Description: Generic specification of 1-M:M relationship -- Comments: -- -- MODIFICATION RECORD -- -------------------- -- NAME DATE ECR No MODIFICATION -- -- DB 24/09/01 TBA Rename Link, Unlink & Unassociate parameters -- to match those for 1:1 type relationships, -- at the request of George. -- -- db 17/04/02 SRLE100003005 Correlated associative navigations supported. -- -- db 22/04/02 SRLE100002907 Procedure initialise removed as surplus to requirements -- -- DNS 20/05/15 CR 10265 For Navigate procedures returning a list, -- the Return is now an "in" parameter -- -- ************************************************************************************** with Root_Object; with Ada.Tags; generic package Many_To_Many_Associative is procedure Register_M1_End_Class (M1_Instance: in Ada.Tags.Tag); procedure Register_M2_End_Class (M2_Instance: in Ada.Tags.Tag); procedure Register_Associative_End_Class (Associative_Instance: in Ada.Tags.Tag); -- function Report_M1_End_Class return Ada.Tags.Tag; function Report_M2_End_Class return Ada.Tags.Tag; function Report_Associative_End_Class return Ada.Tags.Tag; --------------------------------------------------------------------- procedure Link ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access; Using : in Root_Object.Object_Access); procedure Unassociate ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access; From : in Root_Object.Object_Access); procedure Unlink ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access); procedure Navigate ( From : in Root_Object.Object_List.List_Header_Access_Type; Class : in Ada.Tags.Tag; To : in Root_Object.Object_List.List_Header_Access_Type); -- -- navigate from a set to a set -- valid for all traversals -- -- procedure Navigate ( From : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : in Root_Object.Object_List.List_Header_Access_Type); -- -- navigate from a single to a set -- valid for: -- M1 -> M2 -- M1 -> A -- M2 -> M1 -- M2 -> A -- procedure Navigate ( From : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : out Root_Object.Object_Access); -- -- navigate from a single to a single -- valid for: -- A -> M1 -- A -> M2 -- -- associative correlated navigation procedure Navigate ( From : in Root_Object.Object_Access; Also : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : out Root_Object.Object_Access); end Many_To_Many_Associative;
29,981
ada
24
svn2github/matreshka
source/web/servlet/servlet-responses.ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2015, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- Defines an object to assist a servlet in sending a response to the client. -- The servlet container creates a ServletResponse object and passes it as an -- argument to the servlet's service method. -- -- To send binary data in a MIME body response, use the ServletOutputStream -- returned by getOutputStream(). -- -- The charset for the MIME body response can be specified explicitly using -- the setCharacterEncoding(java.lang.String) and -- setContentType(java.lang.String) methods, or implicitly using the -- setLocale(java.util.Locale) method. Explicit specifications take precedence -- over implicit specifications. If no charset is specified, ISO-8859-1 will -- be used. The setCharacterEncoding, setContentType, or setLocale method must -- be called before getWriter and before committing the response for the -- character encoding to be used. -- -- See the Internet RFCs such as RFC 2045 for more information on MIME. -- Protocols such as SMTP and HTTP define profiles of MIME, and those -- standards are still evolving. ------------------------------------------------------------------------------ with League.Strings; with Servlet.Output_Streams; package Servlet.Responses is pragma Preelaborate; type Servlet_Response is limited interface; type Servlet_Response_Access is access all Servlet_Response'Class; not overriding function Get_Output_Stream (Self : Servlet_Response) return not null access Servlet.Output_Streams.Servlet_Output_Stream'Class is abstract; -- Returns a ServletOutputStream suitable for writing binary data in the -- response. The servlet container does not encode the binary data. -- -- Calling flush() on the ServletOutputStream commits the response. not overriding procedure Set_Character_Encoding (Self : in out Servlet_Response; Encoding : League.Strings.Universal_String) is abstract; -- Sets the character encoding (MIME charset) of the response being sent to -- the client, for example, to UTF-8. If the character encoding has already -- been set by setContentType(java.lang.String) or -- setLocale(java.util.Locale), this method overrides it. Calling -- setContentType(java.lang.String) with the String of text/html and -- calling this method with the String of UTF-8 is equivalent with calling -- setContentType with the String of text/html; charset=UTF-8. -- -- This method can be called repeatedly to change the character encoding. -- This method has no effect if it is called after getWriter has been -- called or after the response has been committed. -- -- Containers must communicate the character encoding used for the servlet -- response's writer to the client if the protocol provides a way for doing -- so. In the case of HTTP, the character encoding is communicated as part -- of the Content-Type header for text media types. Note that the character -- encoding cannot be communicated via HTTP headers if the servlet does not -- specify a content type; however, it is still used to encode text written -- via the servlet response's writer. not overriding procedure Set_Content_Type (Self : in out Servlet_Response; To : League.Strings.Universal_String) is abstract; -- Sets the content type of the response being sent to the client, if the -- response has not been committed yet. The given content type may include -- a character encoding specification, for example, -- text/html;charset=UTF-8. The response's character encoding is only set -- from the given content type if this method is called before getWriter is -- called. -- -- This method may be called repeatedly to change content type and -- character encoding. This method has no effect if called after the -- response has been committed. It does not set the response's character -- encoding if it is called after getWriter has been called or after the -- response has been committed. -- -- Containers must communicate the content type and the character encoding -- used for the servlet response's writer to the client if the protocol -- provides a way for doing so. In the case of HTTP, the Content-Type -- header is used. end Servlet.Responses;
29,982
ada
0
ekoeppen/MSP430_Generic_Ada_Drivers
apps/bootloader/memory.ads
<reponame>ekoeppen/MSP430_Generic_Ada_Drivers with System; use System; with Interfaces; use Interfaces; package Memory is Flash_Start : Unsigned_16 with Import, Convention => Asm, External_Name => "__flash_start"; Flash_Size : Unsigned_16 with Import, Convention => Asm, External_Name => "__flash_size"; Info_Start : Unsigned_16 with Import, Convention => Asm, External_Name => "__info_start"; Info_Size : Unsigned_16 with Import, Convention => Asm, External_Name => "__info_size"; Flash_Segment_Size : constant Unsigned_16 := 512; Info_Segment_Size : constant Unsigned_16 := 64; type Flash_Memory_Range is new Unsigned_16 range Flash_Start .. Flash_Start + Flash_Size - 2; type Info_Memory_Range is new Unsigned_16 range Info_Start .. Info_Start + Info_Size - 2; type Flash_Segment_Range is new Unsigned_16 range 1 .. Flash_Size / Flash_Segment_Size; Flash_Memory : array (Flash_Memory_Range) of Unsigned_8 with Address => System'To_Address (Flash_Start); Info_Memory : array (Info_Memory_Range) of Unsigned_8 with Address => System'To_Address (Info_Start); function "+" (Addr : Flash_Memory_Range; Offset : Unsigned_16) return Flash_Memory_Range; end Memory;
29,983
ada
0
balintsoos/LearnAda
gyak/gyak1-2/signof.adb
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO; use Ada.Text_IO; with Mat; -- use Mat; procedure signOf is N : Integer; begin Get( N ); Put( Mat.signof(N)); end signOf;
29,984
ada
32
robdaemon/AdaYaml
src/implementation/yaml-presenter-analysis.adb
-- part of AdaYaml, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" package body Yaml.Presenter.Analysis is function Features (S : String) return Scalar_Features is Pos : Positive := S'First; Cur : Character; Cur_Word_Length : Natural := 0; Cur_Line_Length : Natural := 0; -- states procedure Read_Beginning (Ret : out Scalar_Features) is begin if S'Length = 0 then Ret := (Max_Word_Length => 0, Max_Line_Length => 0, Single_Line_Length => 0, Quoting_Needed => Single, Unquoted_Single_Line => True, Folding_Possible => True, Contains_Non_Printable => False, Leading_Spaces => 0, Trailing_Linefeeds => 0); else Ret := (Max_Word_Length => 0, Max_Line_Length => 0, Single_Line_Length => 0, Quoting_Needed => None, Unquoted_Single_Line => True, Folding_Possible => True, Contains_Non_Printable => False, Leading_Spaces => 0, Trailing_Linefeeds => 0); Cur := S (Pos); if Cur = ' ' then Ret.Quoting_Needed := Single; loop Ret.Leading_Spaces := Ret.Leading_Spaces + 1; Cur_Word_Length := Cur_Word_Length + 1; Cur_Line_Length := Cur_Line_Length + 1; Pos := Pos + 1; exit when Pos > S'Last; Cur := S (Pos); exit when Cur /= ' '; end loop; end if; end if; end Read_Beginning; procedure Read_Word (Ret : in out Scalar_Features) is begin if Cur = '#' then Ret.Quoting_Needed := Necessary_Quoting'Max (Ret.Quoting_Needed, Single); Ret.Unquoted_Single_Line := False; end if; loop case Cur is when ':' => Ret.Single_Line_Length := Ret.Single_Line_Length + 1; if Pos < S'Last and then S (Pos + 1) = ' ' then Ret.Quoting_Needed := Necessary_Quoting'Max (Ret.Quoting_Needed, Single); Ret.Unquoted_Single_Line := False; Pos := Pos + 1; return; end if; when Character'Val (7) .. Character'Val (9) => Ret.Quoting_Needed := Double; Ret.Single_Line_Length := Ret.Single_Line_Length + 2; Ret.Contains_Non_Printable := True; when '"' => if Pos = S'First then Ret.Quoting_Needed := Necessary_Quoting'Max (Ret.Quoting_Needed, Single); Ret.Single_Line_Length := Ret.Single_Line_Length + 2; Ret.Unquoted_Single_Line := False; else Ret.Single_Line_Length := Ret.Single_Line_Length + 1; end if; when others => Ret.Single_Line_Length := Ret.Single_Line_Length + 1; end case; Pos := Pos + 1; exit when Pos > S'Last; Cur := S (Pos); exit when Cur in ' ' | Character'Val (10); Cur_Word_Length := Cur_Word_Length + 1; Cur_Line_Length := Cur_Line_Length + 1; end loop; end Read_Word; procedure Read_Newlines (Ret : in out Scalar_Features) is begin Ret.Max_Line_Length := Natural'Max (Ret.Max_Line_Length, Cur_Line_Length); Cur_Line_Length := 0; Ret.Max_Word_Length := Natural'Max (Ret.Max_Word_Length, Cur_Word_Length); Cur_Word_Length := 0; loop Ret.Trailing_Linefeeds := Ret.Trailing_Linefeeds + 1; Pos := Pos + 1; exit when Pos > S'Last; Cur := S (Pos); exit when Cur /= Character'Val (10); end loop; if Pos <= S'Last then Ret.Trailing_Linefeeds := 0; end if; end Read_Newlines; procedure Read_Space_After_Word (Ret : in out Scalar_Features) is begin Cur_Line_Length := Cur_Line_Length + 1; Ret.Single_Line_Length := Ret.Single_Line_Length + 1; Pos := Pos + 1; if Pos > S'Last then Ret.Quoting_Needed := Necessary_Quoting'Max (Ret.Quoting_Needed, Single); Ret.Unquoted_Single_Line := False; Cur_Word_Length := Cur_Word_Length + 1; Cur_Line_Length := Cur_Line_Length + 1; return; end if; Cur := S (Pos); if Cur in ' ' | Character'Val (10) then Cur_Word_Length := Cur_Word_Length + 1; while Cur = ' ' loop Cur_Word_Length := Cur_Word_Length + 1; Cur_Line_Length := Cur_Line_Length + 1; Ret.Single_Line_Length := Ret.Single_Line_Length + 1; Pos := Pos + 1; exit when Pos > S'Last; end loop; else Ret.Max_Word_Length := Natural'Max (Ret.Max_Word_Length, Cur_Word_Length); Cur_Word_Length := 0; end if; end Read_Space_After_Word; begin return Ret : Scalar_Features do Read_Beginning (Ret); if Pos <= S'Last then loop Read_Word (Ret); exit when Pos > S'Last; loop case Cur is when ' ' => Read_Space_After_Word (Ret); when Character'Val (10) => Read_Newlines (Ret); when others => null; -- never happens end case; exit when Pos > S'Last or else not (Cur in ' ' | Character'Val (10)); end loop; exit when Pos > S'Last; end loop; end if; end return; end Features; end Yaml.Presenter.Analysis;
29,985
ada
0
persan/a-libpcap
src/gen/pcap-low_level-pcap_pcap_h.ads
-- begin read only pragma Ada_2012; pragma Style_Checks (Off); pragma Warnings (Off); -- Since this is automaticly generated with Interfaces.C; use Interfaces.C; with PCAP.Low_Level.pcap_bpf_h; with System.Linux; with Interfaces.C.Strings; with System; limited with Interfaces.C_Streams; package PCAP.Low_Level.pcap_pcap_h is PCAP_VERSION_MAJOR : constant := 2; -- /usr/include/pcap/pcap.h:65 PCAP_VERSION_MINOR : constant := 4; -- /usr/include/pcap/pcap.h:66 PCAP_ERRBUF_SIZE : constant := 256; -- /usr/include/pcap/pcap.h:68 -- arg-macro: function LT_FCS_LENGTH_PRESENT (x) -- return (x) and 16#04000000#; -- arg-macro: function LT_FCS_LENGTH (x) -- return ((x) and 16#F0000000#) >> 28; -- arg-macro: function LT_FCS_DATALINK_EXT (x) -- return (((x) and 16#F#) << 28) or 16#04000000#; PCAP_IF_LOOPBACK : constant := 16#00000001#; -- /usr/include/pcap/pcap.h:222 PCAP_IF_UP : constant := 16#00000002#; -- /usr/include/pcap/pcap.h:223 PCAP_IF_RUNNING : constant := 16#00000004#; -- /usr/include/pcap/pcap.h:224 PCAP_ERROR : constant := -1; -- /usr/include/pcap/pcap.h:246 PCAP_ERROR_BREAK : constant := -2; -- /usr/include/pcap/pcap.h:247 PCAP_ERROR_NOT_ACTIVATED : constant := -3; -- /usr/include/pcap/pcap.h:248 PCAP_ERROR_ACTIVATED : constant := -4; -- /usr/include/pcap/pcap.h:249 PCAP_ERROR_NO_SUCH_DEVICE : constant := -5; -- /usr/include/pcap/pcap.h:250 PCAP_ERROR_RFMON_NOTSUP : constant := -6; -- /usr/include/pcap/pcap.h:251 PCAP_ERROR_NOT_RFMON : constant := -7; -- /usr/include/pcap/pcap.h:252 PCAP_ERROR_PERM_DENIED : constant := -8; -- /usr/include/pcap/pcap.h:253 PCAP_ERROR_IFACE_NOT_UP : constant := -9; -- /usr/include/pcap/pcap.h:254 PCAP_ERROR_CANTSET_TSTAMP_TYPE : constant := -10; -- /usr/include/pcap/pcap.h:255 PCAP_ERROR_PROMISC_PERM_DENIED : constant := -11; -- /usr/include/pcap/pcap.h:256 PCAP_ERROR_TSTAMP_PRECISION_NOTSUP : constant := -12; -- /usr/include/pcap/pcap.h:257 PCAP_WARNING : constant := 1; -- /usr/include/pcap/pcap.h:264 PCAP_WARNING_PROMISC_NOTSUP : constant := 2; -- /usr/include/pcap/pcap.h:265 PCAP_WARNING_TSTAMP_TYPE_NOTSUP : constant := 3; -- /usr/include/pcap/pcap.h:266 PCAP_NETMASK_UNKNOWN : constant := 16#ffffffff#; -- /usr/include/pcap/pcap.h:272 PCAP_TSTAMP_HOST : constant := 0; -- /usr/include/pcap/pcap.h:334 PCAP_TSTAMP_HOST_LOWPREC : constant := 1; -- /usr/include/pcap/pcap.h:335 PCAP_TSTAMP_HOST_HIPREC : constant := 2; -- /usr/include/pcap/pcap.h:336 PCAP_TSTAMP_ADAPTER : constant := 3; -- /usr/include/pcap/pcap.h:337 PCAP_TSTAMP_ADAPTER_UNSYNCED : constant := 4; -- /usr/include/pcap/pcap.h:338 PCAP_TSTAMP_PRECISION_MICRO : constant := 0; -- /usr/include/pcap/pcap.h:346 PCAP_TSTAMP_PRECISION_NANO : constant := 1; -- /usr/include/pcap/pcap.h:347 -- -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- -- * Copyright (c) 1993, 1994, 1995, 1996, 1997 -- * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software -- * must display the following acknowledgement: -- * This product includes software developed by the Computer Systems -- * Engineering Group at Lawrence Berkeley Laboratory. -- * 4. Neither the name of the University nor of the Laboratory may be used -- * to endorse or promote products derived from this software without -- * specific prior written permission. -- * -- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -- * SUCH DAMAGE. -- -- * Version number of the current version of the pcap file format. -- * -- * NOTE: this is *NOT* the version number of the libpcap library. -- * To fetch the version information for the version of libpcap -- * you're using, use pcap_lib_version(). -- -- * Compatibility for systems that have a bpf.h that -- * predates the bpf typedefs for 64-bit support. -- type pcap is null record; -- incomplete struct subtype pcap_t is pcap; -- /usr/include/pcap/pcap.h:79 type pcap_dumper is null record; -- incomplete struct subtype pcap_dumper_t is pcap_dumper; -- /usr/include/pcap/pcap.h:80 type pcap_if; subtype pcap_if_t is pcap_if; -- /usr/include/pcap/pcap.h:81 type pcap_addr; subtype pcap_addr_t is pcap_addr; -- /usr/include/pcap/pcap.h:82 -- * The first record in the file contains saved values for some -- * of the flags used in the printout phases of tcpdump. -- * Many fields here are 32 bit ints so compilers won't insert unwanted -- * padding; these files need to be interchangeable across architectures. -- * -- * Do not change the layout of this structure, in any way (this includes -- * changes that only affect the length of fields in this structure). -- * -- * Also, do not change the interpretation of any of the members of this -- * structure, in any way (this includes using values other than -- * LINKTYPE_ values, as defined in "savefile.c", in the "linktype" -- * field). -- * -- * Instead: -- * -- * introduce a new structure for the new format, if the layout -- * of the structure changed; -- * -- * send mail to "<EMAIL>", requesting -- * a new magic number for your new capture file format, and, when -- * you get the new magic number, put it in "savefile.c"; -- * -- * use that magic number for save files with the changed file -- * header; -- * -- * make the code in "savefile.c" capable of reading files with -- * the old file header as well as files with the new file header -- * (using the magic number to determine the header format). -- * -- * Then supply the changes by forking the branch at -- * -- * https://github.com/the-tcpdump-group/libpcap/issues -- * -- * and issuing a pull request, so that future versions of libpcap and -- * programs that use it (such as tcpdump) will be able to read your new -- * capture file format. -- type pcap_file_header is record magic : aliased unsigned; -- /usr/include/pcap/pcap.h:123 version_major : aliased unsigned_short; -- /usr/include/pcap/pcap.h:124 version_minor : aliased unsigned_short; -- /usr/include/pcap/pcap.h:125 thiszone : aliased int; -- /usr/include/pcap/pcap.h:126 sigfigs : aliased unsigned; -- /usr/include/pcap/pcap.h:127 snaplen : aliased unsigned; -- /usr/include/pcap/pcap.h:128 linktype : aliased unsigned; -- /usr/include/pcap/pcap.h:129 end record with Convention => C_Pass_By_Copy; -- /usr/include/pcap/pcap.h:122 -- gmt to local correction -- accuracy of timestamps -- max length saved portion of each pkt -- data link type (LINKTYPE_*) -- * Macros for the value returned by pcap_datalink_ext(). -- * -- * If LT_FCS_LENGTH_PRESENT(x) is true, the LT_FCS_LENGTH(x) macro -- * gives the FCS length of packets in the capture. -- type pcap_direction_t is (PCAP_D_INOUT, PCAP_D_IN, PCAP_D_OUT) with Convention => C; -- /usr/include/pcap/pcap.h:146 -- * Generic per-packet information, as supplied by libpcap. -- * -- * The time stamp can and should be a "struct timeval", regardless of -- * whether your system supports 32-bit tv_sec in "struct timeval", -- * 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit -- * and 64-bit applications. The on-disk format of savefiles uses 32-bit -- * tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit -- * and 64-bit versions of libpcap, even if they're on the same platform, -- * should supply the appropriate version of "struct timeval", even if -- * that's not what the underlying packet capture mechanism supplies. -- -- time stamp type pcap_pkthdr is record ts : aliased System.Linux.timeval; -- /usr/include/pcap/pcap.h:161 caplen : aliased unsigned; -- /usr/include/pcap/pcap.h:162 len : aliased unsigned; -- /usr/include/pcap/pcap.h:163 end record with Convention => C_Pass_By_Copy; -- /usr/include/pcap/pcap.h:160 -- length of portion present -- length this packet (off wire) -- * As returned by the pcap_stats() -- -- number of packets received type pcap_stat is record ps_recv : aliased unsigned; -- /usr/include/pcap/pcap.h:170 ps_drop : aliased unsigned; -- /usr/include/pcap/pcap.h:171 ps_ifdrop : aliased unsigned; -- /usr/include/pcap/pcap.h:172 end record with Convention => C_Pass_By_Copy; -- /usr/include/pcap/pcap.h:169 -- number of packets dropped -- drops by interface -- only supported on some platforms -- number of packets that reach the application -- * As returned by the pcap_stats_ex() -- -- total packets received -- total packets transmitted -- total bytes received -- total bytes transmitted -- bad packets received -- packet transmit problems -- no space in Rx buffers -- no space available for Tx -- multicast packets received -- detailed rx_errors: -- receiver ring buff overflow -- recv'd pkt with crc error -- recv'd frame alignment error -- recv'r fifo overrun -- recv'r missed packet -- detailed tx_errors -- * Item in a list of interfaces. -- type pcap_if is record next : access pcap_if; -- /usr/include/pcap/pcap.h:215 name : Interfaces.C.Strings.chars_ptr; -- /usr/include/pcap/pcap.h:216 description : Interfaces.C.Strings.chars_ptr; -- /usr/include/pcap/pcap.h:217 addresses : access pcap_addr; -- /usr/include/pcap/pcap.h:218 flags : aliased unsigned; -- /usr/include/pcap/pcap.h:219 end record with Convention => C_Pass_By_Copy; -- /usr/include/pcap/pcap.h:214 -- name to hand to "pcap_open_live()" -- textual description of interface, or NULL -- PCAP_IF_ interface flags -- * Representation of an interface address. -- type sockaddr; type pcap_addr is record next : access pcap_addr; -- /usr/include/pcap/pcap.h:230 addr : access sockaddr; -- /usr/include/pcap/pcap.h:231 netmask : access sockaddr; -- /usr/include/pcap/pcap.h:232 broadaddr : access sockaddr; -- /usr/include/pcap/pcap.h:233 dstaddr : access sockaddr; -- /usr/include/pcap/pcap.h:234 end record with Convention => C_Pass_By_Copy; -- /usr/include/pcap/pcap.h:229 -- address type sockaddr is null record; -- incomplete struct -- netmask for that address -- broadcast address for that address -- P2P destination address for that address type pcap_handler is access procedure (arg1 : access unsigned_char; arg2 : access constant pcap_pkthdr; arg3 : access unsigned_char) with Convention => C; -- /usr/include/pcap/pcap.h:237 -- * Error codes for the pcap API. -- * These will all be negative, so you can check for the success or -- * failure of a call that returns these codes by checking for a -- * negative value. -- -- * Warning codes for the pcap API. -- * These will all be positive and non-zero, so they won't look like -- * errors. -- -- * Value to pass to pcap_compile() as the netmask if you don't know what -- * the netmask is. -- function pcap_lookupdev (arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:274 with Import => True, Convention => C, External_Name => "pcap_lookupdev"; function pcap_lookupnet (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : access unsigned; arg3 : access unsigned; arg4 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:275 with Import => True, Convention => C, External_Name => "pcap_lookupnet"; function pcap_create (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:277 with Import => True, Convention => C, External_Name => "pcap_create"; function pcap_set_snaplen (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:278 with Import => True, Convention => C, External_Name => "pcap_set_snaplen"; function pcap_set_promisc (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:279 with Import => True, Convention => C, External_Name => "pcap_set_promisc"; function pcap_can_set_rfmon (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:280 with Import => True, Convention => C, External_Name => "pcap_can_set_rfmon"; function pcap_set_rfmon (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:281 with Import => True, Convention => C, External_Name => "pcap_set_rfmon"; function pcap_set_timeout (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:282 with Import => True, Convention => C, External_Name => "pcap_set_timeout"; function pcap_set_tstamp_type (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:283 with Import => True, Convention => C, External_Name => "pcap_set_tstamp_type"; function pcap_set_immediate_mode (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:284 with Import => True, Convention => C, External_Name => "pcap_set_immediate_mode"; function pcap_set_buffer_size (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:285 with Import => True, Convention => C, External_Name => "pcap_set_buffer_size"; function pcap_set_tstamp_precision (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:286 with Import => True, Convention => C, External_Name => "pcap_set_tstamp_precision"; function pcap_get_tstamp_precision (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:287 with Import => True, Convention => C, External_Name => "pcap_get_tstamp_precision"; function pcap_activate (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:288 with Import => True, Convention => C, External_Name => "pcap_activate"; function pcap_list_tstamp_types (arg1 : access pcap_t; arg2 : System.Address) return int -- /usr/include/pcap/pcap.h:290 with Import => True, Convention => C, External_Name => "pcap_list_tstamp_types"; procedure pcap_free_tstamp_types (arg1 : access int) -- /usr/include/pcap/pcap.h:291 with Import => True, Convention => C, External_Name => "pcap_free_tstamp_types"; function pcap_tstamp_type_name_to_val (arg1 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:292 with Import => True, Convention => C, External_Name => "pcap_tstamp_type_name_to_val"; function pcap_tstamp_type_val_to_name (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:293 with Import => True, Convention => C, External_Name => "pcap_tstamp_type_val_to_name"; function pcap_tstamp_type_val_to_description (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:294 with Import => True, Convention => C, External_Name => "pcap_tstamp_type_val_to_description"; -- * Time stamp types. -- * Not all systems and interfaces will necessarily support all of these. -- * -- * A system that supports PCAP_TSTAMP_HOST is offering time stamps -- * provided by the host machine, rather than by the capture device, -- * but not committing to any characteristics of the time stamp; -- * it will not offer any of the PCAP_TSTAMP_HOST_ subtypes. -- * -- * PCAP_TSTAMP_HOST_LOWPREC is a time stamp, provided by the host machine, -- * that's low-precision but relatively cheap to fetch; it's normally done -- * using the system clock, so it's normally synchronized with times you'd -- * fetch from system calls. -- * -- * PCAP_TSTAMP_HOST_HIPREC is a time stamp, provided by the host machine, -- * that's high-precision; it might be more expensive to fetch. It might -- * or might not be synchronized with the system clock, and might have -- * problems with time stamps for packets received on different CPUs, -- * depending on the platform. -- * -- * PCAP_TSTAMP_ADAPTER is a high-precision time stamp supplied by the -- * capture device; it's synchronized with the system clock. -- * -- * PCAP_TSTAMP_ADAPTER_UNSYNCED is a high-precision time stamp supplied by -- * the capture device; it's not synchronized with the system clock. -- * -- * Note that time stamps synchronized with the system clock can go -- * backwards, as the system clock can go backwards. If a clock is -- * not in sync with the system clock, that could be because the -- * system clock isn't keeping accurate time, because the other -- * clock isn't keeping accurate time, or both. -- * -- * Note that host-provided time stamps generally correspond to the -- * time when the time-stamping code sees the packet; this could -- * be some unknown amount of time after the first or last bit of -- * the packet is received by the network adapter, due to batching -- * of interrupts for packet arrival, queueing delays, etc.. -- -- * Time stamp resolution types. -- * Not all systems and interfaces will necessarily support all of these -- * resolutions when doing live captures; all of them can be requested -- * when reading a savefile. -- function pcap_open_live (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : int; arg3 : int; arg4 : int; arg5 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:349 with Import => True, Convention => C, External_Name => "pcap_open_live"; function pcap_open_dead (arg1 : int; arg2 : int) return access pcap_t -- /usr/include/pcap/pcap.h:350 with Import => True, Convention => C, External_Name => "pcap_open_dead"; function pcap_open_dead_with_tstamp_precision (arg1 : int; arg2 : int; arg3 : unsigned) return access pcap_t -- /usr/include/pcap/pcap.h:351 with Import => True, Convention => C, External_Name => "pcap_open_dead_with_tstamp_precision"; function pcap_open_offline_with_tstamp_precision (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : unsigned; arg3 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:352 with Import => True, Convention => C, External_Name => "pcap_open_offline_with_tstamp_precision"; function pcap_open_offline (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:353 with Import => True, Convention => C, External_Name => "pcap_open_offline"; function pcap_fopen_offline_with_tstamp_precision (arg1 : access Interfaces.C_Streams.FILEs; arg2 : unsigned; arg3 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:367 with Import => True, Convention => C, External_Name => "pcap_fopen_offline_with_tstamp_precision"; function pcap_fopen_offline (arg1 : access Interfaces.C_Streams.FILEs; arg2 : Interfaces.C.Strings.chars_ptr) return access pcap_t -- /usr/include/pcap/pcap.h:368 with Import => True, Convention => C, External_Name => "pcap_fopen_offline"; procedure pcap_close (arg1 : access pcap_t) -- /usr/include/pcap/pcap.h:371 with Import => True, Convention => C, External_Name => "pcap_close"; function pcap_loop (arg1 : access pcap_t; arg2 : int; arg3 : pcap_handler; arg4 : access unsigned_char) return int -- /usr/include/pcap/pcap.h:372 with Import => True, Convention => C, External_Name => "pcap_loop"; function pcap_dispatch (arg1 : access pcap_t; arg2 : int; arg3 : pcap_handler; arg4 : access unsigned_char) return int -- /usr/include/pcap/pcap.h:373 with Import => True, Convention => C, External_Name => "pcap_dispatch"; function pcap_next (arg1 : access pcap_t; arg2 : access pcap_pkthdr) return access unsigned_char -- /usr/include/pcap/pcap.h:375 with Import => True, Convention => C, External_Name => "pcap_next"; function pcap_next_ex (arg1 : access pcap_t; arg2 : System.Address; arg3 : System.Address) return int -- /usr/include/pcap/pcap.h:376 with Import => True, Convention => C, External_Name => "pcap_next_ex"; procedure pcap_breakloop (arg1 : access pcap_t) -- /usr/include/pcap/pcap.h:377 with Import => True, Convention => C, External_Name => "pcap_breakloop"; function pcap_stats (arg1 : access pcap_t; arg2 : access pcap_stat) return int -- /usr/include/pcap/pcap.h:378 with Import => True, Convention => C, External_Name => "pcap_stats"; function pcap_setfilter (arg1 : access pcap_t; arg2 : access pcap_bpf_h.bpf_program) return int -- /usr/include/pcap/pcap.h:379 with Import => True, Convention => C, External_Name => "pcap_setfilter"; function pcap_setdirection (arg1 : access pcap_t; arg2 : pcap_direction_t) return int -- /usr/include/pcap/pcap.h:380 with Import => True, Convention => C, External_Name => "pcap_setdirection"; function pcap_getnonblock (arg1 : access pcap_t; arg2 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:381 with Import => True, Convention => C, External_Name => "pcap_getnonblock"; function pcap_setnonblock (arg1 : access pcap_t; arg2 : int; arg3 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:382 with Import => True, Convention => C, External_Name => "pcap_setnonblock"; function pcap_inject (arg1 : access pcap_t; arg2 : System.Address; arg3 : size_t) return int -- /usr/include/pcap/pcap.h:383 with Import => True, Convention => C, External_Name => "pcap_inject"; function pcap_sendpacket (arg1 : access pcap_t; arg2 : access unsigned_char; arg3 : int) return int -- /usr/include/pcap/pcap.h:384 with Import => True, Convention => C, External_Name => "pcap_sendpacket"; function pcap_statustostr (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:385 with Import => True, Convention => C, External_Name => "pcap_statustostr"; function pcap_strerror (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:386 with Import => True, Convention => C, External_Name => "pcap_strerror"; function pcap_geterr (arg1 : access pcap_t) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:387 with Import => True, Convention => C, External_Name => "pcap_geterr"; procedure pcap_perror (arg1 : access pcap_t; arg2 : Interfaces.C.Strings.chars_ptr) -- /usr/include/pcap/pcap.h:388 with Import => True, Convention => C, External_Name => "pcap_perror"; function pcap_compile (arg1 : access pcap_t; arg2 : access pcap_bpf_h.bpf_program; arg3 : Interfaces.C.Strings.chars_ptr; arg4 : int; arg5 : unsigned) return int -- /usr/include/pcap/pcap.h:389 with Import => True, Convention => C, External_Name => "pcap_compile"; function pcap_compile_nopcap (arg1 : int; arg2 : int; arg3 : access pcap_bpf_h.bpf_program; arg4 : Interfaces.C.Strings.chars_ptr; arg5 : int; arg6 : unsigned) return int -- /usr/include/pcap/pcap.h:391 with Import => True, Convention => C, External_Name => "pcap_compile_nopcap"; procedure pcap_freecode (arg1 : access pcap_bpf_h.bpf_program) -- /usr/include/pcap/pcap.h:393 with Import => True, Convention => C, External_Name => "pcap_freecode"; function pcap_offline_filter (arg1 : access constant pcap_bpf_h.bpf_program; arg2 : access constant pcap_pkthdr; arg3 : access unsigned_char) return int -- /usr/include/pcap/pcap.h:394 with Import => True, Convention => C, External_Name => "pcap_offline_filter"; function pcap_datalink (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:396 with Import => True, Convention => C, External_Name => "pcap_datalink"; function pcap_datalink_ext (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:397 with Import => True, Convention => C, External_Name => "pcap_datalink_ext"; function pcap_list_datalinks (arg1 : access pcap_t; arg2 : System.Address) return int -- /usr/include/pcap/pcap.h:398 with Import => True, Convention => C, External_Name => "pcap_list_datalinks"; function pcap_set_datalink (arg1 : access pcap_t; arg2 : int) return int -- /usr/include/pcap/pcap.h:399 with Import => True, Convention => C, External_Name => "pcap_set_datalink"; procedure pcap_free_datalinks (arg1 : access int) -- /usr/include/pcap/pcap.h:400 with Import => True, Convention => C, External_Name => "pcap_free_datalinks"; function pcap_datalink_name_to_val (arg1 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:401 with Import => True, Convention => C, External_Name => "pcap_datalink_name_to_val"; function pcap_datalink_val_to_name (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:402 with Import => True, Convention => C, External_Name => "pcap_datalink_val_to_name"; function pcap_datalink_val_to_description (arg1 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:403 with Import => True, Convention => C, External_Name => "pcap_datalink_val_to_description"; function pcap_snapshot (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:404 with Import => True, Convention => C, External_Name => "pcap_snapshot"; function pcap_is_swapped (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:405 with Import => True, Convention => C, External_Name => "pcap_is_swapped"; function pcap_major_version (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:406 with Import => True, Convention => C, External_Name => "pcap_major_version"; function pcap_minor_version (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:407 with Import => True, Convention => C, External_Name => "pcap_minor_version"; -- XXX function pcap_file (arg1 : access pcap_t) return access Interfaces.C_Streams.FILEs -- /usr/include/pcap/pcap.h:410 with Import => True, Convention => C, External_Name => "pcap_file"; function pcap_fileno (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:411 with Import => True, Convention => C, External_Name => "pcap_fileno"; function pcap_dump_open (arg1 : access pcap_t; arg2 : Interfaces.C.Strings.chars_ptr) return access pcap_dumper_t -- /usr/include/pcap/pcap.h:413 with Import => True, Convention => C, External_Name => "pcap_dump_open"; function pcap_dump_fopen (arg1 : access pcap_t; fp : access Interfaces.C_Streams.FILEs) return access pcap_dumper_t -- /usr/include/pcap/pcap.h:414 with Import => True, Convention => C, External_Name => "pcap_dump_fopen"; function pcap_dump_file (arg1 : access pcap_dumper_t) return access Interfaces.C_Streams.FILEs -- /usr/include/pcap/pcap.h:415 with Import => True, Convention => C, External_Name => "pcap_dump_file"; function pcap_dump_ftell (arg1 : access pcap_dumper_t) return long -- /usr/include/pcap/pcap.h:416 with Import => True, Convention => C, External_Name => "pcap_dump_ftell"; function pcap_dump_flush (arg1 : access pcap_dumper_t) return int -- /usr/include/pcap/pcap.h:417 with Import => True, Convention => C, External_Name => "pcap_dump_flush"; procedure pcap_dump_close (arg1 : access pcap_dumper_t) -- /usr/include/pcap/pcap.h:418 with Import => True, Convention => C, External_Name => "pcap_dump_close"; procedure pcap_dump (arg1 : access unsigned_char; arg2 : access constant pcap_pkthdr; arg3 : access unsigned_char) -- /usr/include/pcap/pcap.h:419 with Import => True, Convention => C, External_Name => "pcap_dump"; function pcap_findalldevs (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr) return int -- /usr/include/pcap/pcap.h:421 with Import => True, Convention => C, External_Name => "pcap_findalldevs"; procedure pcap_freealldevs (arg1 : access pcap_if_t) -- /usr/include/pcap/pcap.h:422 with Import => True, Convention => C, External_Name => "pcap_freealldevs"; function pcap_lib_version return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:424 with Import => True, Convention => C, External_Name => "pcap_lib_version"; -- * On at least some versions of NetBSD, we don't want to declare -- * bpf_filter() here, as it's also be declared in <net/bpf.h>, with a -- * different signature, but, on other BSD-flavored UN*Xes, it's not -- * declared in <net/bpf.h>, so we *do* want to declare it here, so it's -- * declared when we build pcap-bpf.c. -- function bpf_filter (arg1 : access constant pcap_bpf_h.bpf_insn; arg2 : access unsigned_char; arg3 : unsigned; arg4 : unsigned) return unsigned -- /usr/include/pcap/pcap.h:434 with Import => True, Convention => C, External_Name => "bpf_filter"; function bpf_validate (arg1 : access constant pcap_bpf_h.bpf_insn; arg2 : int) return int -- /usr/include/pcap/pcap.h:436 with Import => True, Convention => C, External_Name => "bpf_validate"; function bpf_image (arg1 : access constant pcap_bpf_h.bpf_insn; arg2 : int) return Interfaces.C.Strings.chars_ptr -- /usr/include/pcap/pcap.h:437 with Import => True, Convention => C, External_Name => "bpf_image"; procedure bpf_dump (arg1 : access constant pcap_bpf_h.bpf_program; arg2 : int) -- /usr/include/pcap/pcap.h:438 with Import => True, Convention => C, External_Name => "bpf_dump"; -- * Win32 definitions -- -- Include file with the wpcap-specific extensions -- * MS-DOS definitions -- -- * UN*X definitions -- function pcap_get_selectable_fd (arg1 : access pcap_t) return int -- /usr/include/pcap/pcap.h:476 with Import => True, Convention => C, External_Name => "pcap_get_selectable_fd"; end PCAP.Low_Level.pcap_pcap_h; -- end read only
29,986
ada
1
ForYouEyesOnly/Space-Convoy
Sources/Globe_3d/objects/globe_3d-tri_mesh-vbo.adb
pragma Warnings (Off); pragma Style_Checks (Off); with GLOBE_3D.Options, GLOBE_3D.Textures, GLOBE_3D.Math; with GL.Buffer.vertex; with GL.Buffer.indices; with GL.Buffer.texture_coords; with Ada.Exceptions; use Ada.Exceptions; with ada.text_io; use ada.text_io; with ada.unchecked_Conversion; with System; package body GLOBE_3D.tri_Mesh.vbo is use GLOBE_3D.Options; package G3DT renames GLOBE_3D.Textures; package G3DM renames GLOBE_3D.Math; procedure destroy (o : in out tri_Mesh) is use GL.skinned_geometry; begin destroy (o.skinned_Geometry); end; function skinned_Geometrys (o : in tri_Mesh) return GL.skinned_geometry.skinned_Geometrys is begin return (1 => o.skinned_Geometry); end; procedure set_Alpha (o : in out tri_Mesh; Alpha : in GL.Double) is begin null; -- tbd: end; function is_Transparent (o : in tri_Mesh) return Boolean is use type GL.Double; begin return o.skinned_Geometry.Skin.is_Transparent; end; procedure Pre_calculate (o : in out tri_Mesh) is use GL, G3DM; begin null; -- tbd: end Pre_calculate; procedure Display (o : in out tri_Mesh; clip : in Clipping_data) is begin null; end Display; procedure set_Vertices (Self : in out tri_Mesh; To : access GL.geometry.GL_vertex_Array) is use GL.Buffer.vertex, GL.Geometry, GL.Geometry.vbo; the_Geometry : GL.geometry.vbo.vbo_Geometry renames GL.geometry.vbo.vbo_Geometry (self.skinned_geometry.Geometry.all); begin the_Geometry.Vertices := to_Buffer (To, usage => GL.static_draw); -- tbd : check usage the_Geometry.vertex_Count := GL.SizeI (To'Length); the_Geometry.Bounds := Bounds (To.all); end; procedure set_Indices (Self : in out tri_Mesh; To : access GL.geometry.vertex_Id_array) is use GL.Buffer.indices, GL.Geometry, GL.Geometry.vbo; the_Geometry : GL.geometry.vbo.vbo_Geometry renames GL.geometry.vbo.vbo_Geometry (self.skinned_geometry.Geometry.all); begin the_Geometry.indices_Count := GL.SizeI (To'Length); the_Geometry.Indices := to_Buffer (To, usage => GL.static_draw); end; procedure Skin_is (o : in out tri_Mesh; Now : in GL.skins.p_Skin) is begin o.skinned_Geometry.Skin := Now; o.skinned_Geometry.Veneer := Now.all.new_Veneer (for_geometry => o.skinned_Geometry.Geometry.all); end; function face_Count (o : in tri_Mesh) return Natural is use GL; the_Geometry : GL.geometry.vbo.vbo_Geometry renames GL.geometry.vbo.vbo_Geometry (o.skinned_geometry.Geometry.all); begin return Natural (the_Geometry.indices_Count / 3); end; function Bounds (o : in tri_Mesh) return GL.geometry.Bounds_record is begin return o.skinned_geometry.Geometry.Bounds; end; end GLOBE_3D.tri_Mesh.vbo;
29,987
ada
10
LionelDraghi/smk
src/smk-runs-must_be_run.adb
<reponame>LionelDraghi/smk -- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 <NAME> <<EMAIL>> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- 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 File_Utilities; with Smk.IO; with Smk.Settings; use Smk.Settings; separate (Smk.Runs) -- ----------------------------------------------------------------------------- function Must_Be_Run (Command : in Command_Lines; Previous_Run : in out Runfiles.Run_Lists.Map) return Boolean is -- -------------------------------------------------------------------------- procedure Put_Explanation (Text : in String) is begin if Settings.Explain then IO.Put_Line ("run """ & (+Command) & """ " & Text); end if; end Put_Explanation; use Runfiles; use Run_Lists; C : Run_Lists.Cursor; Updated_List : Condition_Lists.List; -- -------------------------------------------------------------------------- function Assert (C : Condition) return Boolean is Role : constant String := Role_Image (Files.Role (C.File)) & " "; Because : constant String := "because " & Role & (if Is_Dir (C.File) then "dir " else "file ") & Shorten (C.Name); Status : File_Status renames Files.Status (C.File); File_Exists : constant Boolean := Status /= Missing; Is_The_Target : constant Boolean := Has_Target (C.Name, Settings.Target_Name); -- Is_The_Target is True if C.Name is the target explicitly given -- on command line. begin if File_Exists and C.Trigger = File_Update and Status = Updated then -- -------------------------------------------------------------------- Put_Explanation (Because & " has been updated (" & IO.Image (Time_Tag (C.File)) & ")"); return False; elsif not File_Exists and C.Trigger = File_Absence and (Is_Target (C.File) and (Settings.Build_Missing_Targets or Is_The_Target)) -- if target and : -- - -mt option used, or -- - this target is explicitly given on command line then -- ----------------------------------------------------------------- Put_Explanation (Because & " is missing"); return False; elsif File_Exists and C.Trigger = File_Presence then -- -------------------------------------------------------------------- Put_Explanation (Because & " is present"); return False; else -- -------------------------------------------------------------------- -- assertions are OK return True; end if; end Assert; begin -- -------------------------------------------------------------------------- if Always_Make then -- don't even ask, run it! Put_Explanation ("because -a option is set"); return True; end if; C := Previous_Run.Find (Command); if C = No_Element then -- never run command Put_Explanation ("because it was not run before"); return True; end if; Update_Files_Status (Previous_Run (C).Assertions, Updated_List); if Debug_Mode then Put_Updated (Updated_List); end if; -- for P of Element (C).Assertions loop if not Assert (P) then return True; end if; end loop; return False; end Must_Be_Run;
29,988
ada
1
ForYouEyesOnly/Space-Convoy
Sources/Graphics/graphics_framerates.adb
-- -- Jan & <NAME>, Australia, July 2011 -- package body Graphics_FrameRates is type Ring_Ix is mod Smoothing_Buffer_Size; Smoothing_Buffer : array (Ring_Ix) of Time_Span := (others => Seconds (1)); Smoothing_Buffer_Ix : Ring_Ix := Ring_Ix'First; Last_Call_To_Limiter : Time := Clock; Last_Padding_Delay : Time_Span := Time_Span_Zero; Last_Call_To_Measure_Interval : Time := Clock; -- -- -- function Measure_Interval return Time_Span is Interval : constant Time_Span := Clock - Last_Call_To_Measure_Interval; begin Last_Call_To_Measure_Interval := Clock; return Interval; end Measure_Interval; ----------------------- -- Average_Framerate -- ----------------------- function Average_Framerate (Interval : Time_Span) return Hz is Interval_Sum : Time_Span := Time_Span_Zero; begin Smoothing_Buffer (Smoothing_Buffer_Ix) := Interval; Smoothing_Buffer_Ix := Smoothing_Buffer_Ix + 1; for i in Ring_Ix'Range loop Interval_Sum := Interval_Sum + Smoothing_Buffer (i); end loop; if Interval_Sum = Time_Span_Zero then return 0.0; else return 1.0 / Real (To_Duration (Interval_Sum / Smoothing_Buffer_Size)); end if; end Average_Framerate; -- -- -- procedure Framerate_Limiter (Max_Framerate : Hz) is Intended_Time_Span : constant Time_Span := To_Time_Span (Duration (1.0 / Max_Framerate)); Actual_Execution_Time : constant Time_Span := (Clock - Last_Call_To_Limiter) - Last_Padding_Delay; Padding_Delay : Time_Span := Intended_Time_Span - Actual_Execution_Time; begin if Padding_Delay > Intended_Time_Span then Padding_Delay := Intended_Time_Span; elsif Padding_Delay < -Intended_Time_Span then Padding_Delay := -Intended_Time_Span; end if; Last_Call_To_Limiter := Clock; Last_Padding_Delay := Padding_Delay; delay To_Duration (Padding_Delay); end Framerate_Limiter; end Graphics_FrameRates;
29,989
ada
1
LaudateCorpus1/RosettaCodeData
Task/Substring/Ada/substring-2.ada
<gh_stars>1-10 A (<first-index>..<last-index>)
29,990
ada
80
enfoTek/tomato.linksys.e2000.nvram-mod
tools-src/gnu/gcc/gcc/ada/s-stoele.ads
<filename>tools-src/gnu/gcc/gcc/ada/s-stoele.ads ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S T O R A G E _ E L E M E N T S -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- Warning: declarations in this package are ambiguous with respect to the -- extra declarations that can be introduced into System using Extend_System. -- It is a good idea to avoid use clauses for this package! pragma Warnings (Off); -- This is to stop bootstrap problems with the use of Inline_Always -- To be removed (along with redundant Inline pragmas) in 3.13. package System.Storage_Elements is pragma Pure (Storage_Elements); -- Note that we take advantage of the implementation permission to make -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). type Storage_Offset is range -(2 ** (Standard."-" (Standard'Address_Size, 1))) .. +(2 ** (Standard."-" (Standard'Address_Size, 1))) - 1; -- Note: the reason for the qualification of "-" here by Standard is -- that we have a current bug in GNAT that otherwise causes a bogus -- ambiguity when this unit is analyzed in an Rtsfind context. subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last; type Storage_Element is mod 2 ** Storage_Unit; for Storage_Element'Size use Storage_Unit; type Storage_Array is array (Storage_Offset range <>) of aliased Storage_Element; for Storage_Array'Component_Size use Storage_Unit; -- Address arithmetic function "+" (Left : Address; Right : Storage_Offset) return Address; pragma Convention (Intrinsic, "+"); pragma Inline ("+"); pragma Inline_Always ("+"); function "+" (Left : Storage_Offset; Right : Address) return Address; pragma Convention (Intrinsic, "+"); pragma Inline ("+"); pragma Inline_Always ("+"); function "-" (Left : Address; Right : Storage_Offset) return Address; pragma Convention (Intrinsic, "-"); pragma Inline ("-"); pragma Inline_Always ("-"); function "-" (Left, Right : Address) return Storage_Offset; pragma Convention (Intrinsic, "-"); pragma Inline ("-"); pragma Inline_Always ("-"); function "mod" (Left : Address; Right : Storage_Offset) return Storage_Offset; pragma Convention (Intrinsic, "mod"); pragma Inline ("mod"); pragma Inline_Always ("mod"); -- Conversion to/from integers type Integer_Address is mod Memory_Size; function To_Address (Value : Integer_Address) return Address; pragma Convention (Intrinsic, To_Address); pragma Inline (To_Address); pragma Inline_Always (To_Address); function To_Integer (Value : Address) return Integer_Address; pragma Convention (Intrinsic, To_Integer); pragma Inline (To_Integer); pragma Inline_Always (To_Integer); end System.Storage_Elements;
29,991
ada
19
jrcarter/Ada_GUI
ada_gui-gnoga-server-model.ads
<reponame>jrcarter/Ada_GUI<gh_stars>10-100 -- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . S E R V E R . M O D E L -- -- -- -- S p e c -- -- -- -- -- -- Copyright (C) 2014 <NAME> -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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/>. -- -- -- -- 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. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ -- An Active Record implementation for Ada similar to that used in Rails with Ada.Finalization; with Ada.Calendar; with Ada_GUI.Gnoga.Server.Database; package Ada_GUI.Gnoga.Server.Model is type Active_Record (Table_Name : access constant String; Connection : access Gnoga.Server.Database.Connection'Class) is new Ada.Finalization.Controlled with private; overriding procedure Initialize (Object : in out Active_Record); function Field_Names (A : Active_Record) return Gnoga.Data_Array_Type; -- Returns the Field Names supported by this Active_Record procedure Values (A : in out Active_Record; Map : in Gnoga.Data_Map_Type); -- Set table values from Map ignoring any extra key/value pairs in Map -- not found in record schema function Values (A : Active_Record) return Gnoga.Data_Map_Type; -- Return all values in record procedure Value (A : in out Active_Record; Field_Name : in String; Value : in String); -- Set value for Field_Name procedure Value (A : in out Active_Record; Field_Name : in String; Integer_Value : in Integer); -- Set value for Field_Name procedure Value (A : in out Active_Record; Field_Name : in String; Date_Value : in Ada.Calendar.Time); -- Set value for Field_Name function Value (A : Active_Record; Field_Name : String) return String; -- Return value for field_name function Exists (A : Active_Record; Field_Name : String) return Boolean; -- Checks for the presence of Field_Name in record procedure Save (A : in out Active_Record); -- Save values to row, if not the result of a find create new record procedure Delete (A : in out Active_Record); -- Delete this row procedure Clear (A : in out Active_Record); -- Clears the Active Record and mark as a new row procedure Find (A : in out Active_Record; ID : in Positive); -- Load row with ID procedure Find (A : in out Active_Record; ID : in String); -- Load row with ID, this version of Find accepts the ID as a string -- ID must be a valid integer procedure Find_Where (A : in out Active_Record; Where : in String; Create_New : in Boolean := True); -- Load row based on where clause, note that only the first record -- returned will be loaded. Use Model.Queries.Find_All for -- return of multiple records. If Create_New is true then no exception -- is thrown if the record is not found. Checking if Value ("id") -- is empty, i.e. is a new record would confirm no results found. procedure Find_Item (A : in out Active_Record; Parent : in Active_Record'Class; Create_New : in Boolean := True); -- Return first matching record in Child Table A where: -- Child_Table.PARENT_TABLE_NAME(with out s)_id = Child_Table.id private type Active_Record (Table_Name : access constant String; Connection : access Gnoga.Server.Database.Connection'Class) is new Ada.Finalization.Controlled with record Is_New : Boolean := True; Fields : Gnoga.Data_Array_Type; Values : Gnoga.Data_Map_Type; end record; end Ada_GUI.Gnoga.Server.Model;
29,992
ada
24
svn2github/matreshka
source/amf/mof/amf-internals-listener_registry.adb
<filename>source/amf/mof/amf-internals-listener_registry.adb ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2013, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Containers.Vectors; package body AMF.Internals.Listener_Registry is use type AMF.Elements.Element_Access; type Registry_Record is record Listener : AMF.Listeners.Listener_Access; Instance : AMF.Elements.Element_Access; end record; package Listener_Vectors is new Ada.Containers.Vectors (Positive, Registry_Record); Registry : Listener_Vectors.Vector; -------------------------- -- Notify_Attribute_Set -- -------------------------- procedure Notify_Attribute_Set (Element : not null AMF.Elements.Element_Access; Property : not null AMF.CMOF.Properties.CMOF_Property_Access; Position : Optional_Integer; Old_Value : League.Holders.Holder; New_Value : League.Holders.Holder) is Aux : Listener_Vectors.Vector := Registry; begin -- Notify element itself. if Element.all in AMF.Listeners.Abstract_Listener'Class then AMF.Listeners.Abstract_Listener'Class (Element.all).Attribute_Set (Element, Property, Position, Old_Value, New_Value); end if; -- Notify registered listeners. for Item of Aux loop if Item.Instance = null or Element = Item.Instance then Item.Listener.Attribute_Set (Element, Property, Position, Old_Value, New_Value); end if; end loop; end Notify_Attribute_Set; -------------------------- -- Notify_Extent_Create -- -------------------------- procedure Notify_Extent_Create (Extent : not null AMF.Extents.Extent_Access) is Aux : Listener_Vectors.Vector := Registry; begin for Item of Aux loop if Item.Instance = null then Item.Listener.Extent_Create (Extent); end if; end loop; end Notify_Extent_Create; ---------------------------- -- Notify_Instance_Create -- ---------------------------- procedure Notify_Instance_Create (Element : not null AMF.Elements.Element_Access) is Aux : Listener_Vectors.Vector := Registry; begin for Item of Aux loop if Item.Instance = null then Item.Listener.Instance_Create (Element); end if; end loop; end Notify_Instance_Create; --------------------- -- Notify_Link_Add -- --------------------- procedure Notify_Link_Add (Association : not null AMF.CMOF.Associations.CMOF_Association_Access; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) is Aux : Listener_Vectors.Vector := Registry; begin -- Notify elements itself. if First_Element.all in AMF.Listeners.Abstract_Listener'Class then AMF.Listeners.Abstract_Listener'Class (First_Element.all).Link_Add (Association, First_Element, Second_Element); end if; if Second_Element.all in AMF.Listeners.Abstract_Listener'Class then AMF.Listeners.Abstract_Listener'Class (Second_Element.all).Link_Add (Association, First_Element, Second_Element); end if; -- Notify registered listeners. for Item of Aux loop if Item.Instance = null or First_Element = Item.Instance or Second_Element = Item.Instance then Item.Listener.Link_Add (Association, First_Element, Second_Element); end if; end loop; end Notify_Link_Add; -------------------------------- -- Register_Instance_Listener -- -------------------------------- procedure Register_Instance_Listener (Listener : not null AMF.Listeners.Listener_Access; Instance : not null AMF.Elements.Element_Access) is begin Registry.Append ((Listener, Instance)); end Register_Instance_Listener; ----------------------- -- Register_Listener -- ----------------------- procedure Register_Listener (Listener : not null AMF.Listeners.Listener_Access) is begin Registry.Append ((Listener, null)); end Register_Listener; end AMF.Internals.Listener_Registry;
29,993
ada
488
ouankou/rose
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/simple_select_accept.adb
<filename>tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/simple_select_accept.adb ----------------------------------------------------------- -- This program asks the user to enter a character, -- preferably a 'c' or a 't'. The resultant behavior -- (conditional or timed) depends on the character entered -- and the time it is entered. -- Taken from http://www.cs.uni.edu//~mccormic/AdaEssentials/select_statement.htm ----------------------------------------------------------- procedure Simple_Select_Accept(Ch : Character) is task Callee is entry Do_This; entry Do_That; entry Do_Nothing; end Callee; task body Callee is begin delay 5.0; select -- Selective Accept accept Do_This do null; end Do_This; or accept Do_That do null; end Do_That; or delay 5.0; null; end select; select -- Selective accept with terminate accept Do_this do null; end Do_This; or terminate; end select; accept Do_Nothing; end Callee; begin -- Caller executable part if Ch = 'c' then -- Conditional Entry Call select Callee.Do_This; else null; end select; elsif Ch = 't' then -- Timed Entry Call select Callee.Do_That; or delay 3.0; null; end select; else null; end if; Callee.Do_Nothing; -- Both tasks can quit end Simple_Select_Accept;
29,994
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array18_pkg.ads
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array18_pkg.ads package Array18_Pkg is function N return Positive; subtype S is String (1 .. N); function F return S; end Array18_Pkg;
29,995
ada
6
darkestkhan/cbap
tests/src/cbap_inputs_detection.adb
pragma License (GPL); ------------------------------------------------------------------------------ -- EMAIL: <<EMAIL>> -- -- License: GNU GPLv3 or any later as published by Free Software Foundation -- -- (see COPYING file) -- -- -- -- Copyright © 2015 darkestkhan -- ------------------------------------------------------------------------------ -- This Program is Free Software: You can redistribute it and/or modify -- -- it under the terms of The GNU General Public License as published by -- -- the Free Software Foundation, either version 3 of the license, or -- -- (at Your option) any later version. -- -- -- -- This Program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the -- -- GNU General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this program. If not, see <http://www.gnu.org/licenses/>. -- ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Text_IO; with CBAP; procedure CBAP_Inputs_Detection is --------------------------------------------------------------------------- -- Dummy callback. procedure Help (Argument : in String) is null; --------------------------------------------------------------------------- Input_Args : constant array (Positive range <>) of access String := ( new String'("doing"), new String'("----"), new String'("--"), new String'("help"), new String'("done") ); --------------------------------------------------------------------------- Error_Count : Natural := 0; Detected_Inputs : Natural := 0; procedure Check_Args (Position : in CBAP.Argument_Lists.Cursor) is --------------------------------------------------------------------------- function Is_Correct_Input_Arg (Arg : in String) return Boolean is begin for K in Input_Args'Range loop if Input_Args (K).all = Arg then return True; end if; end loop; Ada.Text_IO.Put_Line ("Detected wrong argument: " & Arg); return False; end Is_Correct_Input_Arg; --------------------------------------------------------------------------- begin if not Is_Correct_Input_Arg (CBAP.Argument_Lists.Element (Position)) then Error_Count := Error_Count + 1; else Detected_Inputs := Detected_Inputs + 1; end if; end Check_Args; --------------------------------------------------------------------------- begin CBAP.Register (Help'Unrestricted_Access, "help"); CBAP.Process_Arguments; CBAP.Input_Arguments.Iterate (Check_Args'Unrestricted_Access); if Detected_Inputs /= Input_Args'Length then Error_Count := Error_Count + 1; end if; if Error_Count > 0 then Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); else Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); end if; end CBAP_Inputs_Detection;
29,996
ada
0
My-Colaborations/ada-asf
src/asf-views-facelets.ads
----------------------------------------------------------------------- -- asf-views-facelets -- Facelets representation and management -- Copyright (C) 2009, 2010, 2011, 2014, 2015, 2019 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; with ASF.Views.Nodes; with ASF.Contexts.Facelets; with ASF.Factory; with ASF.Components.Base; with Ada.Finalization; private with Ada.Strings.Unbounded; private with Ada.Containers.Hashed_Sets; private with Util.Refs; private with Ada.Strings.Hash; -- The <b>ASF.Views.Facelets</b> package contains the facelet factory -- responsible for getting the facelet tree from a facelet name. -- The facelets (or *.xhtml) files are loaded by the reader to form -- a tag node tree which is cached by the factory. The facelet factory -- is shared by multiple requests and threads. package ASF.Views.Facelets is type Facelet is private; -- Returns True if the facelet is null/empty. function Is_Null (F : Facelet) return Boolean; -- ------------------------------ -- Facelet factory -- ------------------------------ -- The facelet factory allows to retrieve the node tree to build the -- component tree. The node tree can be shared by several component trees. -- The node tree is initialized from the <b>XHTML</b> view file. It is put -- in a cache to avoid loading and parsing the file several times. type Facelet_Factory is limited private; -- Get the facelet identified by the given name. If the facelet is already -- loaded, the cached value is returned. The facelet file is searched in -- a set of directories configured in the facelet factory. procedure Find_Facelet (Factory : in out Facelet_Factory; Name : in String; Context : in ASF.Contexts.Facelets.Facelet_Context'Class; Result : out Facelet); -- Create the component tree from the facelet view. procedure Build_View (View : in Facelet; Context : in out ASF.Contexts.Facelets.Facelet_Context'Class; Root : in ASF.Components.Base.UIComponent_Access); -- Initialize the facelet factory. -- Set the search directories for facelet files. -- Set the ignore white space configuration when reading XHTML files. -- Set the ignore empty lines configuration when reading XHTML files. -- Set the escape unknown tags configuration when reading XHTML files. procedure Initialize (Factory : in out Facelet_Factory; Components : access ASF.Factory.Component_Factory; Paths : in String; Ignore_White_Spaces : in Boolean; Ignore_Empty_Lines : in Boolean; Escape_Unknown_Tags : in Boolean); -- Find the facelet file in one of the facelet directories. -- Returns the path to be used for reading the facelet file. function Find_Facelet_Path (Factory : in Facelet_Factory; Name : in String) return String; -- Clear the facelet cache procedure Clear_Cache (Factory : in out Facelet_Factory); private use Ada.Strings.Unbounded; CHECK_FILE_DELAY : constant := 10.0; type Facelet_Type (Len : Natural) is limited new Util.Refs.Ref_Entity with record Root : ASF.Views.Nodes.Tag_Node_Access; File : ASF.Views.File_Info_Access; Modify_Time : Ada.Calendar.Time; Check_Time : Ada.Calendar.Time; Name : String (1 .. Len); end record; type Facelet_Access is access all Facelet_Type; package Ref is new Util.Refs.Indefinite_References (Facelet_Type, Facelet_Access); type Facelet is record Facelet : Facelet_Access; end record; Empty : constant Facelet := (others => <>); function Hash (Item : in Facelet_Access) return Ada.Containers.Hash_Type is (Ada.Strings.Hash (Item.Name)); function Compare (Left, Right : in Facelet_Access) return Boolean is (Left.Name = Right.Name); -- Tag library map indexed on the library namespace. package Facelet_Sets is new Ada.Containers.Hashed_Sets (Element_Type => Facelet_Access, Hash => Hash, Equivalent_Elements => Compare); use Facelet_Sets; protected type Facelet_Cache is -- Find the facelet entry associated with the given name. function Find (Name : in String) return Facelet_Access; -- Insert or replace the facelet entry associated with the given name. procedure Insert (Facelet : in Facelet_Access); -- Clear the cache. procedure Clear; private Map : Facelet_Sets.Set; end Facelet_Cache; type Facelet_Factory is new Ada.Finalization.Limited_Controlled with record Paths : Unbounded_String := To_Unbounded_String (""); -- The facelet cache. Map : Facelet_Cache; -- The component factory Factory : access ASF.Factory.Component_Factory; -- Whether the unknown tags are escaped using XML escape rules. Escape_Unknown_Tags : Boolean := True; -- Whether white spaces can be ignored. Ignore_White_Spaces : Boolean := True; -- Whether empty lines should be ignored (when white spaces are kept). Ignore_Empty_Lines : Boolean := True; end record; -- Free the storage held by the factory cache. overriding procedure Finalize (Factory : in out Facelet_Factory); end ASF.Views.Facelets;
29,997
ada
0
soerenbnoergaard/adventofcode2020
day01/main.adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Main is Target: constant Integer := 2020; Puzzle_Input: constant array (1 .. 200) of Integer := ( 2000, 50, 1984, 1600, 1736, 1572, 2010, 1559, 1999, 1764, 1808, 1745, 1343, 1495, 1860, 1977, 1981, 1640, 1966, 1961, 1978, 1719, 1930, 535, 1804, 1535, 1507, 1284, 1618, 1991, 1589, 1593, 1960, 1953, 1963, 1697, 1741, 1823, 1932, 1789, 1822, 1972, 1570, 1651, 1800, 1514, 726, 1567, 72, 1987, 1791, 1842, 1020, 1541, 1383, 1505, 2009, 1925, 13, 1973, 1599, 1632, 1905, 1626, 1554, 1913, 1890, 1583, 1513, 1828, 187, 1616, 1508, 1524, 1613, 1648, 32, 1612, 1992, 1671, 1955, 1943, 1936, 1870, 1629, 1493, 1770, 1699, 1990, 1658, 1592, 1596, 1888, 1540, 239, 1677, 1602, 1877, 1481, 2004, 1985, 1829, 1980, 2008, 1964, 897, 1843, 1750, 1969, 1790, 1989, 1606, 1484, 1983, 1986, 1501, 1511, 1543, 1869, 1051, 1810, 1716, 1633, 1850, 1500, 1120, 1849, 1941, 1403, 1515, 1915, 1862, 2002, 1952, 1893, 1494, 1610, 1797, 1908, 1534, 1979, 2006, 1971, 1993, 1432, 1547, 1488, 1642, 1982, 1666, 1856, 1889, 1691, 1976, 1962, 2005, 1611, 1665, 1816, 1880, 1896, 1552, 1809, 1844, 1553, 1841, 1785, 1968, 1491, 1498, 1995, 1748, 1533, 1988, 2001, 1917, 1788, 1537, 1659, 1574, 1724, 1997, 923, 1476, 1763, 1817, 1998, 1848, 1974, 1830, 1672, 1861, 1652, 1551, 1363, 1645, 1996, 1965, 1967, 1778); begin for A of Puzzle_Input loop for B of Puzzle_Input loop if A + B = Target then Put("Product ot two numbers: "); Put(A*B); New_Line; end if; for C of Puzzle_Input loop if A + B + C = Target then Put("Product ot three numbers: "); Put(A*B*C); New_Line; end if; end loop; end loop; end loop; end Main;
29,998
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/ada/g-sechas.ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . S E C U R E _ H A S H E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2009-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides common supporting code for a family of secure -- hash functions (including MD5 and the FIPS PUB 180-3 functions SHA-1, -- SHA-224, SHA-256, SHA-384 and SHA-512). -- This is an internal unit and should be not used directly in applications. -- Use GNAT.MD5 and GNAT.SHA* instead. with Ada.Streams; use Ada.Streams; with Interfaces; with System; package GNAT.Secure_Hashes is type Buffer_Type is new String; for Buffer_Type'Alignment use 8; -- Secure hash functions use a string buffer that is also accessed as an -- array of words, which may require up to 64 bit alignment. -- The function-independent part of processing state: A buffer of data -- being accumulated until a complete block is ready for hashing. type Message_State (Block_Length : Natural) is record Last : Natural := 0; -- Index of last used element in Buffer Length : Interfaces.Unsigned_64 := 0; -- Total length of processed data Buffer : Buffer_Type (1 .. Block_Length); -- Data buffer end record; -- The function-specific part of processing state: -- Each hash function maintains an internal state as an array of words, -- which is ultimately converted to a stream representation with the -- appropriate bit order. generic type Word is mod <>; -- Either 32 or 64 bits with procedure Swap (X : System.Address); -- Byte swapping function for a Word at X Hash_Bit_Order : System.Bit_Order; -- Bit order of the produced hash package Hash_Function_State is type State is array (Natural range <>) of Word; -- Used to store a hash function's internal state procedure To_Hash (H : State; H_Bits : out Stream_Element_Array); -- Convert H to stream representation with the given bit order. If -- H_Bits is smaller than the internal hash state, then the state -- is truncated. end Hash_Function_State; -- Generic hashing framework: The user interface for each implemented -- secure hash function is an instance of this generic package. generic Block_Words : Natural; -- Number of words in each block State_Words : Natural; -- Number of words in internal state Hash_Words : Natural; -- Number of words in the final hash (must be no greater than -- State_Words). Hash_Bit_Order : System.Bit_Order; -- Bit order used for conversion between bit representation and word -- representation. with package Hash_State is new Hash_Function_State (<>); -- Hash function state package Initial_State : Hash_State.State; -- Initial value of the hash function state with procedure Transform (H : in out Hash_State.State; M : in out Message_State); -- Transformation function updating H by processing a complete data -- block from M. package H is -- The visible part of H is the interface to secure hashing functions -- that is exposed to user applications, and is intended to remain -- a stable interface. pragma Assert (Hash_Words <= State_Words); type Context is private; -- The internal processing state of the hashing function function "=" (L, R : Context) return Boolean is abstract; -- Context is the internal, implementation defined intermediate state -- in a hash computation, and no specific semantics can be expected on -- equality of context values. Only equality of final hash values (as -- returned by the [Wide_]Digest functions below) is meaningful. Initial_Context : constant Context; -- Initial value of a Context object. May be used to reinitialize -- a Context value by simple assignment of this value to the object. function HMAC_Initial_Context (Key : String) return Context; -- Initial Context for HMAC computation with the given Key procedure Update (C : in out Context; Input : String); procedure Wide_Update (C : in out Context; Input : Wide_String); procedure Update (C : in out Context; Input : Stream_Element_Array); -- Update C to process the given input. Successive calls to Update are -- equivalent to a single call with the concatenation of the inputs. For -- the Wide_String version, each Wide_Character is processed low order -- byte first. Word_Length : constant Natural := Hash_State.Word'Size / 8; Hash_Length : constant Natural := Hash_Words * Word_Length; subtype Binary_Message_Digest is Stream_Element_Array (1 .. Stream_Element_Offset (Hash_Length)); -- The fixed-length byte array returned by Digest, providing -- the hash in binary representation. function Digest (C : Context) return Binary_Message_Digest; -- Return hash or HMAC for the data accumulated with C function Digest (S : String) return Binary_Message_Digest; function Wide_Digest (W : Wide_String) return Binary_Message_Digest; function Digest (A : Stream_Element_Array) return Binary_Message_Digest; -- These functions are equivalent to the corresponding Update (or -- Wide_Update) on a default initialized Context, followed by Digest -- on the resulting Context. subtype Message_Digest is String (1 .. 2 * Hash_Length); -- The fixed-length string returned by Digest, providing the hash in -- hexadecimal representation. function Digest (C : Context) return Message_Digest; -- Return hash or HMAC for the data accumulated with C in hexadecimal -- representation. function Digest (S : String) return Message_Digest; function Wide_Digest (W : Wide_String) return Message_Digest; function Digest (A : Stream_Element_Array) return Message_Digest; -- These functions are equivalent to the corresponding Update (or -- Wide_Update) on a default initialized Context, followed by Digest -- on the resulting Context. type Hash_Stream (C : access Context) is new Root_Stream_Type with private; -- Stream wrapper converting Write calls to Update calls on C. -- Arbitrary data structures can thus be conveniently hashed using -- their stream attributes. private Block_Length : constant Natural := Block_Words * Word_Length; -- Length in bytes of a data block subtype Key_Length is Stream_Element_Offset range 0 .. Stream_Element_Offset (Block_Length); -- KL is 0 for a normal hash context, > 0 for HMAC type Context (KL : Key_Length := 0) is record Key : Stream_Element_Array (1 .. KL); -- HMAC key H_State : Hash_State.State (0 .. State_Words - 1) := Initial_State; -- Function-specific state M_State : Message_State (Block_Length); -- Function-independent state (block buffer) end record; Initial_Context : constant Context (KL => 0) := (others => <>); -- Initial values are provided by default initialization of Context type Hash_Stream (C : access Context) is new Root_Stream_Type with null record; procedure Read (Stream : in out Hash_Stream; Item : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Raise Program_Error: hash streams are write-only procedure Write (Stream : in out Hash_Stream; Item : Stream_Element_Array); -- Call Update end H; end GNAT.Secure_Hashes;
29,999
ada
2
morbos/Ada_Drivers_Library
arch/ARM/STM32/svd/stm32f103/stm32_svd-wwdg.ads
<reponame>morbos/Ada_Drivers_Library -- This spec has been automatically generated from STM32F103.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.WWDG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_T_Field is HAL.UInt7; -- Control register (WWDG_CR) type CR_Register is record -- 7-bit counter (MSB to LSB) T : CR_T_Field := 16#7F#; -- Activation bit WDGA : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record T at 0 range 0 .. 6; WDGA at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype CFR_W_Field is HAL.UInt7; subtype CFR_WDGTB_Field is HAL.UInt2; -- Configuration register (WWDG_CFR) type CFR_Register is record -- 7-bit window value W : CFR_W_Field := 16#7F#; -- Timer Base WDGTB : CFR_WDGTB_Field := 16#0#; -- Early Wakeup Interrupt EWI : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CFR_Register use record W at 0 range 0 .. 6; WDGTB at 0 range 7 .. 8; EWI at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- Status register (WWDG_SR) type SR_Register is record -- Early Wakeup Interrupt EWI : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record EWI at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Window watchdog type WWDG_Peripheral is record -- Control register (WWDG_CR) CR : aliased CR_Register; -- Configuration register (WWDG_CFR) CFR : aliased CFR_Register; -- Status register (WWDG_SR) SR : aliased SR_Register; end record with Volatile; for WWDG_Peripheral use record CR at 16#0# range 0 .. 31; CFR at 16#4# range 0 .. 31; SR at 16#8# range 0 .. 31; end record; -- Window watchdog WWDG_Periph : aliased WWDG_Peripheral with Import, Address => System'To_Address (16#40002C00#); end STM32_SVD.WWDG;