content
stringlengths
23
1.05M
package impact.d3.collision.Detector -- -- -- is end impact.d3.collision.Detector;
----------------------------csc410/prog4/as4.adb---------------------------- -- Author: Matthew Bennett -- Class: CSC410 Burgess -- Date: 10-05-04 Modified: 10-22-04 -- Due: 10-12-04 -- Desc: Assignment 4: DJIKSTRA'S STABILIZING ALGORITHM -- -- a nonproduction implementation of -- DJIKSTRA's algorithm which describes -- mutual exclusion, fairness, and deadlock avoidance -- n processes (TASKS), and IS self-correcting -- -- BRIEF: (please read all of this) -- n processes form a [directed] virtual ring topology, and -- use an internal integer counter called flag to determine -- which may go next. IN general, a process may not proceed -- unless its flag IS not equal to its previous neighbor, except FOR process0 -- -- The algorithm IS ASYMMETRIC. Process0 behaves differently than -- processes [1..n] IN several respects. Also, since the -- asymmetrical behavior IS neccessary FOR the algorithm to -- continue, some other process MUST assume the behavior of -- Process0 IN case that process IS killed or quits. -- -- The algorithm IS self-stabilizing, so it should operate on a -- "dummy resource" FOR several iterations (up to 10) eahc time -- the tasks are reordered. id will try to add this feature to -- code soon. -- !! MUTUAL EXCLUSION IS NOT GUARANTEED UNTIL THE TASKS STABILIZE !! -- -- DJIKSTRA implemented as described IN -- "Algorithms FOR Mutual Exclusion", M. Raynal -- MIT PRESS Cambridge, 1986 ISBN: 0-262-18119-3 -- with minor revisions ---------------------------------------------------------------- -- dependencies -- style note: the reasons to "with IN" but not "use" packages are -- (1) to avoid crowding of the namespace -- (2) to be explicit where abstract data types and methods come from. -- FOR instance, line randomPool : Ada.Numerics.Float_Random.Generator; -- IS more explicit than randomPool : Generator; WITH ADA.TEXT_IO; USE ADA.TEXT_IO; WITH ADA.INTEGER_TEXT_IO; USE ADA.INTEGER_TEXT_IO; WITH ADA.NUMERICS.FLOAT_RANDOM; USE ADA.NUMERICS.FLOAT_RANDOM; --by request only WITH ADA.CALENDAR; -- (provides cast: natural -> time FOR input into delay) WITH ADA.STRINGS; USE ADA.STRINGS; ---------------------------------------------------------------- ---------------------------------------------------------------- PROCEDURE AS4B IS --globals are: randompool, MAX_TASKS, SCALE_FACTOR, SPACES randomPool : ada.numerics.float_random.Generator; MAX_TASKS : CONSTANT := 100; --global constant for mem allocation restriction SCALE_FACTOR : CONSTANT := 1.0; --used to increase "spread" of random delays SPACES : STRING(1..80) := (Others => ' '); --for convenience in string manipulations TYPE RX; TYPE RX_Ptr IS ACCESS RX; --so that we ---- BEGIN RX declaration and definition ---- TASK TYPE RX IS ENTRY initvars ( id : Integer; this : RX_Ptr; left : RX_Ptr; right : RX_Ptr; thisFlag : Integer; leftFlag : Integer; rightFlag : Integer; numTasks_user : Integer; lowId : Boolean ); ENTRY Receive ( mesgType : Character; id : Integer; flag : Integer; left : RX_Ptr; right : RX_Ptr; lowId : Boolean ); END RX; TASK BODY RX IS procArray : array (0..2) of RX_Ptr; flagArray : array (0..2) of Integer := (Others => 0); myId : Integer; num_count : Integer; lowestId : Boolean; ShouldIDie : Boolean := FALSE; ---- BEGIN djikstra declaration and definition ---- TASK TYPE djikstra IS --gee, that was short END djikstra; TASK BODY djikstra IS BEGIN LOOP IF (lowestId) THEN -- Protocol 0 LOOP null; EXIT WHEN flagArray(1) = flagArray(0); END LOOP; -- BEGIN Critical Section -- Put (myId, (1+(4*myId))); Put (" IN CS"); NEW_Line; delay (Standard.Duration(random(randomPool) * 4.0)); Put (myId, (1+(4*myId))); Put (" out CS"); NEW_Line; -- END Critical Section -- flagArray(1) := (flagArray(1) + 1) mod num_count; procArray(2).Receive('U', myId, flagArray(1), null, null, FALSE); ELSE -- Protocol K NOT 0 LOOP null; EXIT WHEN (flagArray(1) /= flagArray(0)); END LOOP; -- BEGIN Critical Section Put (myId, (1+(4*myId))); Put (" IN CS"); NEW_Line; delay (Standard.Duration(random(randomPool) * 4.0)); Put (myId, (1+(4*myId))); Put (" out CS"); NEW_Line; -- END Critical Section -- flagArray(1) := flagArray(0); procArray(2).Receive('U', myId, flagArray(1), null, null, FALSE); END IF; END LOOP; END djikstra; TYPE djik_ptr IS ACCESS djikstra; ptr : djik_Ptr; --so that we can spin off a copy of djikstra's algorithm for each listener task BEGIN -- ENTRY Point to initalize our id's from the AS4 PROCEDURE ACCEPT initvars (id : Integer; this : RX_Ptr; left : RX_Ptr; right : RX_Ptr; thisFlag : Integer; leftFlag : Integer; rightFlag : Integer; numTasks_user : Integer; lowId : Boolean) do procArray(1) := this; procArray(0) := left; procArray(2) := right; flagArray(1) := thisFlag; flagArray(0) := leftFlag; flagArray(2) := rightFlag; num_count := numTasks_user; myId := id; lowestId := lowId; END initvars; ptr := NEW djikstra; -- Start our message handling LOOP waiting FOR messages to arrive -- LOOP SELECT ACCEPT Receive ( mesgType : Character; id : Integer; flag : Integer; left : RX_Ptr; right : RX_Ptr; lowId : Boolean ) DO case mesgType IS WHEN 'U' => BEGIN Put(id, (80 - 10 ) ); Put_Line(" update"); NEW_Line; -- As we always receive update messages from the left neighbour -- we simply change our local copy of left's NEW flag flagArray(0) := flag; END; WHEN 'N' => BEGIN Put(id, (80 - 10 ) ); Put_Line(" neighbor"); NEW_Line; IF (left = null) THEN -- Someone IS updating our right neighbour procArray(2) := right; flagArray(2) := flag; ELSE -- Someone IS updating our left neighbour procArray(0) := left; flagArray(0) := flag; lowestId := lowId; END IF; END; WHEN 'R' => BEGIN Put(id, (80 - 10 ) ); Put_Line(" dying..."); procArray(0).Receive('N', myId, flagArray(2), null, procArray(2), FALSE); -- Tell my left who my right was -- Also, IF dying, we pass TRUE as the lowest id to the right, -- as it IS our next lowest, IF we were the lowest already IF (lowestId) THEN procArray(2).Receive('N', myId, flagArray(0), procArray(0), null, TRUE); -- Tell my right who my left was ELSE procArray(2).Receive('N', myId, flagArray(0), procArray(0), null, FALSE); -- Tell my right who my left was END IF; ShouldIDie := TRUE; -- Set flag to drop out of LOOP now END; WHEN Others => null; END case; END Receive; EXIT WHEN ShouldIDie = TRUE; END SELECT; END LOOP; END RX; ---- END RX declaration and definition ---- PROCEDURE Driver IS numtasks_user : Integer; seed_user : Integer; --user defined at runtime by std. input ptrArray : array (0..MAX_TASKS-1) of RX_Ptr; killId : Integer; --temp to store which process to kill RIPArray : array (0..MAX_TASKS-1) of Boolean := (Others => FALSE); --keep track of which processes have been killed BEGIN put("# random seed: "); get(seed_user); --to ensure a significantly random series, a seed IS needed -- to generate pseudo-random numbers Ada.Numerics.Float_Random.Reset(randomPool,seed_user); --seed the random number pool LOOP put("# tasks[1-50]: "); Get (numTasks_user); EXIT WHEN (0 < numTasks_user) AND (numTasks_user <= MAX_TASKS); END LOOP; -- Create each of our tasks FOR task_count IN 0 .. numTasks_user-1 LOOP ptrArray(task_count) := NEW RX; END LOOP; FOR task_count IN 0 .. numTasks_user-1 LOOP ptrArray(task_count).initvars(task_count, ptrArray(task_count), ptrArray((task_count - 1) mod numTasks_user), ptrArray((task_count + 1) mod numTasks_user), task_count, ((task_count - 1) mod numTasks_user),((task_count + 1) mod numTasks_user), numTasks_user, FALSE); END LOOP; delay (120.0); --start randomly killing off processes FOR kill_index IN REVERSE 0 .. (numTasks_user - 1) LOOP delay (3.0); put ("Going to kill random process ... process "); -- Delay 60 seconds THEN kill off a process -- LOOP killID := Integer (random(randomPool)) mod numTasks_user; EXIT WHEN NOT RIParray(killID); END LOOP; RIParray(killID) := TRUE; Put(killID, 0); Put_line(""); ptrArray(killID).Receive('R', 0, 0, null, null, FALSE); END LOOP; --kill out all our processes END Driver; BEGIN Driver; null; END AS4B;
with Ada.Integer_Text_IO, Ada.Text_IO, Constraint_Engine; use Ada.Integer_Text_IO, Ada.Text_IO; procedure Example is package Test_Engine renames Constraint_Engine; use Test_Engine; P : Type_Problem; S : Var_Vector.Vector; begin P.Add_Var(Low_Interval => 0, Top_Interval => 400); P.Add_Var(Low_Interval => 0, Top_Interval => 500); P.Add_Constraint_Var_Multiple(V_All_Position => (1, 2), Rel => IS_INEQUAL); P.Add_Constraint_Var(V1_Position => 1, Rel => IS_MORE, V2_Position => 2); P.Add_Constraint_Int(V1_Position => 1, Rel => IS_MORE, V => 150); P := P.Find_Solution; S := P.Get_Var; Put("Solution : "); for Cursor in S.First_Index .. S.Last_Index loop Put( Integer'Image(S(Cursor).Curr_Solution) & ", "); end loop; New_Line; end Example;
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Containers; with Ada.Strings.Unbounded; with Ada.Containers.Vectors; with Types; with Symbol_Sets; limited with Rules; package Symbols is type Symbol_Kind is (Terminal, Non_Terminal, Multi_Terminal); type Association_Type is (Left_Association, Right_Association, No_Association, Unknown_Association); type Symbol_Record; type Symbol_Access is access all Symbol_Record; subtype Line_Number is Types.Line_Number; package Symbol_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Symbol_Access); use Symbol_Vectors; use Ada.Strings.Unbounded; package Alias_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Unbounded_String); subtype Symbol_Index is Types.Symbol_Index; type Symbol_Record is record Name : Unbounded_String := Null_Unbounded_String; Index : Symbol_Index := 0; -- Index number for this symbol Kind : Symbol_Kind := Terminal; -- Symbols are all either TERMINALS or NTs Rule : access Rules.Rule_Record := null; -- Linked list of rules of this (if an NT) Fallback : access Symbol_Record := null; -- fallback token in case this token doesn't parse Precedence : Integer := 0; -- Precedence if defined (-1 otherwise) Association : Association_Type := Left_Association; -- Associativity if precedence is defined -- First_Set : Sets.Set_Type := Sets.Null_Set; First_Set : Symbol_Sets.Set_Type := Symbol_Sets.Null_Set; -- First-set for all rules of this symbol Lambda : Boolean := False; -- True if NT and can generate an empty string Use_Count : Natural := 0; -- Number of times used Destructor : aliased Unbounded_String := Null_Unbounded_String; -- Code which executes whenever this symbol is -- popped from the stack during error processing Dest_Lineno : aliased Line_Number := 0; -- Line number for start of destructor. Set to -- -1 for duplicate destructors. Data_Type : aliased Unbounded_String := Null_Unbounded_String; -- The data type of information held by this -- object. Only used if type==NONTERMINAL DT_Num : Integer := 0; -- The data type number. In the parser, the value -- stack is a union. The .yy%d element of this -- union is the correct data type for this object Content : Boolean := False; -- True if this symbol ever carries content - if -- it is ever more than just syntax -- -- The following fields are used by MULTITERMINALs only -- Sub_Symbol : Vector := Empty_Vector; -- Array of constituent symbols end record; -- -- Routines for handling symbols of the grammar -- function Name_Of (Symbol : in Symbol_Access) return String is (To_String (Symbol.Name)); procedure Count_Symbols_And_Terminals (Symbol_Count : out Natural; Terminal_Count : out Natural); -- Count the number of symbols and terminals. procedure Symbol_Init; -- Allocate a new associative array. function Create (Name : in String) return Symbol_Access; -- Return a pointer to the (terminal or nonterminal) symbol "Name". -- Create a new symbol if this is the first time "Name" has been seen. function Find (Name : in String) return Symbol_Access; -- Return a pointer to data assigned to the given key. Return NULL -- if no such key. procedure Symbol_Allocate (Count : in Ada.Containers.Count_Type); -- Return an array of pointers to all data in the table. -- The array is obtained from malloc. Return NULL if memory allocation -- problems, or if the array is empty. function "<" (Left, Right : in Symbol_Record) return Boolean; -- Compare two symbols for sorting purposes. Return negative, -- zero, or positive if a is less then, equal to, or greater -- than b. -- -- Symbols that begin with upper case letters (terminals or tokens) -- must sort before symbols that begin with lower case letters -- (non-terminals). And MULTITERMINAL symbols (created using the -- %token_class directive) must sort at the very end. Other than -- that, the order does not matter. -- -- We find experimentally that leaving the symbols in their original -- order (the order they appeared in the grammar file) gives the -- smallest parser tables in SQLite. function Last_Index return Symbol_Index; -- Get symbol last index. function Element_At (Index : in Symbol_Index) return Symbol_Access; -- Get symbol at Index position. procedure Sort; -- Sort the symbol table procedure Set_Lambda_False_And_Set_Firstset (First : in Natural; Last : in Natural); -- Helper procedure split out of Builds.Find_First_Sets. -- Set all symbol lambda to False. -- New_Set to symbol in range First to Last. end Symbols;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ S M E M -- -- -- -- B o d y -- -- -- -- Copyright (C) 1998-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Einfo; use Einfo; with Elists; use Elists; with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Nmake; use Nmake; with Namet; use Namet; with Nlists; use Nlists; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Tbuild; use Tbuild; package body Exp_Smem is Insert_Node : Node_Id; -- Node after which a write call is to be inserted ----------------------- -- Local Subprograms -- ----------------------- procedure Add_Read (N : Node_Id; Call : Node_Id := Empty); -- Insert a Shared_Var_ROpen call for variable before node N, unless -- Call is a call to an init-proc, in which case the call is inserted -- after Call. procedure Add_Write_After (N : Node_Id); -- Insert a Shared_Var_WOpen call for variable after the node Insert_Node, -- as recorded by On_Lhs_Of_Assignment (where it points to the assignment -- statement) or Is_Out_Actual (where it points to the subprogram call). -- When Insert_Node is a function call, establish a transient scope around -- the expression, and insert the write as an after-action of the transient -- scope. procedure Build_Full_Name (E : Entity_Id; N : out String_Id); -- Build the fully qualified string name of a shared variable function On_Lhs_Of_Assignment (N : Node_Id) return Boolean; -- Determines if N is on the left hand of the assignment. This means that -- either it is a simple variable, or it is a record or array variable with -- a corresponding selected or indexed component on the left side of an -- assignment. If the result is True, then Insert_Node is set to point -- to the assignment function Is_Out_Actual (N : Node_Id) return Boolean; -- In a similar manner, this function determines if N appears as an OUT -- or IN OUT parameter to a procedure call. If the result is True, then -- Insert_Node is set to point to the call. function Build_Shared_Var_Proc_Call (Loc : Source_Ptr; E : Node_Id; N : Name_Id) return Node_Id; -- Build a call to support procedure N for shared object E (provided by the -- instance of System.Shared_Storage.Shared_Var_Procs associated to E). -------------------------------- -- Build_Shared_Var_Proc_Call -- -------------------------------- function Build_Shared_Var_Proc_Call (Loc : Source_Ptr; E : Entity_Id; N : Name_Id) return Node_Id is begin return Make_Procedure_Call_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Shared_Var_Procs_Instance (E), Loc), Selector_Name => Make_Identifier (Loc, N))); end Build_Shared_Var_Proc_Call; -------------- -- Add_Read -- -------------- procedure Add_Read (N : Node_Id; Call : Node_Id := Empty) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Node_Id := Entity (N); SVC : Node_Id; begin if Present (Shared_Var_Procs_Instance (Ent)) then SVC := Build_Shared_Var_Proc_Call (Loc, Ent, Name_Read); if Present (Call) and then Is_Init_Proc (Name (Call)) then Insert_After_And_Analyze (Call, SVC); else Insert_Action (N, SVC); end if; end if; end Add_Read; ------------------------------- -- Add_Shared_Var_Lock_Procs -- ------------------------------- procedure Add_Shared_Var_Lock_Procs (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Obj : constant Entity_Id := Entity (Expression (First_Actual (N))); Vnm : String_Id; Vid : Entity_Id; Vde : Node_Id; Aft : constant List_Id := New_List; In_Transient : constant Boolean := Scope_Is_Transient; function Build_Shared_Var_Lock_Call (RE : RE_Id) return Node_Id; -- Return a procedure call statement for lock proc RTE -------------------------------- -- Build_Shared_Var_Lock_Call -- -------------------------------- function Build_Shared_Var_Lock_Call (RE : RE_Id) return Node_Id is begin return Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE), Loc), Parameter_Associations => New_List (New_Occurrence_Of (Vid, Loc))); end Build_Shared_Var_Lock_Call; -- Start of processing for Add_Shared_Var_Lock_Procs begin -- Discussion of transient scopes: we need to have a transient scope -- to hold the required lock/unlock actions. Either the current scope -- is transient, in which case we reuse it, or we establish a new -- transient scope. If this is a function call with unconstrained -- return type, we can't introduce a transient scope here (because -- Wrap_Transient_Expression would need to declare a temporary with -- the unconstrained type outside of the transient block), but in that -- case we know that we have already established one at an outer level -- for secondary stack management purposes. -- If the lock/read/write/unlock actions for this object have already -- been emitted in the current scope, no need to perform them anew. if In_Transient and then Contains (Scope_Stack.Table (Scope_Stack.Last) .Locked_Shared_Objects, Obj) then return; end if; Build_Full_Name (Obj, Vnm); -- Declare a constant string to hold the name of the shared object. -- Note that this must occur outside of the transient scope, as the -- scope's finalizer needs to have access to this object. Also, it -- appears that GIGI does not support elaborating string literal -- subtypes in transient scopes. Vid := Make_Temporary (Loc, 'N', Obj); Vde := Make_Object_Declaration (Loc, Defining_Identifier => Vid, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_String, Loc), Expression => Make_String_Literal (Loc, Vnm)); -- Already in a transient scope. Make sure that we insert Vde outside -- that scope. if In_Transient then Insert_Before_And_Analyze (Node_To_Be_Wrapped, Vde); -- Not in a transient scope yet: insert Vde as an action on N prior to -- establishing one. else Insert_Action (N, Vde); Establish_Transient_Scope (N, Sec_Stack => False); end if; -- Mark object as locked in the current (transient) scope Append_New_Elmt (Obj, To => Scope_Stack.Table (Scope_Stack.Last).Locked_Shared_Objects); -- First insert the Lock call before Insert_Action (N, Build_Shared_Var_Lock_Call (RE_Shared_Var_Lock)); -- Now, right after the Lock, insert a call to read the object Insert_Action (N, Build_Shared_Var_Proc_Call (Loc, Obj, Name_Read)); -- For a procedure call only, insert the call to write the object prior -- to unlocking. if Nkind (N) = N_Procedure_Call_Statement then Append_To (Aft, Build_Shared_Var_Proc_Call (Loc, Obj, Name_Write)); end if; -- Finally insert the Unlock call Append_To (Aft, Build_Shared_Var_Lock_Call (RE_Shared_Var_Unlock)); -- Store cleanup actions in transient scope Store_Cleanup_Actions_In_Scope (Aft); -- If we have established a transient scope here, wrap it now if not In_Transient then if Nkind (N) = N_Procedure_Call_Statement then Wrap_Transient_Statement (N); else Wrap_Transient_Expression (N); end if; end if; end Add_Shared_Var_Lock_Procs; --------------------- -- Add_Write_After -- --------------------- procedure Add_Write_After (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Entity_Id := Entity (N); Par : constant Node_Id := Insert_Node; begin if Present (Shared_Var_Procs_Instance (Ent)) then if Nkind (Insert_Node) = N_Function_Call then Establish_Transient_Scope (Insert_Node, Sec_Stack => False); Store_After_Actions_In_Scope (New_List ( Build_Shared_Var_Proc_Call (Loc, Ent, Name_Write))); else Insert_After_And_Analyze (Par, Build_Shared_Var_Proc_Call (Loc, Ent, Name_Write)); end if; end if; end Add_Write_After; --------------------- -- Build_Full_Name -- --------------------- procedure Build_Full_Name (E : Entity_Id; N : out String_Id) is procedure Build_Name (E : Entity_Id); -- This is a recursive routine used to construct the fully qualified -- string name of the package corresponding to the shared variable. ---------------- -- Build_Name -- ---------------- procedure Build_Name (E : Entity_Id) is begin if Scope (E) /= Standard_Standard then Build_Name (Scope (E)); Store_String_Char ('.'); end if; Get_Decoded_Name_String (Chars (E)); Store_String_Chars (Name_Buffer (1 .. Name_Len)); end Build_Name; -- Start of processing for Build_Full_Name begin Start_String; Build_Name (E); N := End_String; end Build_Full_Name; ------------------------------------ -- Expand_Shared_Passive_Variable -- ------------------------------------ procedure Expand_Shared_Passive_Variable (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin -- Nothing to do for protected or limited objects if Is_Limited_Type (Typ) or else Is_Concurrent_Type (Typ) then return; -- If we are on the left hand side of an assignment, then we add the -- write call after the assignment. elsif On_Lhs_Of_Assignment (N) then Add_Write_After (N); -- If we are a parameter for an out or in out formal, then in general -- we do: -- read -- call -- write -- but in the special case of a call to an init proc, we need to first -- call the init proc (to set discriminants), then read (to possibly -- set other components), then write (to record the updated components -- to the backing store): -- init-proc-call -- read -- write elsif Is_Out_Actual (N) then -- Note: For an init proc call, Add_Read inserts just after the -- call node, and we want to have first the read, then the write, -- so we need to first Add_Write_After, then Add_Read. Add_Write_After (N); Add_Read (N, Call => Insert_Node); -- All other cases are simple reads else Add_Read (N); end if; end Expand_Shared_Passive_Variable; ------------------- -- Is_Out_Actual -- ------------------- function Is_Out_Actual (N : Node_Id) return Boolean is Formal : Entity_Id; Call : Node_Id; begin Find_Actual (N, Formal, Call); if No (Formal) then return False; else if Ekind_In (Formal, E_Out_Parameter, E_In_Out_Parameter) then Insert_Node := Call; return True; else return False; end if; end if; end Is_Out_Actual; --------------------------- -- Make_Shared_Var_Procs -- --------------------------- function Make_Shared_Var_Procs (N : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (N); Ent : constant Entity_Id := Defining_Identifier (N); Typ : constant Entity_Id := Etype (Ent); Vnm : String_Id; Obj : Node_Id; Obj_Typ : Entity_Id; After : constant Node_Id := Next (N); -- Node located right after N originally (after insertion of the SV -- procs this node is right after the last inserted node). SVP_Instance : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Ent), 'G')); -- Instance of Shared_Storage.Shared_Var_Procs associated with Ent Instantiation : Node_Id; -- Package instantiation node for SVP_Instance -- Start of processing for Make_Shared_Var_Procs begin Build_Full_Name (Ent, Vnm); -- We turn off Shared_Passive during construction and analysis of the -- generic package instantiation, to avoid improper attempts to process -- the variable references within these instantiation. Set_Is_Shared_Passive (Ent, False); -- Construct generic package instantiation -- package varG is new Shared_Var_Procs (typ, var, "pkg.var"); Obj := New_Occurrence_Of (Ent, Loc); Obj_Typ := Typ; if Is_Concurrent_Type (Typ) then Obj := Convert_Concurrent (N => Obj, Typ => Typ); Obj_Typ := Corresponding_Record_Type (Typ); end if; Instantiation := Make_Package_Instantiation (Loc, Defining_Unit_Name => SVP_Instance, Name => New_Occurrence_Of (RTE (RE_Shared_Var_Procs), Loc), Generic_Associations => New_List ( Make_Generic_Association (Loc, Explicit_Generic_Actual_Parameter => New_Occurrence_Of (Obj_Typ, Loc)), Make_Generic_Association (Loc, Explicit_Generic_Actual_Parameter => Obj), Make_Generic_Association (Loc, Explicit_Generic_Actual_Parameter => Make_String_Literal (Loc, Vnm)))); Insert_After_And_Analyze (N, Instantiation); Set_Is_Shared_Passive (Ent, True); Set_Shared_Var_Procs_Instance (Ent, Defining_Entity (Instance_Spec (Instantiation))); -- Return last node before After declare Nod : Node_Id := Next (N); begin while Next (Nod) /= After loop Nod := Next (Nod); end loop; return Nod; end; end Make_Shared_Var_Procs; -------------------------- -- On_Lhs_Of_Assignment -- -------------------------- function On_Lhs_Of_Assignment (N : Node_Id) return Boolean is P : constant Node_Id := Parent (N); begin if Nkind (P) = N_Assignment_Statement then if N = Name (P) then Insert_Node := P; return True; else return False; end if; elsif Nkind_In (P, N_Indexed_Component, N_Selected_Component) and then N = Prefix (P) then return On_Lhs_Of_Assignment (P); else return False; end if; end On_Lhs_Of_Assignment; end Exp_Smem;
Ch : Character; Available : Boolean; Ada.Text_IO.Get_Immediate (Ch, Available);
-- { dg-do compile } -- { dg-options "-gnatct" } package Private1.Sub is package Nested is type T is limited private; function "=" (X, Y : T) return Boolean; private type T is new Private1.T; end Nested; end Private1.Sub;
with Common; use Common; package Int64_Parsing with SPARK_Mode is procedure Parse_Int64 (S : String; V : out Int64; Error : out Boolean) with Pre => S'Last < Integer'Last; function Print_Int64 (V : Int64) return String; end Int64_Parsing;
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); package body SPAT.String_Tables is type Lengths is array (1 .. Columns) of Ada.Text_IO.Count; type Column_Positions is array (1 .. Columns) of Ada.Text_IO.Positive_Count; --------------------------------------------------------------------------- -- Put --------------------------------------------------------------------------- procedure Put (File : in Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Output; Item : in Row_Vectors.Vector) is Col_Length : Lengths := (others => 0); Start_Col : Column_Positions := (others => 1); use type Ada.Text_IO.Count; begin -- Retrieve maximum length of each column. for Row of Item loop for Col in Col_Length'Range loop Col_Length (Col) := Ada.Text_IO.Count'Max (Col_Length (Col), (if Col = Col_Length'First and then Col /= Col_Length'Last and then Ada.Strings.Unbounded.Length (Row (Col + 1)) = 0 then 0 -- Ignore length of first field if no other field follows. else Ada.Text_IO.Count (Ada.Strings.Unbounded.Length (Row (Col))))); end loop; end loop; -- Now each Length entry contains the maximum length of each item. -- Let's turn these length into absolute positions. for Col in Col_Length'Range loop Start_Col (Col) := (if Col = Col_Length'First then 1 else Start_Col (Col - 1) + Col_Length (Col - 1)); end loop; -- Finally print each entry. for Row of Item loop for Col in Row'Range loop if Ada.Strings.Unbounded.Length (Row (Col)) > 0 then Ada.Text_IO.Set_Col (File => File, To => Start_Col (Col)); Ada.Text_IO.Put (File => File, Item => Ada.Strings.Unbounded.To_String (Row (Col))); end if; end loop; Ada.Text_IO.New_Line (File => File); end loop; end Put; end SPAT.String_Tables;
with AUnit.Test_Suites; use AUnit.Test_Suites; package Rejuvenation_Workshop_Suite is function Suite return Access_Test_Suite; end Rejuvenation_Workshop_Suite;
------------------------------------------------------------------------------ -- AGAR GUI LIBRARY -- -- A G A R . I N P U T _ D E V I C E -- -- S p e c -- ------------------------------------------------------------------------------ with Interfaces.C; with Interfaces.C.Strings; with Agar.Object; with System; -- -- Generic input device -- package Agar.Input_Device is package C renames Interfaces.C; package CS renames Interfaces.C.Strings; use type C.unsigned; type Input_Device is limited record Super : aliased Agar.Object.Object; -- [Object -> Input_Device] Driver : System.Address; -- Agar.Driver.Driver_Access Descr : CS.chars_ptr; -- Long description Flags : C.unsigned; C_Pad : Interfaces.Unsigned_32; end record with Convention => C; type Input_Device_Access is access all Input_Device with Convention => C; subtype Input_Device_not_null_Access is not null Input_Device_Access; end Agar.Input_Device;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Stocks_Materiel; use Stocks_Materiel; -- Auteur: -- Gérer un stock de matériel informatique. -- procedure Scenario_Stock is Mon_Stock : T_Stock; begin -- Créer un stock vide Creer (Mon_Stock); pragma Assert (Nb_Materiels (Mon_Stock) = 0); -- Enregistrer quelques matériels Enregistrer (Mon_Stock, 1012, UNITE_CENTRALE, 2016); pragma Assert (Nb_Materiels (Mon_Stock) = 1); Enregistrer (Mon_Stock, 2143, ECRAN, 2016); pragma Assert (Nb_Materiels (Mon_Stock) = 2); Enregistrer (Mon_Stock, 3001, IMPRIMANTE, 2017); pragma Assert (Nb_Materiels (Mon_Stock) = 3); Enregistrer (Mon_Stock, 3012, UNITE_CENTRALE, 2017); pragma Assert (Nb_Materiels (Mon_Stock) = 4); end Scenario_Stock;
-- CC3605A.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 SOME DIFFERENCES BETWEEN THE FORMAL AND THE -- ACTUAL SUBPROGRAMS DO NOT INVALIDATE A MATCH. -- 1) CHECK DIFFERENT PARAMETER NAMES. -- 2) CHECK DIFFERENT PARAMETER CONSTRAINTS. -- 3) CHECK ONE PARAMETER CONSTRAINED AND THE OTHER -- UNCONSTRAINED (WITH ARRAY, RECORD, ACCESS, AND -- PRIVATE TYPES). -- 4) CHECK PRESENCE OR ABSENCE OF AN EXPLICIT "IN" MODE -- INDICATOR. -- 5) DIFFERENT TYPE MARKS USED TO SPECIFY THE TYPE OF -- PARAMETERS. -- HISTORY: -- LDC 10/04/88 CREATED ORIGINAL TEST. PACKAGE CC3605A_PACK IS SUBTYPE INT IS INTEGER RANGE -100 .. 100; TYPE PRI_TYPE (SIZE : INT) IS PRIVATE; SUBTYPE PRI_CONST IS PRI_TYPE (2); PRIVATE TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN; TYPE PRI_TYPE (SIZE : INT) IS RECORD SUB_A : ARR_TYPE (1 .. SIZE); END RECORD; END CC3605A_PACK; WITH REPORT; USE REPORT; WITH CC3605A_PACK; USE CC3605A_PACK; PROCEDURE CC3605A IS SUBTYPE ZERO_TO_TEN IS INTEGER RANGE IDENT_INT (0) .. IDENT_INT (10); SUBTYPE ONE_TO_FIVE IS INTEGER RANGE IDENT_INT (1) .. IDENT_INT (5); SUBPRG_ACT : BOOLEAN := FALSE; BEGIN TEST ("CC3605A", "CHECK THAT SOME DIFFERENCES BETWEEN THE " & "FORMAL AND THE ACTUAL PARAMETERS DO NOT " & "INVALIDATE A MATCH"); ---------------------------------------------------------------------- -- DIFFERENT PARAMETER NAMES ---------------------------------------------------------------------- DECLARE PROCEDURE ACT_PROC (DIFF_NAME_PARM : ONE_TO_FIVE) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : ONE_TO_FIVE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (ONE_TO_FIVE'FIRST); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("DIFFERENT PARAMETER NAMES MADE MATCH INVALID"); END IF; END; ---------------------------------------------------------------------- -- DIFFERENT PARAMETER CONSTRAINTS ---------------------------------------------------------------------- DECLARE PROCEDURE ACT_PROC (PARM : ONE_TO_FIVE) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : ZERO_TO_TEN); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (ONE_TO_FIVE'FIRST); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("DIFFERENT PARAMETER CONSTRAINTS MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- ONE PARAMETER CONSTRAINED (ARRAY) ---------------------------------------------------------------------- DECLARE TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN; SUBTYPE ARR_CONST IS ARR_TYPE (ONE_TO_FIVE'FIRST .. ONE_TO_FIVE'LAST); PASSED_PARM : ARR_CONST := (OTHERS => TRUE); PROCEDURE ACT_PROC (PARM : ARR_CONST) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : ARR_TYPE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (PASSED_PARM); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("ONE ARRAY PARAMETER CONSTRAINED MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- ONE PARAMETER CONSTRAINED (RECORDS) ---------------------------------------------------------------------- DECLARE TYPE REC_TYPE (BOL : BOOLEAN) IS RECORD SUB_A : INTEGER; CASE BOL IS WHEN TRUE => DSCR_A : INTEGER; WHEN FALSE => DSCR_B : BOOLEAN; END CASE; END RECORD; SUBTYPE REC_CONST IS REC_TYPE (TRUE); PASSED_PARM : REC_CONST := (TRUE, 1, 2); PROCEDURE ACT_PROC (PARM : REC_CONST) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : REC_TYPE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (PASSED_PARM); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("ONE RECORD PARAMETER CONSTRAINED MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- ONE PARAMETER CONSTRAINED (ACCESS) ---------------------------------------------------------------------- DECLARE TYPE ARR_TYPE IS ARRAY (INTEGER RANGE <>) OF BOOLEAN; SUBTYPE ARR_CONST IS ARR_TYPE (ONE_TO_FIVE'FIRST .. ONE_TO_FIVE'LAST); TYPE ARR_ACC_TYPE IS ACCESS ARR_TYPE; SUBTYPE ARR_ACC_CONST IS ARR_ACC_TYPE (1 .. 3); PASSED_PARM : ARR_ACC_TYPE := NULL; PROCEDURE ACT_PROC (PARM : ARR_ACC_CONST) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : ARR_ACC_TYPE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (PASSED_PARM); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("ONE ACCESS PARAMETER CONSTRAINED MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- ONE PARAMETER CONSTRAINED (PRIVATE) ---------------------------------------------------------------------- DECLARE PASSED_PARM : PRI_CONST; PROCEDURE ACT_PROC (PARM : PRI_CONST) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : PRI_TYPE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (PASSED_PARM); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("ONE PRIVATE PARAMETER CONSTRAINED MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- PRESENCE (OR ABSENCE) OF AN EXPLICIT "IN" MODE ---------------------------------------------------------------------- DECLARE PROCEDURE ACT_PROC (PARM : INTEGER) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM : IN INTEGER); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (1); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("PRESENCE OF AN EXPLICIT 'IN' MODE MADE MATCH " & "INVALID"); END IF; END; ---------------------------------------------------------------------- -- DIFFERENT TYPE MARKS ---------------------------------------------------------------------- DECLARE SUBTYPE MARK_1_TYPE IS INTEGER; SUBTYPE MARK_2_TYPE IS INTEGER; PROCEDURE ACT_PROC (PARM1 : IN MARK_1_TYPE) IS BEGIN SUBPRG_ACT := TRUE; END ACT_PROC; GENERIC WITH PROCEDURE PASSED_PROC (PARM2 : MARK_2_TYPE); PROCEDURE GEN_PROC; PROCEDURE GEN_PROC IS BEGIN PASSED_PROC (1); END GEN_PROC; PROCEDURE INST_PROC IS NEW GEN_PROC (ACT_PROC); BEGIN SUBPRG_ACT := FALSE; INST_PROC; IF NOT SUBPRG_ACT THEN FAILED ("DIFFERENT TYPE MARKS MADE MATCH INVALID"); END IF; END; RESULT; END CC3605A;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.ICM is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ICM_CFG_BBC_Field is HAL.UInt4; -- User SHA Algorithm type CFG_UALGOSelect is (-- SHA1 Algorithm SHA1, -- SHA256 Algorithm SHA256, -- SHA224 Algorithm SHA224) with Size => 3; for CFG_UALGOSelect use (SHA1 => 0, SHA256 => 1, SHA224 => 4); subtype ICM_CFG_HAPROT_Field is HAL.UInt6; subtype ICM_CFG_DAPROT_Field is HAL.UInt6; -- Configuration type ICM_CFG_Register is record -- Write Back Disable WBDIS : Boolean := False; -- End of Monitoring Disable EOMDIS : Boolean := False; -- Secondary List Branching Disable SLBDIS : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Bus Burden Control BBC : ICM_CFG_BBC_Field := 16#0#; -- Automatic Switch To Compare Digest ASCD : Boolean := False; -- Dual Input Buffer DUALBUFF : Boolean := False; -- unspecified Reserved_10_11 : HAL.UInt2 := 16#0#; -- User Initial Hash Value UIHASH : Boolean := False; -- User SHA Algorithm UALGO : CFG_UALGOSelect := SAM_SVD.ICM.SHA1; -- Region Hash Area Protection HAPROT : ICM_CFG_HAPROT_Field := 16#0#; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Region Descriptor Area Protection DAPROT : ICM_CFG_DAPROT_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_CFG_Register use record WBDIS at 0 range 0 .. 0; EOMDIS at 0 range 1 .. 1; SLBDIS at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; BBC at 0 range 4 .. 7; ASCD at 0 range 8 .. 8; DUALBUFF at 0 range 9 .. 9; Reserved_10_11 at 0 range 10 .. 11; UIHASH at 0 range 12 .. 12; UALGO at 0 range 13 .. 15; HAPROT at 0 range 16 .. 21; Reserved_22_23 at 0 range 22 .. 23; DAPROT at 0 range 24 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype ICM_CTRL_REHASH_Field is HAL.UInt4; subtype ICM_CTRL_RMDIS_Field is HAL.UInt4; subtype ICM_CTRL_RMEN_Field is HAL.UInt4; -- Control type ICM_CTRL_Register is record -- Write-only. ICM Enable ENABLE : Boolean := False; -- Write-only. ICM Disable Register DISABLE : Boolean := False; -- Write-only. Software Reset SWRST : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Write-only. Recompute Internal Hash REHASH : ICM_CTRL_REHASH_Field := 16#0#; -- Write-only. Region Monitoring Disable RMDIS : ICM_CTRL_RMDIS_Field := 16#0#; -- Write-only. Region Monitoring Enable RMEN : ICM_CTRL_RMEN_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_CTRL_Register use record ENABLE at 0 range 0 .. 0; DISABLE at 0 range 1 .. 1; SWRST at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; REHASH at 0 range 4 .. 7; RMDIS at 0 range 8 .. 11; RMEN at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ICM_SR_RAWRMDIS_Field is HAL.UInt4; subtype ICM_SR_RMDIS_Field is HAL.UInt4; -- Status type ICM_SR_Register is record -- Read-only. ICM Controller Enable Register ENABLE : Boolean; -- unspecified Reserved_1_7 : HAL.UInt7; -- Read-only. RAW Region Monitoring Disabled Status RAWRMDIS : ICM_SR_RAWRMDIS_Field; -- Read-only. Region Monitoring Disabled Status RMDIS : ICM_SR_RMDIS_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_SR_Register use record ENABLE at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; RAWRMDIS at 0 range 8 .. 11; RMDIS at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ICM_IER_RHC_Field is HAL.UInt4; subtype ICM_IER_RDM_Field is HAL.UInt4; subtype ICM_IER_RBE_Field is HAL.UInt4; subtype ICM_IER_RWC_Field is HAL.UInt4; subtype ICM_IER_REC_Field is HAL.UInt4; subtype ICM_IER_RSU_Field is HAL.UInt4; -- Interrupt Enable type ICM_IER_Register is record -- Write-only. Region Hash Completed Interrupt Enable RHC : ICM_IER_RHC_Field := 16#0#; -- Write-only. Region Digest Mismatch Interrupt Enable RDM : ICM_IER_RDM_Field := 16#0#; -- Write-only. Region Bus Error Interrupt Enable RBE : ICM_IER_RBE_Field := 16#0#; -- Write-only. Region Wrap Condition detected Interrupt Enable RWC : ICM_IER_RWC_Field := 16#0#; -- Write-only. Region End bit Condition Detected Interrupt Enable REC : ICM_IER_REC_Field := 16#0#; -- Write-only. Region Status Updated Interrupt Disable RSU : ICM_IER_RSU_Field := 16#0#; -- Write-only. Undefined Register Access Detection Interrupt Enable URAD : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_IER_Register use record RHC at 0 range 0 .. 3; RDM at 0 range 4 .. 7; RBE at 0 range 8 .. 11; RWC at 0 range 12 .. 15; REC at 0 range 16 .. 19; RSU at 0 range 20 .. 23; URAD at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype ICM_IDR_RHC_Field is HAL.UInt4; subtype ICM_IDR_RDM_Field is HAL.UInt4; subtype ICM_IDR_RBE_Field is HAL.UInt4; subtype ICM_IDR_RWC_Field is HAL.UInt4; subtype ICM_IDR_REC_Field is HAL.UInt4; subtype ICM_IDR_RSU_Field is HAL.UInt4; -- Interrupt Disable type ICM_IDR_Register is record -- Write-only. Region Hash Completed Interrupt Disable RHC : ICM_IDR_RHC_Field := 16#0#; -- Write-only. Region Digest Mismatch Interrupt Disable RDM : ICM_IDR_RDM_Field := 16#0#; -- Write-only. Region Bus Error Interrupt Disable RBE : ICM_IDR_RBE_Field := 16#0#; -- Write-only. Region Wrap Condition Detected Interrupt Disable RWC : ICM_IDR_RWC_Field := 16#0#; -- Write-only. Region End bit Condition detected Interrupt Disable REC : ICM_IDR_REC_Field := 16#0#; -- Write-only. Region Status Updated Interrupt Disable RSU : ICM_IDR_RSU_Field := 16#0#; -- Write-only. Undefined Register Access Detection Interrupt Disable URAD : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_IDR_Register use record RHC at 0 range 0 .. 3; RDM at 0 range 4 .. 7; RBE at 0 range 8 .. 11; RWC at 0 range 12 .. 15; REC at 0 range 16 .. 19; RSU at 0 range 20 .. 23; URAD at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype ICM_IMR_RHC_Field is HAL.UInt4; subtype ICM_IMR_RDM_Field is HAL.UInt4; subtype ICM_IMR_RBE_Field is HAL.UInt4; subtype ICM_IMR_RWC_Field is HAL.UInt4; subtype ICM_IMR_REC_Field is HAL.UInt4; subtype ICM_IMR_RSU_Field is HAL.UInt4; -- Interrupt Mask type ICM_IMR_Register is record -- Read-only. Region Hash Completed Interrupt Mask RHC : ICM_IMR_RHC_Field; -- Read-only. Region Digest Mismatch Interrupt Mask RDM : ICM_IMR_RDM_Field; -- Read-only. Region Bus Error Interrupt Mask RBE : ICM_IMR_RBE_Field; -- Read-only. Region Wrap Condition Detected Interrupt Mask RWC : ICM_IMR_RWC_Field; -- Read-only. Region End bit Condition Detected Interrupt Mask REC : ICM_IMR_REC_Field; -- Read-only. Region Status Updated Interrupt Mask RSU : ICM_IMR_RSU_Field; -- Read-only. Undefined Register Access Detection Interrupt Mask URAD : Boolean; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_IMR_Register use record RHC at 0 range 0 .. 3; RDM at 0 range 4 .. 7; RBE at 0 range 8 .. 11; RWC at 0 range 12 .. 15; REC at 0 range 16 .. 19; RSU at 0 range 20 .. 23; URAD at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype ICM_ISR_RHC_Field is HAL.UInt4; subtype ICM_ISR_RDM_Field is HAL.UInt4; subtype ICM_ISR_RBE_Field is HAL.UInt4; subtype ICM_ISR_RWC_Field is HAL.UInt4; subtype ICM_ISR_REC_Field is HAL.UInt4; subtype ICM_ISR_RSU_Field is HAL.UInt4; -- Interrupt Status type ICM_ISR_Register is record -- Read-only. Region Hash Completed RHC : ICM_ISR_RHC_Field; -- Read-only. Region Digest Mismatch RDM : ICM_ISR_RDM_Field; -- Read-only. Region Bus Error RBE : ICM_ISR_RBE_Field; -- Read-only. Region Wrap Condition Detected RWC : ICM_ISR_RWC_Field; -- Read-only. Region End bit Condition Detected REC : ICM_ISR_REC_Field; -- Read-only. Region Status Updated Detected RSU : ICM_ISR_RSU_Field; -- Read-only. Undefined Register Access Detection Status URAD : Boolean; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_ISR_Register use record RHC at 0 range 0 .. 3; RDM at 0 range 4 .. 7; RBE at 0 range 8 .. 11; RWC at 0 range 12 .. 15; REC at 0 range 16 .. 19; RSU at 0 range 20 .. 23; URAD at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; -- Undefined Register Access Trace type UASR_URATSelect is (-- Unspecified structure member set to one detected when the descriptor is -- loaded UNSPEC_STRUCT_MEMBER, -- CFG modified during active monitoring CFG_MODIFIED, -- DSCR modified during active monitoring DSCR_MODIFIED, -- HASH modified during active monitoring HASH_MODIFIED, -- Write-only register read access READ_ACCESS) with Size => 3; for UASR_URATSelect use (UNSPEC_STRUCT_MEMBER => 0, CFG_MODIFIED => 1, DSCR_MODIFIED => 2, HASH_MODIFIED => 3, READ_ACCESS => 4); -- Undefined Access Status type ICM_UASR_Register is record -- Read-only. Undefined Register Access Trace URAT : UASR_URATSelect; -- unspecified Reserved_3_31 : HAL.UInt29; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_UASR_Register use record URAT at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype ICM_DSCR_DASA_Field is HAL.UInt26; -- Region Descriptor Area Start Address type ICM_DSCR_Register is record -- unspecified Reserved_0_5 : HAL.UInt6 := 16#0#; -- Descriptor Area Start Address DASA : ICM_DSCR_DASA_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_DSCR_Register use record Reserved_0_5 at 0 range 0 .. 5; DASA at 0 range 6 .. 31; end record; subtype ICM_HASH_HASA_Field is HAL.UInt25; -- Region Hash Area Start Address type ICM_HASH_Register is record -- unspecified Reserved_0_6 : HAL.UInt7 := 16#0#; -- Hash Area Start Address HASA : ICM_HASH_HASA_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICM_HASH_Register use record Reserved_0_6 at 0 range 0 .. 6; HASA at 0 range 7 .. 31; end record; -- User Initial Hash Value n -- User Initial Hash Value n type ICM_UIHVAL_Registers is array (0 .. 7) of HAL.UInt32; ----------------- -- Peripherals -- ----------------- -- Integrity Check Monitor type ICM_Peripheral is record -- Configuration CFG : aliased ICM_CFG_Register; -- Control CTRL : aliased ICM_CTRL_Register; -- Status SR : aliased ICM_SR_Register; -- Interrupt Enable IER : aliased ICM_IER_Register; -- Interrupt Disable IDR : aliased ICM_IDR_Register; -- Interrupt Mask IMR : aliased ICM_IMR_Register; -- Interrupt Status ISR : aliased ICM_ISR_Register; -- Undefined Access Status UASR : aliased ICM_UASR_Register; -- Region Descriptor Area Start Address DSCR : aliased ICM_DSCR_Register; -- Region Hash Area Start Address HASH : aliased ICM_HASH_Register; -- User Initial Hash Value n UIHVAL : aliased ICM_UIHVAL_Registers; end record with Volatile; for ICM_Peripheral use record CFG at 16#0# range 0 .. 31; CTRL at 16#4# range 0 .. 31; SR at 16#8# range 0 .. 31; IER at 16#10# range 0 .. 31; IDR at 16#14# range 0 .. 31; IMR at 16#18# range 0 .. 31; ISR at 16#1C# range 0 .. 31; UASR at 16#20# range 0 .. 31; DSCR at 16#30# range 0 .. 31; HASH at 16#34# range 0 .. 31; UIHVAL at 16#38# range 0 .. 255; end record; -- Integrity Check Monitor ICM_Periph : aliased ICM_Peripheral with Import, Address => ICM_Base; end SAM_SVD.ICM;
with STM32GD.GPIO; with STM32GD.GPIO.Pin; with STM32GD.USART; with STM32GD.USART.Peripheral; with STM32GD.SPI; with STM32GD.SPI.Peripheral; with Drivers; with Drivers.RFM69; with Ada.Interrupts.Names; package Peripherals is package GPIO renames STM32GD.GPIO; package RFM69_RESET is new GPIO.Pin (Pin => GPIO.Pin_2, Port => GPIO.Port_A, Mode => GPIO.Mode_Out); package CSN is new GPIO.Pin (Pin => GPIO.Pin_4, Port => GPIO.Port_A, Mode => GPIO.Mode_Out); package IRQ is new GPIO.Pin (Pin => GPIO.Pin_3, Port => GPIO.Port_A, Mode => GPIO.Mode_In); package SPI is new STM32GD.SPI.Peripheral (SPI => STM32GD.SPI.SPI_1); package Radio is new Drivers.RFM69 (SPI => SPI, Chip_Select => CSN, IRQ => IRQ, Packet_Size => 62, Frequency => 915_000_000); procedure Init; end Peripherals;
package body Util is Invalid_Input_Data : exception; --------- -- B2S -- --------- function B2S (Data : LSC.Types.Bytes) return String is use type LSC.Types.Byte; B, Nibble : LSC.Types.Byte; function Hex_Digit (D : LSC.Types.Byte) return Character is (case D is when 16#0# => '0', when 16#1# => '1', when 16#2# => '2', when 16#3# => '3', when 16#4# => '4', when 16#5# => '5', when 16#6# => '6', when 16#7# => '7', when 16#8# => '8', when 16#9# => '9', when 16#A# => 'a', when 16#b# => 'b', when 16#c# => 'c', when 16#d# => 'd', when 16#e# => 'e', when 16#f# => 'f', when others => '*'); Result_Offset : Natural := 0; begin for D of Data loop Result_Offset := Result_Offset + (if D = 0 then 2 elsif D <= 16#f# then 1 else 0); exit when D > 16#f#; end loop; return Result : String (Result_Offset + 1 .. 2 * Data'Length) do for I in Result'Range loop B := Data (Data'First + (I + 1) / 2 - 1); Nibble := (if I mod 2 = 0 then B and LSC.Types.Byte (16#f#) else B / LSC.Types.Byte (16#10#)); Result (I) := Hex_Digit (Nibble); end loop; end return; end B2S; --------- -- S2B -- --------- function S2B (Data : String) return LSC.Types.Bytes is function To_Byte (C : Character) return LSC.Types.Byte is (case C is when '0' => 16#0#, when '1' => 16#1#, when '2' => 16#2#, when '3' => 16#3#, when '4' => 16#4#, when '5' => 16#5#, when '6' => 16#6#, when '7' => 16#7#, when '8' => 16#8#, when '9' => 16#9#, when 'a' => 16#a#, when 'b' => 16#b#, when 'c' => 16#c#, when 'd' => 16#d#, when 'e' => 16#e#, when 'f' => 16#f#, when 'A' => 16#a#, when 'B' => 16#b#, when 'C' => 16#c#, when 'D' => 16#d#, when 'E' => 16#e#, when 'F' => 16#f#, when others => 16#ff#); function Is_Whitespace (C : Character) return Boolean is (case C is when ' ' => True, when ASCII.HT => True, when others => False); Position : Natural := 1; Num_Nibbles : Natural := 0; Nibble : LSC.Types.Byte; High_Nibble : Boolean; Previous : LSC.Types.Byte := 0; use type LSC.Types.Byte; begin for C of Data loop if To_Byte (C) <= 16#f# then Num_Nibbles := Num_Nibbles + 1; end if; end loop; return Result : LSC.Types.Bytes (1 .. (Num_Nibbles + 1) / 2) do High_Nibble := Num_Nibbles mod 2 = 0; for C of Data loop if not Is_Whitespace (C) then Nibble := To_Byte (C); if Nibble > 16#f# then raise Invalid_Input_Data with ">>>" & Data & "<<<"; end if; if High_Nibble then Previous := 16#10# * Nibble; else Result (Position) := Previous + Nibble; Position := Position + 1; end if; High_Nibble := not High_Nibble; end if; end loop; end return; end S2B; --------- -- T2B -- --------- procedure T2B (Input : String; Output : out LSC.Types.Bytes; Last : out LSC.Types.Natural_Index) is function To_Byte (C : Character) return LSC.Types.Byte is (LSC.Types.Byte (Character'Pos (C))); begin for I in 0 .. Input'Length - 1 loop Output (Output'First + I) := To_Byte (Input (Input'First + I)); end loop; Last := Output'First + Input'Length - 1; end T2B; function T2B (Data : String) return LSC.Types.Bytes is Result : LSC.Types.Bytes (1 .. Data'Length); Unused : LSC.Types.Natural_Index; begin T2B (Data, Result, Unused); pragma Unreferenced (Unused); return Result; end T2B; --------- -- B2T -- --------- function B2T (Data : LSC.Types.Bytes) return String is Result : String (1 .. Data'Length); function To_Character (B : LSC.Types.Byte) return Character is (Character'Val (B)); begin for I in 0 .. Data'Length - 1 loop Result (Result'First + I) := To_Character (Data (Data'First + I)); end loop; return Result; end B2T; end Util;
with Trendy_Test; package Trendy_Test.Assertions is -- Forcibly fail a test. procedure Fail (Op : in out Operation'Class; Message : String; Loc : Source_Location := Make_Source_Location); -- A boolean check which must be passed for the test to continue. procedure Assert (Op : in out Operation'Class; Condition : Boolean; Loc : Source_Location := Make_Source_Location); procedure Assert_EQ (Op : in out Trendy_Test.Operation'Class; Left : String; Right : String; Loc : Source_Location := Make_Source_Location); end Trendy_Test.Assertions;
with Ada.Exception_Identification.From_Here; with Ada.Unchecked_Conversion; package body System.Stream_Attributes is pragma Suppress (All_Checks); use Ada.Exception_Identification.From_Here; use type Ada.Streams.Stream_Element_Offset; type IO_Boolean is new Boolean; for IO_Boolean'Size use ((Boolean'Stream_Size + Ada.Streams.Stream_Element'Size - 1) / Ada.Streams.Stream_Element'Size) * Standard'Storage_Unit; subtype S_AD is Ada.Streams.Stream_Element_Array ( 1 .. Standard'Address_Size * 2 / Ada.Streams.Stream_Element'Size); subtype S_AS is Ada.Streams.Stream_Element_Array ( 1 .. Standard'Address_Size / Ada.Streams.Stream_Element'Size); subtype S_B is Ada.Streams.Stream_Element_Array ( 1 .. IO_Boolean'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_C is Ada.Streams.Stream_Element_Array ( 1 .. Character'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_F is Ada.Streams.Stream_Element_Array ( 1 .. Float'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_I is Ada.Streams.Stream_Element_Array ( 1 .. Integer'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LF is Ada.Streams.Stream_Element_Array ( 1 .. Long_Float'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LI is Ada.Streams.Stream_Element_Array ( 1 .. Long_Integer'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LLF is Ada.Streams.Stream_Element_Array ( 1 .. Long_Long_Float'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LLI is Ada.Streams.Stream_Element_Array ( 1 .. Long_Long_Integer'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LLU is Ada.Streams.Stream_Element_Array ( 1 .. Unsigned_Types.Long_Long_Unsigned'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_LU is Ada.Streams.Stream_Element_Array ( 1 .. Unsigned_Types.Long_Unsigned'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_SF is Ada.Streams.Stream_Element_Array ( 1 .. Short_Float'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_SI is Ada.Streams.Stream_Element_Array ( 1 .. Short_Integer'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_SSI is Ada.Streams.Stream_Element_Array ( 1 .. Short_Short_Integer'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_SSU is Ada.Streams.Stream_Element_Array ( 1 .. Unsigned_Types.Short_Short_Unsigned'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_SU is Ada.Streams.Stream_Element_Array ( 1 .. Unsigned_Types.Short_Unsigned'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_U is Ada.Streams.Stream_Element_Array ( 1 .. Unsigned_Types.Unsigned'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_WC is Ada.Streams.Stream_Element_Array ( 1 .. Wide_Character'Stream_Size / Ada.Streams.Stream_Element'Size); subtype S_WWC is Ada.Streams.Stream_Element_Array ( 1 .. Wide_Wide_Character'Stream_Size / Ada.Streams.Stream_Element'Size); procedure Read_Just ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out Ada.Streams.Stream_Element_Array; Line : Integer := Ada.Debug.Line); procedure Read_Just ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out Ada.Streams.Stream_Element_Array; Line : Integer := Ada.Debug.Line) is Last : Ada.Streams.Stream_Element_Offset; begin Ada.Streams.Read (Stream.all, Item, Last); if Last < Item'Last then Raise_Exception (End_Error'Identity, Line => Line); end if; end Read_Just; -- implementation function I_AD (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Fat_Pointer is function Cast is new Ada.Unchecked_Conversion (S_AD, Fat_Pointer); Buffer : S_AD; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_AD; function I_AS (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Thin_Pointer is function Cast is new Ada.Unchecked_Conversion (S_AS, Thin_Pointer); Buffer : S_AS; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_AS; function I_B (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Boolean is function Cast is new Ada.Unchecked_Conversion (S_B, IO_Boolean); Buffer : S_B; begin Read_Just (Stream, Buffer); return Boolean (Cast (Buffer)); end I_B; function I_C (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Character is function Cast is new Ada.Unchecked_Conversion (S_C, Character); Buffer : S_C; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_C; function I_F (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Float is function Cast is new Ada.Unchecked_Conversion (S_F, Float); Buffer : S_F; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_F; function I_I (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Integer is function Cast is new Ada.Unchecked_Conversion (S_I, Integer); Buffer : S_I; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_I; function I_LF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Float is function Cast is new Ada.Unchecked_Conversion (S_LF, Long_Float); Buffer : S_LF; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LF; function I_LI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Integer is function Cast is new Ada.Unchecked_Conversion (S_LI, Long_Integer); Buffer : S_LI; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LI; function I_LLF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Long_Float is function Cast is new Ada.Unchecked_Conversion (S_LLF, Long_Long_Float); Buffer : S_LLF; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LLF; function I_LLI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Long_Integer is function Cast is new Ada.Unchecked_Conversion (S_LLI, Long_Long_Integer); Buffer : S_LLI; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LLI; function I_LLU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Long_Long_Unsigned is function Cast is new Ada.Unchecked_Conversion ( S_LLU, Unsigned_Types.Long_Long_Unsigned); Buffer : S_LLU; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LLU; function I_LU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Long_Unsigned is function Cast is new Ada.Unchecked_Conversion (S_LU, Unsigned_Types.Long_Unsigned); Buffer : S_LU; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_LU; function I_SF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Float is function Cast is new Ada.Unchecked_Conversion (S_SF, Short_Float); Buffer : S_SF; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_SF; function I_SI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Integer is function Cast is new Ada.Unchecked_Conversion (S_SI, Short_Integer); Buffer : S_SI; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_SI; function I_SSI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Short_Integer is function Cast is new Ada.Unchecked_Conversion (S_SSI, Short_Short_Integer); Buffer : S_SSI; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_SSI; function I_SSU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Short_Short_Unsigned is function Cast is new Ada.Unchecked_Conversion ( S_SSU, Unsigned_Types.Short_Short_Unsigned); Buffer : S_SSU; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_SSU; function I_SU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Short_Unsigned is function Cast is new Ada.Unchecked_Conversion (S_SU, Unsigned_Types.Short_Unsigned); Buffer : S_SU; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_SU; function I_U (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Unsigned is function Cast is new Ada.Unchecked_Conversion (S_U, Unsigned_Types.Unsigned); Buffer : S_U; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_U; function I_WC (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Wide_Character is function Cast is new Ada.Unchecked_Conversion (S_WC, Wide_Character); Buffer : S_WC; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_WC; function I_WWC (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Wide_Wide_Character is function Cast is new Ada.Unchecked_Conversion (S_WWC, Wide_Wide_Character); Buffer : S_WWC; begin Read_Just (Stream, Buffer); return Cast (Buffer); end I_WWC; procedure W_AD ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Fat_Pointer) is function Cast is new Ada.Unchecked_Conversion (Fat_Pointer, S_AD); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_AD; procedure W_AS ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Thin_Pointer) is function Cast is new Ada.Unchecked_Conversion (Thin_Pointer, S_AS); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_AS; procedure W_B ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Boolean) is function Cast is new Ada.Unchecked_Conversion (IO_Boolean, S_B); begin Ada.Streams.Write (Stream.all, Cast (IO_Boolean (Item))); end W_B; procedure W_C ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Character) is function Cast is new Ada.Unchecked_Conversion (Character, S_C); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_C; procedure W_F ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Float) is function Cast is new Ada.Unchecked_Conversion (Float, S_F); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_F; procedure W_I ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Integer) is function Cast is new Ada.Unchecked_Conversion (Integer, S_I); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_I; procedure W_LF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Float) is function Cast is new Ada.Unchecked_Conversion (Long_Float, S_LF); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LF; procedure W_LI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Integer) is function Cast is new Ada.Unchecked_Conversion (Long_Integer, S_LI); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LI; procedure W_LLF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Long_Float) is function Cast is new Ada.Unchecked_Conversion (Long_Long_Float, S_LLF); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LLF; procedure W_LLI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Long_Integer) is function Cast is new Ada.Unchecked_Conversion (Long_Long_Integer, S_LLI); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LLI; procedure W_LLU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Long_Long_Unsigned) is function Cast is new Ada.Unchecked_Conversion ( Unsigned_Types.Long_Long_Unsigned, S_LLU); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LLU; procedure W_LU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Long_Unsigned) is function Cast is new Ada.Unchecked_Conversion (Unsigned_Types.Long_Unsigned, S_LU); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_LU; procedure W_SF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Float) is function Cast is new Ada.Unchecked_Conversion (Short_Float, S_SF); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_SF; procedure W_SI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Integer) is function Cast is new Ada.Unchecked_Conversion (Short_Integer, S_SI); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_SI; procedure W_SSI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Short_Integer) is function Cast is new Ada.Unchecked_Conversion (Short_Short_Integer, S_SSI); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_SSI; procedure W_SSU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Short_Short_Unsigned) is function Cast is new Ada.Unchecked_Conversion ( Unsigned_Types.Short_Short_Unsigned, S_SSU); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_SSU; procedure W_SU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Short_Unsigned) is function Cast is new Ada.Unchecked_Conversion (Unsigned_Types.Short_Unsigned, S_SU); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_SU; procedure W_U ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Unsigned) is function Cast is new Ada.Unchecked_Conversion (Unsigned_Types.Unsigned, S_U); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_U; procedure W_WC ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Wide_Character) is function Cast is new Ada.Unchecked_Conversion (Wide_Character, S_WC); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_WC; procedure W_WWC ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Wide_Wide_Character) is function Cast is new Ada.Unchecked_Conversion (Wide_Wide_Character, S_WWC); begin Ada.Streams.Write (Stream.all, Cast (Item)); end W_WWC; end System.Stream_Attributes;
with Ada.Text_IO; use Ada.Text_IO; -- Dans ce programme, les commentaires de spécification -- ont **volontairement** été omis ! procedure Comprendre_Mode_Parametre is function Double (N : in Integer) return Integer is begin return 2 * N; end Double; procedure Incrementer (N : in out Integer) is begin N := N + 1; end Incrementer; procedure Mettre_A_Zero (N : out Integer) is begin N := 0; end Mettre_A_Zero; procedure Comprendre_Les_Contraintes_Sur_L_Appelant is A, B, R : Integer; begin A := 5; -- Indiquer pour chacune des instructions suivantes si elles sont -- acceptées par le compilateur. R := Double (A);--OK R := Double (10);--OK R := Double (10 * A);--OK R := Double (B);--B N'EST PAS INITIALSÉ Incrementer (A);--OK Incrementer (10);--ON'EST PAS UNE VARIABLE Incrementer (10 * A);--N'EST PAS UNE VARIABLE Incrementer (B);--B N'EST PAS INITIALSÉ Mettre_A_Zero (A);--OK Mettre_A_Zero (10);--10 N'EST PAS UNE VARIABLE Mettre_A_Zero (10 * A);--10 * A N'EST PAS UNE VARIABLE Mettre_A_Zero (B);--B N'EST PAS INITIALSÉ end Comprendre_Les_Contraintes_Sur_L_Appelant; procedure Comprendre_Les_Contrainte_Dans_Le_Corps ( A : in Integer; B1, B2 : in out Integer; C1, C2 : out Integer) is L: Integer; begin -- pour chaque affectation suivante indiquer si elle est autorisée L := A;--OK MAIS DANS LA LIGNE 60 ON RÉINITIALISE L ALORS UNITILE A := 1;--A N'EST PAS EN OUT B1 := 5;--OK L := B2;--OK B2 := B2 + 1;--OK C1 := L;--OK L := C2;--NON C2 N'EST PAS EN IN C2 := A;--OK C2 := C2 + 1;-- end Comprendre_Les_Contrainte_Dans_Le_Corps; begin Comprendre_Les_Contraintes_Sur_L_Appelant; Put_Line ("Fin"); end Comprendre_Mode_Parametre;
----------------------------------------------------------------------- -- html-selects -- ASF HTML UISelectOne and UISelectMany components -- Copyright (C) 2011, 2013, 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 ASF.Components.Base; with ASF.Components.Html.Forms; with ASF.Models.Selects; with Util.Beans.Objects; -- The <b>Selects</b> package implements various components used in forms to select -- one or many choices from a list. -- -- See JSR 314 - JavaServer Faces Specification 4.1.14 UISelectItem -- See JSR 314 - JavaServer Faces Specification 4.1.15 UISelectItems -- See JSR 314 - JavaServer Faces Specification 4.1.16 UISelectMany -- See JSR 314 - JavaServer Faces Specification 4.1.17 UISelectOne package ASF.Components.Html.Selects is -- ------------------------------ -- UISelectBoolean Component -- ------------------------------ -- The <b>UISelectBoolean</b> is a component that represents a single boolean value. type UISelectBoolean is new Forms.UIInput with private; type UISelectBoolean_Access is access all UISelectBoolean'Class; -- Render the checkbox element. overriding procedure Render_Input (UI : in UISelectBoolean; Context : in out Faces_Context'Class; Write_Id : in Boolean := True); -- Convert the string into a value. If a converter is specified on the component, -- use it to convert the value. Make sure the result is a boolean. overriding function Convert_Value (UI : in UISelectBoolean; Value : in String; Context : in Faces_Context'Class) return EL.Objects.Object; -- ------------------------------ -- UISelectItem Component -- ------------------------------ -- The <b>UISelectItem</b> is a component that may be nested inside a <b>UISelectMany</b> -- or <b>UISelectOne</b> component and represents exactly one <b>Select_Item</b>. type UISelectItem is new Core.UILeaf with private; type UISelectItem_Access is access all UISelectItem'Class; -- Get the <b>Select_Item</b> represented by the component. function Get_Select_Item (From : in UISelectItem; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item; -- ------------------------------ -- UISelectItems Component -- ------------------------------ -- The <b>UISelectItems</b> is a component that may be nested inside a <b>UISelectMany</b> -- or <b>UISelectOne</b> component and represents zero or more <b>Select_Item</b>. type UISelectItems is new Core.UILeaf with private; type UISelectItems_Access is access all UISelectItems'Class; -- Get the <b>Select_Item</b> represented by the component. function Get_Select_Item_List (From : in UISelectItems; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item_List; -- ------------------------------ -- SelectOne Component -- ------------------------------ -- The <b>UISelectOne</b> is a component that represents zero or one selection from -- a list of available options. type UISelectOne is new Forms.UIInput with private; type UISelectOne_Access is access all UISelectOne'Class; -- Render the <b>select</b> element. overriding procedure Encode_Begin (UI : in UISelectOne; Context : in out Faces_Context'Class); -- Renders the <b>select</b> element. This is called by <b>Encode_Begin</b> if -- the component is rendered. procedure Render_Select (UI : in UISelectOne; Context : in out Faces_Context'Class); -- Renders the <b>option</b> element. This is called by <b>Render_Select</b> to -- generate the component options. procedure Render_Options (UI : in UISelectOne; Value : in Util.Beans.Objects.Object; Context : in out Faces_Context'Class); -- ------------------------------ -- SelectOneRadio Component -- ------------------------------ -- The <b>UISelectOneRadio</b> is a component that represents zero or one selection from -- a list of available options. type UISelectOneRadio is new UISelectOne with private; type UISelectOneRadio_Access is access all UISelectOneRadio'Class; -- Returns True if the radio options must be rendered vertically. function Is_Vertical (UI : in UISelectOneRadio; Context : in Faces_Context'Class) return Boolean; -- Renders the <b>select</b> element. This is called by <b>Encode_Begin</b> if -- the component is rendered. overriding procedure Render_Select (UI : in UISelectOneRadio; Context : in out Faces_Context'Class); -- ------------------------------ -- Iterator over the Select_Item elements -- ------------------------------ type Cursor is limited private; -- Get an iterator to scan the component children. -- SCz 2011-11-07: due to a bug in GNAT, we cannot use a function for First because -- the inner member 'List' is not copied correctly if the 'Cursor' is a limited type. -- Fallback to the Ada95 way. procedure First (UI : in UISelectOne'Class; Context : in Faces_Context'Class; Iterator : out Cursor); -- Returns True if the iterator points to a valid child. function Has_Element (Pos : in Cursor) return Boolean; -- Get the child component pointed to by the iterator. function Element (Pos : in Cursor; Context : in Faces_Context'Class) return ASF.Models.Selects.Select_Item; -- Move to the next child. procedure Next (Pos : in out Cursor; Context : in Faces_Context'Class); private type UISelectBoolean is new Forms.UIInput with null record; type Cursor is limited record List : ASF.Models.Selects.Select_Item_List; Component : ASF.Components.Base.Cursor; Current : ASF.Components.Base.UIComponent_Access := null; Pos : Natural := 0; Last : Natural := 0; end record; type UISelectItem is new Core.UILeaf with null record; type UISelectItems is new Core.UILeaf with null record; type UISelectOne is new Forms.UIInput with null record; type UISelectOneRadio is new UISelectOne with null record; end ASF.Components.Html.Selects;
-- Copyright (c) 2006-2020 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body JWS.Integers is type Double is mod 2 ** (2 * Digit_Size); subtype Double_Digit is Double range 0 .. 2 ** Digit_Size - 1; procedure Devide (Left : in out Number; Right : in Number; Result : out Digit) with Pre => Left'Length = Right'Length + 1 and Right'Length >= 2 and Left (Right'Range) < Right; --------- -- Add -- --------- procedure Add (A : in out Number; B : Number) is Result : Number renames A; Temp : Double; Carry : Double_Digit := 0; begin for J in reverse 1 .. A'Length loop Temp := Double (A (J)) + Double (B (J)) + Carry; Result (J) := Digit'Mod (Temp); Carry := Temp / Digit'Modulus; end loop; end Add; --------- -- Add -- --------- procedure Add (A, B : Number; Result : out Number; C : Digit) is Mult : constant Double_Digit := Double_Digit (C); Temp : Double; Carry : Double_Digit := 0; begin for J in reverse 1 .. A'Length loop Temp := Double (A (J)) + Double (B (J)) * Mult + Carry; Result (J + 1) := Digit'Mod (Temp); Carry := Temp / Digit'Modulus; end loop; Result (1) := Digit (Carry); end Add; ---------------- -- BER_Decode -- ---------------- procedure BER_Decode (Raw : Ada.Streams.Stream_Element_Array; Value : out Number) is use type Ada.Streams.Stream_Element_Offset; function N (X : Ada.Streams.Stream_Element_Offset) return Digit; ------- -- N -- ------- function N (X : Ada.Streams.Stream_Element_Offset) return Digit is begin if X in Raw'Range then return Digit (Raw (X)); else return 0; end if; end N; X : Ada.Streams.Stream_Element_Offset := Raw'Last; begin for J in reverse Value'Range loop Value (J) := 256 * (256 * (256 * N (X - 3) + N (X - 2)) + N (X - 1)) + N (X); X := X - 4; end loop; end BER_Decode; ---------------- -- BER_Encode -- ---------------- procedure BER_Encode (Value : Number; Raw : out Ada.Streams.Stream_Element_Array) is X : Ada.Streams.Stream_Element_Offset := Raw'Last; V : Digit; begin for J in reverse Value'Range loop V := Value (J); for K in 1 .. 4 loop Raw (X) := Ada.Streams.Stream_Element'Mod (V); V := V / 256; X := Ada.Streams.Stream_Element_Offset'Pred (X); end loop; end loop; end BER_Encode; ---------------- -- BER_Length -- ---------------- function BER_Length (Raw : Ada.Streams.Stream_Element_Array) return Positive is use type Ada.Streams.Stream_Element; Result : constant Natural := Raw'Length / 4; begin if Result = 0 then return 1; elsif Raw'Length = (Result - 1) * 4 + 1 and then Raw (Raw'First) = 0 then -- Last extra byte contains zero return Result - 1; else return Result; end if; end BER_Length; ------------ -- Devide -- ------------ procedure Devide (Left : in out Number; Right : in Number; Result : out Digit) is function Get_Digit (Left, Right : Number) return Digit with Pre => Left'Length = Right'Length + 1 and Right'Length >= 2 and Left (Right'Range) < Right; function Get_Digit (Left, Right : Number) return Digit is QHAT : Double_Digit; RHAT : Double_Digit; Temp : Double; begin if Left (1) = Right (1) then Temp := Double_Digit (Left (2)) + Double_Digit (Right (1)); if Temp >= Digit'Modulus then return Digit'Last; end if; RHAT := Temp; QHAT := Digit'Modulus - 1; elsif Left (1) < Right (1) then declare L12 : constant Double := Digit'Modulus * Double_Digit (Left (1)) + Double_Digit (Left (2)); begin QHAT := L12 / Double_Digit (Right (1)); -- < Digit'Modulus RHAT := L12 mod Double_Digit (Right (1)); end; else raise Program_Error; end if; while QHAT * Double_Digit (Right (2)) > RHAT * Digit'Modulus + Double_Digit (Left (3)) loop QHAT := QHAT - 1; Temp := RHAT + Double_Digit (Right (1)); exit when Temp >= Digit'Modulus; RHAT := Temp; end loop; return Digit (QHAT); end Get_Digit; Ok : Boolean; begin Result := Get_Digit (Left, Right); Subtract (A => Left, B => Right, C => Result, Ok => Ok); if not Ok then Result := Result - 1; Add (A => Left, B => 0 & Right); end if; end Devide; ----------------- -- Fast_Devide -- ----------------- procedure Fast_Devide (A : Number; B : Digit; Result : out Number; Rest : out Digit) is Div : constant Double_Digit := Double_Digit (B); Carry : Double_Digit := 0; Temp : Double; begin for J in A'Range loop Temp := Carry * Digit'Modulus + Double_Digit (A (J)); Result (J) := Digit (Temp / Div); Carry := Temp mod Div; end loop; Rest := Digit (Carry); end Fast_Devide; -------------- -- Multiply -- -------------- procedure Multiply (A, B : Number; Result : out Number) is Mult : constant Number (Result'Range) := B & (A'Range => 0); Temp : Digit; begin Result (B'Range) := (B'Range => 0); for J in 1 .. A'Length loop Temp := A (A'Length - J + 1); Add (Result (1 .. B'Length + J - 1), Mult (1 .. B'Length + J - 1), Result (1 .. B'Length + J), Temp); end loop; end Multiply; -------------------------- -- Normalize_For_Devide -- -------------------------- procedure Normalize_For_Devide (A : Number; B : in out Number; A_Copy : in out Number; Mult : out Digit) with Pre => A_Copy'Length >= A'Length + 1; procedure Normalize_For_Devide (A : Number; B : in out Number; A_Copy : in out Number; Mult : out Digit) is begin Mult := Digit (Digit'Modulus / (Double_Digit (B (1)) + 1)); if Mult = 1 then A_Copy := (1 .. A_Copy'Length - A'Length => 0) & A; else declare Zero : constant Number (1 .. A_Copy'Length - 1) := (others => 0); begin Add (A => Zero, B => (1 .. Zero'Length - A'Length => 0) & A, Result => A_Copy, C => Mult); end; declare Temp : Number (1 .. B'Length + 1); begin Add (A => (B'Range => 0), B => B, Result => Temp, C => Mult); pragma Assert (Temp (1) = 0); B (1 .. B'Last) := Temp (2 .. Temp'Last); end; end if; end Normalize_For_Devide; procedure Power (Value : Number; Exponent : Number; Module : Number; Result : out Number) is Mult : Number (Module'Range); Mask : Digit := 1; J : Natural := Exponent'Last; begin if Value'Length < Module'Length or else (Value'Length = Module'Length and then Value <= Module) then Mult := (1 .. Module'Length - Value'Length => 0) & Value; else Remainder (Value, Module, Mult); end if; Result := (1 .. Result'Last - 1 => 0) & 1; while J > 0 loop if (Exponent (J) and Mask) /= 0 then declare Temp : Number (1 .. Result'Length + Mult'Length); begin Multiply (Result, Mult, Temp); Remainder (Temp, Module, Result); end; end if; declare Temp : Number (1 .. 2 * Mult'Length); begin Multiply (Mult, Mult, Temp); Remainder (Temp, Module, Mult); end; if Mask = 2 ** (Digit_Size - 1) then J := J - 1; Mask := 1; else Mask := Mask * 2; end if; end loop; end Power; --------------- -- Remainder -- --------------- procedure Remainder (A, B : Number; Result : out Number) is begin if A (B'Last + 1 .. A'Last) = (B'Last + 1 .. A'Last => 0) and then A (B'Range) < B then Result := A (B'Range); elsif B'Length = 1 then declare Ignore : Number (A'Range); begin Fast_Devide (A, B (1), Ignore, Result (1)); end; else declare Length : constant Positive := Positive'Max (B'Length + 2, A'Length + 1); A_Copy : Number (1 .. Length); B_Copy : Number := B; Temp : Number (1 .. 1 + B'Length); Mult : Digit; Ignore : Digit; begin Normalize_For_Devide (A, B_Copy, A_Copy, Mult); Temp (1 .. 1 + B'Length) := A_Copy (1 .. 1 + B'Length); for Index in 1 .. A_Copy'Length - B'Length loop Temp (Temp'Last) := A_Copy (Index + B'Length); Devide (Left => Temp, Right => B_Copy, Result => Ignore); pragma Assert (Temp (1) = 0); Temp (1 .. B'Length) := Temp (2 .. Temp'Last); end loop; if Mult = 1 then Result := Temp (1 .. Result'Length); else Fast_Devide (A => Temp (1 .. Result'Length), B => Mult, Result => Result, Rest => Ignore); end if; end; end if; end Remainder; -------------- -- Subtract -- -------------- procedure Subtract (A : in out Number; B : Number; C : Digit := 1; Ok : out Boolean) is Result : Number renames A; Mult : constant Double_Digit := Double_Digit (C); Temp : Double; Carry : Digit := 0; begin for J in reverse 1 .. B'Length loop Temp := Double (A (J + 1)) - Double (B (J)) * Mult - Double_Digit (Carry); Result (J + 1) := Digit'Mod (Temp); Carry := -Digit (Temp / Digit'Modulus); end loop; Ok := A (1) >= Carry; Result (1) := A (1) - Carry; end Subtract; end JWS.Integers;
type Point is tagged record X : Integer := 0; Y : Integer := 0; end record;
package body GMP.Random is use type C.unsigned_long; function Initialize return Generator is begin return (State => Initialize); end Initialize; function Initialize (Initiator : Long_Integer) return Generator is begin return (State => Initialize (Initiator)); end Initialize; procedure Reset (Gen : in out Generator) is begin Gen.State := Initialize; end Reset; procedure Reset (Gen : in out Generator; Initiator : Long_Integer) is begin Gen.State := Initialize (Initiator); end Reset; function Initialize return State is begin return Result : State do pragma Unreferenced (Result); null; end return; end Initialize; function Initialize (Initiator : Long_Integer) return State is pragma Suppress (Overflow_Check); pragma Suppress (Range_Check); begin return Result : State do C.gmp.gmp_randseed_ui ( Controlled.Reference (Result), C.unsigned_long'Mod (Initiator)); end return; end Initialize; function Save (Gen : Generator) return State is begin return Gen.State; end Save; procedure Save (Gen : Generator; To_State : out State) is begin To_State := Gen.State; end Save; function Reset (From_State : State) return Generator is begin return (State => From_State); end Reset; procedure Reset (Gen : in out Generator; From_State : State) is begin Gen.State := From_State; end Reset; function Random (Gen : aliased in out Generator) return Long_Integer is pragma Suppress (Overflow_Check); pragma Suppress (Range_Check); begin return Long_Integer (C.gmp.gmp_urandomb_ui ( Controlled.Reference (Gen.State), Long_Integer'Size)); end Random; package body Discrete_Random is function Random (Gen : aliased in out Generator) return Result_Subtype is Result_Width : constant C.unsigned_long := Result_Subtype'Pos (Result_Subtype'Last) - Result_Subtype'Pos (Result_Subtype'First) + 1; begin return Result_Subtype'Val ( C.gmp.gmp_urandomm_ui (Controlled.Reference (Gen.State), Result_Width) + Result_Subtype'Pos (Result_Subtype'First)); end Random; end Discrete_Random; package body Controlled is function View_Reference (Item : in out State) return not null access C.gmp.gmp_randstate_struct; pragma Inline (View_Reference); function View_Reference (Item : in out State) return not null access C.gmp.gmp_randstate_struct is begin return Item.Raw (0)'Unchecked_Access; end View_Reference; -- implementation function Reference (Item : in out GMP.Random.State) return not null access C.gmp.gmp_randstate_struct is begin return View_Reference (State (Item)); -- view conversion end Reference; function Constant_Reference (Item : GMP.Random.State) return not null access constant C.gmp.gmp_randstate_struct is begin return State (Item).Raw (0)'Unchecked_Access; end Constant_Reference; overriding procedure Initialize (Object : in out State) is begin C.gmp.gmp_randinit_default (Object.Raw (0)'Access); end Initialize; overriding procedure Adjust (Object : in out State) is Old : constant C.gmp.gmp_randstate_t := Object.Raw; begin C.gmp.gmp_randinit_set (Object.Raw (0)'Access, Old (0)'Access); end Adjust; overriding procedure Finalize (Object : in out State) is begin C.gmp.gmp_randclear (Object.Raw (0)'Access); end Finalize; end Controlled; end GMP.Random;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- F N A M E . S F -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Casing; use Casing; with Fname; use Fname; with Fname.UF; use Fname.UF; with SFN_Scan; use SFN_Scan; with Osint; use Osint; with Types; use Types; with Unchecked_Conversion; package body Fname.SF is function To_Big_String_Ptr is new Unchecked_Conversion (Source_Buffer_Ptr, Big_String_Ptr); ---------------------- -- Local Procedures -- ---------------------- procedure Set_File_Name (Typ : Character; U : String; F : String; Index : Natural); -- This is a transfer function that is called from Scan_SFN_Pragmas, -- and reformats its parameters appropriately for the version of -- Set_File_Name found in Fname.SF. procedure Set_File_Name_Pattern (Pat : String; Typ : Character; Dot : String; Cas : Character); -- This is a transfer function that is called from Scan_SFN_Pragmas, -- and reformats its parameters appropriately for the version of -- Set_File_Name_Pattern found in Fname.SF. ----------------------------------- -- Read_Source_File_Name_Pragmas -- ----------------------------------- procedure Read_Source_File_Name_Pragmas is Src : Source_Buffer_Ptr; Hi : Source_Ptr; BS : Big_String_Ptr; SP : String_Ptr; begin Name_Buffer (1 .. 8) := "gnat.adc"; Name_Len := 8; Read_Source_File (Name_Enter, 0, Hi, Src); if Src /= null then BS := To_Big_String_Ptr (Src); SP := BS (1 .. Natural (Hi))'Unrestricted_Access; Scan_SFN_Pragmas (SP.all, Set_File_Name'Access, Set_File_Name_Pattern'Access); end if; end Read_Source_File_Name_Pragmas; ------------------- -- Set_File_Name -- ------------------- procedure Set_File_Name (Typ : Character; U : String; F : String; Index : Natural) is Unm : Unit_Name_Type; Fnm : File_Name_Type; begin Name_Buffer (1 .. U'Length) := U; Name_Len := U'Length; Set_Casing (All_Lower_Case); Name_Buffer (Name_Len + 1) := '%'; Name_Buffer (Name_Len + 2) := Typ; Name_Len := Name_Len + 2; Unm := Name_Find; Name_Buffer (1 .. F'Length) := F; Name_Len := F'Length; Fnm := Name_Find; Fname.UF.Set_File_Name (Unm, Fnm, Nat (Index)); end Set_File_Name; --------------------------- -- Set_File_Name_Pattern -- --------------------------- procedure Set_File_Name_Pattern (Pat : String; Typ : Character; Dot : String; Cas : Character) is Ctyp : Casing_Type; Patp : constant String_Ptr := new String'(Pat); Dotp : constant String_Ptr := new String'(Dot); begin if Cas = 'l' then Ctyp := All_Lower_Case; elsif Cas = 'u' then Ctyp := All_Upper_Case; else -- Cas = 'm' Ctyp := Mixed_Case; end if; Fname.UF.Set_File_Name_Pattern (Patp, Typ, Dotp, Ctyp); end Set_File_Name_Pattern; end Fname.SF;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with System; with Interfaces.C; with GL.Low_Level; -- This package is incomplete. As I do not develop or test under Linux, this -- has very low priority. Perhaps someone wants to help out... package GL.GLX is pragma Preelaborate; -- needed types from Xlib type XID is new Interfaces.C.unsigned_long; type GLX_Context is new System.Address; type GLX_Drawable is new XID; type Screen_Depth is new Natural; type Screen_Number is new Natural; type Visual_ID is new XID; type Display_Pointer is new System.Address; type X_Visual_Info is record Visual : System.Address; Visual_Ident : Visual_ID; Screen : Screen_Number; Depth : Screen_Depth; Class : Integer; Red_Mask : Long_Integer; Green_Mask : Long_Integer; Blue_Mask : Long_Integer; Colormap_Size : Natural; Bits_Per_RGB : Natural; end record; pragma Convention (C_Pass_By_Copy, X_Visual_Info); type X_Visual_Info_Pointer is access all X_Visual_Info; pragma Convention (C, X_Visual_Info_Pointer); function Create_Context (Display : Display_Pointer; Visual : X_Visual_Info_Pointer; Share_List : GLX_Context; Direct : Low_Level.Bool) return GLX_Context; function Make_Current (Display : Display_Pointer; Drawable : GLX_Drawable; Context : GLX_Context) return Low_Level.Bool; function Make_Context_Current (Display : Display_Pointer; Draw : GLX_Drawable; Read : GLX_Drawable; Context : GLX_Context) return Low_Level.Bool; function Get_Current_Context return System.Address; function Get_Current_Display return System.Address; function Get_Proc_Address (Name : Interfaces.C.char_array) return System.Address; private pragma Import (C, Create_Context, "glXCreateContext"); pragma Import (C, Make_Current, "glXMakeCurrent"); pragma Import (C, Make_Context_Current, "glXMakeContextCurrent"); pragma Import (C, Get_Current_Context, "glXGetCurrentContext"); pragma Import (C, Get_Current_Display, "glXGetCurrentDisplay"); pragma Import (C, Get_Proc_Address, "glXGetProcAddress"); end GL.GLX;
with openGL.Errors, openGL.Tasks, openGL.IO, GL.Binding, GL.lean, GL.Pointers, ada.unchecked_Deallocation; package body openGL.Texture is use GL, GL.lean, GL.Pointers; ---------------- -- Texture Name -- function new_texture_Name return texture_Name is use GL.Binding; the_Name : aliased texture_Name; begin Tasks.check; glGenTextures (1, the_Name'Access); return the_Name; end new_texture_Name; procedure free (the_texture_Name : in texture_Name) is the_Name : aliased texture_Name := the_texture_Name; begin Tasks.check; glDeleteTextures (1, the_Name'Access); end free; --------- -- Forge -- package body Forge is function to_Texture (Name : in texture_Name) return Object is Self : Texture.Object; begin Self.Name := Name; -- TODO: Fill in remaining fields by querying GL. return Self; end to_Texture; function to_Texture (Dimensions : in Texture.Dimensions) return Object is use GL.Binding; Self : aliased Texture.Object; begin Tasks.check; Self.Dimensions := Dimensions; Self.Name := new_texture_Name; Self.enable; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); return Self; end to_Texture; function to_Texture (the_Image : in Image; use_Mipmaps : in Boolean := True) return Object is Self : aliased Texture.Object; begin Self.Name := new_texture_Name; Self.set_Image (the_Image, use_Mipmaps); return Self; end to_Texture; function to_Texture (the_Image : in lucid_Image; use_Mipmaps : in Boolean := True) return Object is Self : aliased Texture.Object; begin Self.Name := new_texture_Name; Self.set_Image (the_Image, use_Mipmaps); return Self; end to_Texture; end Forge; procedure destroy (Self : in out Object) is begin free (Self.Name); -- Release the GL texture name. end destroy; procedure free (Self : in out Object) is begin free (Self.Pool.all, Self); -- Release 'Self' from it's pool for later re-use. end free; function is_Defined (Self : in Object) return Boolean is use type texture_Name; begin return Self.Name /= 0; end is_Defined; procedure set_Name (Self : in out Object; To : in texture_Name) is begin Self.Name := To; end set_Name; function Name (Self : in Object) return texture_Name is begin return Self.Name; end Name; procedure set_Image (Self : in out Object; To : in Image; use_Mipmaps : in Boolean := True) is use GL.Binding; the_Image : Image renames To; min_Width : constant Positive := the_Image'Length (2); min_Height : constant Positive := the_Image'Length (1); begin Tasks.check; Self.is_Transparent := False; Self.Dimensions.Width := min_Width; Self.Dimensions.Height := min_Height; Self.enable; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); Errors.log; glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, GLsizei (Self.Dimensions.Width), GLsizei (Self.Dimensions.Height), 0, GL_RGB, GL_UNSIGNED_BYTE, +the_Image (1, 1).Red'Address); Errors.log; if use_Mipmaps then glGenerateMipmap (GL_TEXTURE_2D); Errors.log; end if; end set_Image; procedure set_Image (Self : in out Object; To : in lucid_Image; use_Mipmaps : in Boolean := True) is use GL.Binding; the_Image : lucid_Image renames To; min_Width : constant Positive := the_Image'Length (2); min_Height : constant Positive := the_Image'Length (1); begin Tasks.check; Self.is_Transparent := True; Self.Dimensions.Width := min_Width; Self.Dimensions.Height := min_Height; Self.enable; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); Errors.log; glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, GLsizei (Self.Dimensions.Width), GLsizei (Self.Dimensions.Height), 0, GL_RGBA, GL_UNSIGNED_BYTE, +the_Image (1, 1).Primary.Red'Address); Errors.log; if use_Mipmaps then glGenerateMipmap (GL_TEXTURE_2D); Errors.log; end if; end set_Image; function is_Transparent (Self : in Object) return Boolean is begin return Self.is_Transparent; end is_Transparent; procedure enable (Self : in Object) is use GL.Binding; use type GL.GLuint; pragma Assert (Self.Name > 0); begin Tasks.check; glBindTexture (GL.GL_TEXTURE_2D, Self.Name); end enable; function Power_of_2_Ceiling (From : in Positive) return GL.GLsizei is use type GL.GLsizei; begin if From <= 2 then return 2; elsif From <= 4 then return 4; elsif From <= 8 then return 8; elsif From <= 16 then return 16; elsif From <= 32 then return 32; elsif From <= 64 then return 64; elsif From <= 128 then return 128; elsif From <= 256 then return 256; elsif From <= 512 then return 512; elsif From <= 1024 then return 1024; elsif From <= 2 * 1024 then return 2 * 1024; elsif From <= 4 * 1024 then return 4 * 1024; elsif From <= 8 * 1024 then return 8 * 1024; elsif From <= 16 * 1024 then return 16 * 1024; elsif From <= 32 * 1024 then return 32 * 1024; end if; raise Constraint_Error with "Texture size too large:" & From'Image; end Power_of_2_Ceiling; function Size (Self : in Object) return Texture.Dimensions is begin return Self.Dimensions; end Size; ----------------------- -- Name Maps of Texture -- function fetch (From : access name_Map_of_texture'Class; texture_Name : in asset_Name) return Object is Name : constant unbounded_String := to_unbounded_String (to_String (texture_Name)); begin if From.Contains (Name) then return From.Element (Name); else declare new_Texture : constant Object := IO.to_Texture (texture_Name); begin From.insert (Name, new_Texture); return new_Texture; end; end if; end fetch; -------- -- Pool -- procedure destroy (the_Pool : in out Pool) is procedure deallocate is new ada.unchecked_Deallocation (pool_texture_List, pool_texture_List_view); begin for Each of the_Pool.Map loop for i in 1 .. Each.Last loop destroy (Each.Textures (i)); deallocate (Each); end loop; end loop; end destroy; function new_Texture (From : access Pool; Size : in Dimensions) return Object is use GL.Binding; the_Pool : access Pool renames From; the_Texture : aliased Object; unused_List : pool_texture_List_view; begin Tasks.check; if the_Pool.Map.contains (Size) then unused_List := the_Pool.Map.Element (Size); else unused_List := new pool_texture_List; the_Pool.Map.insert (Size, unused_List); end if; -- Search for existing, but unused, object. -- if unused_List.Last > 0 then -- An existing unused texture has been found. the_Texture := unused_List.Textures (unused_List.Last); unused_List.Last := unused_List.Last - 1; the_Texture.enable; gltexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, GLsizei (Size.Width), GLsizei (Size.Height), 0, GL_RGBA, GL_UNSIGNED_BYTE, null); -- NB: Actual image is not initialised. else -- No existing, unused texture found, so create a new one. the_Texture.Pool := From.all'unchecked_Access; the_Texture.Name := new_texture_Name; the_Texture.enable; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gltexImage2D (gl_TEXTURE_2D, 0, gl_RGBA, GLsizei (Size.Width), GLsizei (Size.Height), 0, GL_RGBA, GL_UNSIGNED_BYTE, null); -- NB: Actual image is not initialised. end if; the_Texture.Dimensions := Size; return the_Texture; end new_Texture; procedure free (From : in out Pool; the_Texture : in Object) is use type texture_Name; begin if the_Texture.Name = 0 then return; end if; raise Program_Error with "TODO: free texture from pool"; -- declare -- unused_texture_List : constant pool_texture_List_view -- := Self.unused_Textures_for_size (the_Texture.Size_width, -- the_Texture.Size_height); -- begin -- unused_texture_List.Last := unused_texture_List.Last + 1; -- unused_texture_List.Textures (unused_texture_List.Last) := the_Texture; -- end; end free; procedure vacuum (the_Pool : in out Pool) is begin for Each of the_Pool.Map loop declare unused_List : constant pool_texture_List_view := Each; begin if unused_List /= null then for Each in 1 .. unused_List.Last loop free (unused_List.Textures (Each).Name); end loop; unused_List.Last := 0; end if; end; end loop; -- TODO: Test this ~ old code follows ... -- for each_Width in Self.unused_Textures_for_size'Range (1) -- loop -- for each_Height in self.unused_Textures_for_size'Range (2) -- loop -- declare -- unused_texture_List : constant pool_texture_List_view -- := Self.unused_Textures_for_size (each_Width, each_Height); -- begin -- if unused_texture_List /= null -- then -- for Each in 1 .. unused_texture_List.Last -- loop -- free (unused_texture_List.Textures (Each).Name); -- end loop; -- -- unused_texture_List.Last := 0; -- end if; -- end; -- end loop; -- end loop; end vacuum; function Hash (the_Dimensions : in Texture.Dimensions) return ada.Containers.Hash_Type is begin return ada.Containers.Hash_type ( the_Dimensions.Width * 13 + the_Dimensions.Height * 17); end Hash; end openGL.Texture;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- W A R N S W -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Err_Vars; use Err_Vars; with Opt; use Opt; with Output; use Output; package body Warnsw is -- Local Subprograms procedure All_Warnings (Setting : Boolean); -- Sets all warnings off if Setting = False, and on if Setting = True procedure WA_Warnings; -- Turn on all warnings set by -gnatwa (also used by -gnatw.g) ------------------ -- All_Warnings -- ------------------ procedure All_Warnings (Setting : Boolean) is begin Address_Clause_Overlay_Warnings := Setting; Check_Unreferenced := Setting; Check_Unreferenced_Formals := Setting; Check_Withs := Setting; Constant_Condition_Warnings := Setting; Elab_Warnings := Setting; Implementation_Unit_Warnings := Setting; Ineffective_Inline_Warnings := Setting; List_Body_Required_Info := Setting; List_Inherited_Aspects := Setting; Warn_On_Ada_2005_Compatibility := Setting; Warn_On_Ada_2012_Compatibility := Setting; Warn_On_All_Unread_Out_Parameters := Setting; Warn_On_Assertion_Failure := Setting; Warn_On_Assumed_Low_Bound := Setting; Warn_On_Atomic_Synchronization := Setting; Warn_On_Bad_Fixed_Value := Setting; Warn_On_Biased_Representation := Setting; Warn_On_Constant := Setting; Warn_On_Deleted_Code := Setting; Warn_On_Dereference := Setting; Warn_On_Export_Import := Setting; Warn_On_Hiding := Setting; Warn_On_Modified_Unread := Setting; Warn_On_No_Value_Assigned := Setting; Warn_On_Non_Local_Exception := Setting; Warn_On_Object_Renames_Function := Setting; Warn_On_Obsolescent_Feature := Setting; Warn_On_Overlap := Setting; Warn_On_Overridden_Size := Setting; Warn_On_Parameter_Order := Setting; Warn_On_Questionable_Missing_Parens := Setting; Warn_On_Record_Holes := Setting; Warn_On_Redundant_Constructs := Setting; Warn_On_Reverse_Bit_Order := Setting; Warn_On_Size_Alignment := Setting; Warn_On_Standard_Redefinition := Setting; Warn_On_Suspicious_Contract := Setting; Warn_On_Suspicious_Modulus_Value := Setting; Warn_On_Unchecked_Conversion := Setting; Warn_On_Unordered_Enumeration_Type := Setting; Warn_On_Unrecognized_Pragma := Setting; Warn_On_Unrepped_Components := Setting; Warn_On_Warnings_Off := Setting; end All_Warnings; ---------------------- -- Restore_Warnings -- ---------------------- procedure Restore_Warnings (W : Warning_Record) is begin Address_Clause_Overlay_Warnings := W.Address_Clause_Overlay_Warnings; Check_Unreferenced := W.Check_Unreferenced; Check_Unreferenced_Formals := W.Check_Unreferenced_Formals; Check_Withs := W.Check_Withs; Constant_Condition_Warnings := W.Constant_Condition_Warnings; Elab_Warnings := W.Elab_Warnings; Elab_Info_Messages := W.Elab_Info_Messages; Implementation_Unit_Warnings := W.Implementation_Unit_Warnings; Ineffective_Inline_Warnings := W.Ineffective_Inline_Warnings; List_Body_Required_Info := W.List_Body_Required_Info; List_Inherited_Aspects := W.List_Inherited_Aspects; No_Warn_On_Non_Local_Exception := W.No_Warn_On_Non_Local_Exception; Warning_Doc_Switch := W.Warning_Doc_Switch; Warn_On_Ada_2005_Compatibility := W.Warn_On_Ada_2005_Compatibility; Warn_On_Ada_2012_Compatibility := W.Warn_On_Ada_2012_Compatibility; Warn_On_All_Unread_Out_Parameters := W.Warn_On_All_Unread_Out_Parameters; Warn_On_Assertion_Failure := W.Warn_On_Assertion_Failure; Warn_On_Assumed_Low_Bound := W.Warn_On_Assumed_Low_Bound; Warn_On_Atomic_Synchronization := W.Warn_On_Atomic_Synchronization; Warn_On_Bad_Fixed_Value := W.Warn_On_Bad_Fixed_Value; Warn_On_Biased_Representation := W.Warn_On_Biased_Representation; Warn_On_Constant := W.Warn_On_Constant; Warn_On_Deleted_Code := W.Warn_On_Deleted_Code; Warn_On_Dereference := W.Warn_On_Dereference; Warn_On_Export_Import := W.Warn_On_Export_Import; Warn_On_Hiding := W.Warn_On_Hiding; Warn_On_Modified_Unread := W.Warn_On_Modified_Unread; Warn_On_No_Value_Assigned := W.Warn_On_No_Value_Assigned; Warn_On_Non_Local_Exception := W.Warn_On_Non_Local_Exception; Warn_On_Object_Renames_Function := W.Warn_On_Object_Renames_Function; Warn_On_Obsolescent_Feature := W.Warn_On_Obsolescent_Feature; Warn_On_Overlap := W.Warn_On_Overlap; Warn_On_Overridden_Size := W.Warn_On_Overridden_Size; Warn_On_Parameter_Order := W.Warn_On_Parameter_Order; Warn_On_Questionable_Missing_Parens := W.Warn_On_Questionable_Missing_Parens; Warn_On_Record_Holes := W.Warn_On_Record_Holes; Warn_On_Redundant_Constructs := W.Warn_On_Redundant_Constructs; Warn_On_Reverse_Bit_Order := W.Warn_On_Reverse_Bit_Order; Warn_On_Size_Alignment := W.Warn_On_Size_Alignment; Warn_On_Standard_Redefinition := W.Warn_On_Standard_Redefinition; Warn_On_Suspicious_Contract := W.Warn_On_Suspicious_Contract; Warn_On_Unchecked_Conversion := W.Warn_On_Unchecked_Conversion; Warn_On_Unordered_Enumeration_Type := W.Warn_On_Unordered_Enumeration_Type; Warn_On_Unrecognized_Pragma := W.Warn_On_Unrecognized_Pragma; Warn_On_Unrepped_Components := W.Warn_On_Unrepped_Components; Warn_On_Warnings_Off := W.Warn_On_Warnings_Off; end Restore_Warnings; ------------------- -- Save_Warnings -- ------------------- function Save_Warnings return Warning_Record is W : Warning_Record; begin W.Address_Clause_Overlay_Warnings := Address_Clause_Overlay_Warnings; W.Check_Unreferenced := Check_Unreferenced; W.Check_Unreferenced_Formals := Check_Unreferenced_Formals; W.Check_Withs := Check_Withs; W.Constant_Condition_Warnings := Constant_Condition_Warnings; W.Elab_Info_Messages := Elab_Info_Messages; W.Elab_Warnings := Elab_Warnings; W.Implementation_Unit_Warnings := Implementation_Unit_Warnings; W.Ineffective_Inline_Warnings := Ineffective_Inline_Warnings; W.List_Body_Required_Info := List_Body_Required_Info; W.List_Inherited_Aspects := List_Inherited_Aspects; W.No_Warn_On_Non_Local_Exception := No_Warn_On_Non_Local_Exception; W.Warning_Doc_Switch := Warning_Doc_Switch; W.Warn_On_Ada_2005_Compatibility := Warn_On_Ada_2005_Compatibility; W.Warn_On_Ada_2012_Compatibility := Warn_On_Ada_2012_Compatibility; W.Warn_On_All_Unread_Out_Parameters := Warn_On_All_Unread_Out_Parameters; W.Warn_On_Assertion_Failure := Warn_On_Assertion_Failure; W.Warn_On_Assumed_Low_Bound := Warn_On_Assumed_Low_Bound; W.Warn_On_Atomic_Synchronization := Warn_On_Atomic_Synchronization; W.Warn_On_Bad_Fixed_Value := Warn_On_Bad_Fixed_Value; W.Warn_On_Biased_Representation := Warn_On_Biased_Representation; W.Warn_On_Constant := Warn_On_Constant; W.Warn_On_Deleted_Code := Warn_On_Deleted_Code; W.Warn_On_Dereference := Warn_On_Dereference; W.Warn_On_Export_Import := Warn_On_Export_Import; W.Warn_On_Hiding := Warn_On_Hiding; W.Warn_On_Modified_Unread := Warn_On_Modified_Unread; W.Warn_On_No_Value_Assigned := Warn_On_No_Value_Assigned; W.Warn_On_Non_Local_Exception := Warn_On_Non_Local_Exception; W.Warn_On_Object_Renames_Function := Warn_On_Object_Renames_Function; W.Warn_On_Obsolescent_Feature := Warn_On_Obsolescent_Feature; W.Warn_On_Overlap := Warn_On_Overlap; W.Warn_On_Overridden_Size := Warn_On_Overridden_Size; W.Warn_On_Parameter_Order := Warn_On_Parameter_Order; W.Warn_On_Questionable_Missing_Parens := Warn_On_Questionable_Missing_Parens; W.Warn_On_Record_Holes := Warn_On_Record_Holes; W.Warn_On_Redundant_Constructs := Warn_On_Redundant_Constructs; W.Warn_On_Reverse_Bit_Order := Warn_On_Reverse_Bit_Order; W.Warn_On_Size_Alignment := Warn_On_Size_Alignment; W.Warn_On_Standard_Redefinition := Warn_On_Standard_Redefinition; W.Warn_On_Suspicious_Contract := Warn_On_Suspicious_Contract; W.Warn_On_Unchecked_Conversion := Warn_On_Unchecked_Conversion; W.Warn_On_Unordered_Enumeration_Type := Warn_On_Unordered_Enumeration_Type; W.Warn_On_Unrecognized_Pragma := Warn_On_Unrecognized_Pragma; W.Warn_On_Unrepped_Components := Warn_On_Unrepped_Components; W.Warn_On_Warnings_Off := Warn_On_Warnings_Off; return W; end Save_Warnings; ---------------------------- -- Set_Dot_Warning_Switch -- ---------------------------- function Set_Dot_Warning_Switch (C : Character) return Boolean is begin case C is when 'a' => Warn_On_Assertion_Failure := True; when 'A' => Warn_On_Assertion_Failure := False; when 'b' => Warn_On_Biased_Representation := True; when 'B' => Warn_On_Biased_Representation := False; when 'c' => Warn_On_Unrepped_Components := True; when 'C' => Warn_On_Unrepped_Components := False; when 'd' => Warning_Doc_Switch := True; when 'D' => Warning_Doc_Switch := False; when 'e' => All_Warnings (True); when 'f' => Warn_On_Elab_Access := True; when 'F' => Warn_On_Elab_Access := False; when 'g' => Set_GNAT_Mode_Warnings; when 'h' => Warn_On_Record_Holes := True; when 'H' => Warn_On_Record_Holes := False; when 'i' => Warn_On_Overlap := True; when 'I' => Warn_On_Overlap := False; when 'k' => Warn_On_Standard_Redefinition := True; when 'K' => Warn_On_Standard_Redefinition := False; when 'l' => List_Inherited_Aspects := True; when 'L' => List_Inherited_Aspects := False; when 'm' => Warn_On_Suspicious_Modulus_Value := True; when 'M' => Warn_On_Suspicious_Modulus_Value := False; when 'n' => Warn_On_Atomic_Synchronization := True; when 'N' => Warn_On_Atomic_Synchronization := False; when 'o' => Warn_On_All_Unread_Out_Parameters := True; when 'O' => Warn_On_All_Unread_Out_Parameters := False; when 'p' => Warn_On_Parameter_Order := True; when 'P' => Warn_On_Parameter_Order := False; when 'r' => Warn_On_Object_Renames_Function := True; when 'R' => Warn_On_Object_Renames_Function := False; when 's' => Warn_On_Overridden_Size := True; when 'S' => Warn_On_Overridden_Size := False; when 't' => Warn_On_Suspicious_Contract := True; when 'T' => Warn_On_Suspicious_Contract := False; when 'u' => Warn_On_Unordered_Enumeration_Type := True; when 'U' => Warn_On_Unordered_Enumeration_Type := False; when 'v' => Warn_On_Reverse_Bit_Order := True; when 'V' => Warn_On_Reverse_Bit_Order := False; when 'w' => Warn_On_Warnings_Off := True; when 'W' => Warn_On_Warnings_Off := False; when 'x' => Warn_On_Non_Local_Exception := True; when 'X' => Warn_On_Non_Local_Exception := False; No_Warn_On_Non_Local_Exception := True; when 'y' => List_Body_Required_Info := True; when 'Y' => List_Body_Required_Info := False; when 'z' => Warn_On_Size_Alignment := True; when 'Z' => Warn_On_Size_Alignment := False; when others => if Ignore_Unrecognized_VWY_Switches then Write_Line ("unrecognized switch -gnatw." & C & " ignored"); else return False; end if; end case; return True; end Set_Dot_Warning_Switch; ---------------------------- -- Set_GNAT_Mode_Warnings -- ---------------------------- procedure Set_GNAT_Mode_Warnings is begin -- Set -gnatwa warnings and no others All_Warnings (False); WA_Warnings; -- These warnings are added to the -gnatwa set Address_Clause_Overlay_Warnings := True; Warn_On_Overridden_Size := True; -- These warnings are removed from the -gnatwa set Implementation_Unit_Warnings := False; Warn_On_Non_Local_Exception := False; No_Warn_On_Non_Local_Exception := True; Warn_On_Reverse_Bit_Order := False; Warn_On_Size_Alignment := False; Warn_On_Unrepped_Components := False; end Set_GNAT_Mode_Warnings; ------------------------ -- Set_Warning_Switch -- ------------------------ function Set_Warning_Switch (C : Character) return Boolean is begin case C is when 'a' => WA_Warnings; when 'A' => All_Warnings (False); No_Warn_On_Non_Local_Exception := True; when 'b' => Warn_On_Bad_Fixed_Value := True; when 'B' => Warn_On_Bad_Fixed_Value := False; when 'c' => Constant_Condition_Warnings := True; when 'C' => Constant_Condition_Warnings := False; when 'd' => Warn_On_Dereference := True; when 'D' => Warn_On_Dereference := False; when 'e' => Warning_Mode := Treat_As_Error; when 'f' => Check_Unreferenced_Formals := True; when 'F' => Check_Unreferenced_Formals := False; when 'g' => Warn_On_Unrecognized_Pragma := True; when 'G' => Warn_On_Unrecognized_Pragma := False; when 'h' => Warn_On_Hiding := True; when 'H' => Warn_On_Hiding := False; when 'i' => Implementation_Unit_Warnings := True; when 'I' => Implementation_Unit_Warnings := False; when 'j' => Warn_On_Obsolescent_Feature := True; when 'J' => Warn_On_Obsolescent_Feature := False; when 'k' => Warn_On_Constant := True; when 'K' => Warn_On_Constant := False; when 'l' => Elab_Warnings := True; when 'L' => Elab_Warnings := False; when 'm' => Warn_On_Modified_Unread := True; when 'M' => Warn_On_Modified_Unread := False; when 'n' => Warning_Mode := Normal; when 'o' => Address_Clause_Overlay_Warnings := True; when 'O' => Address_Clause_Overlay_Warnings := False; when 'p' => Ineffective_Inline_Warnings := True; when 'P' => Ineffective_Inline_Warnings := False; when 'q' => Warn_On_Questionable_Missing_Parens := True; when 'Q' => Warn_On_Questionable_Missing_Parens := False; when 'r' => Warn_On_Redundant_Constructs := True; when 'R' => Warn_On_Redundant_Constructs := False; when 's' => Warning_Mode := Suppress; when 't' => Warn_On_Deleted_Code := True; when 'T' => Warn_On_Deleted_Code := False; when 'u' => Check_Unreferenced := True; Check_Withs := True; Check_Unreferenced_Formals := True; when 'U' => Check_Unreferenced := False; Check_Withs := False; Check_Unreferenced_Formals := False; when 'v' => Warn_On_No_Value_Assigned := True; when 'V' => Warn_On_No_Value_Assigned := False; when 'w' => Warn_On_Assumed_Low_Bound := True; when 'W' => Warn_On_Assumed_Low_Bound := False; when 'x' => Warn_On_Export_Import := True; when 'X' => Warn_On_Export_Import := False; when 'y' => Warn_On_Ada_2005_Compatibility := True; Warn_On_Ada_2012_Compatibility := True; when 'Y' => Warn_On_Ada_2005_Compatibility := False; Warn_On_Ada_2012_Compatibility := False; when 'z' => Warn_On_Unchecked_Conversion := True; when 'Z' => Warn_On_Unchecked_Conversion := False; when others => if Ignore_Unrecognized_VWY_Switches then Write_Line ("unrecognized switch -gnatw" & C & " ignored"); else return False; end if; end case; return True; end Set_Warning_Switch; ----------------- -- WA_Warnings -- ----------------- procedure WA_Warnings is begin Check_Unreferenced := True; -- -gnatwf/-gnatwu Check_Unreferenced_Formals := True; -- -gnatwf/-gnatwu Check_Withs := True; -- -gnatwu Constant_Condition_Warnings := True; -- -gnatwc Implementation_Unit_Warnings := True; -- -gnatwi Ineffective_Inline_Warnings := True; -- -gnatwp Warn_On_Ada_2005_Compatibility := True; -- -gnatwy Warn_On_Ada_2012_Compatibility := True; -- -gnatwy Warn_On_Assertion_Failure := True; -- -gnatw.a Warn_On_Assumed_Low_Bound := True; -- -gnatww Warn_On_Bad_Fixed_Value := True; -- -gnatwb Warn_On_Biased_Representation := True; -- -gnatw.b Warn_On_Constant := True; -- -gnatwk Warn_On_Export_Import := True; -- -gnatwx Warn_On_Modified_Unread := True; -- -gnatwm Warn_On_No_Value_Assigned := True; -- -gnatwv Warn_On_Non_Local_Exception := True; -- -gnatw.x Warn_On_Object_Renames_Function := True; -- -gnatw.r Warn_On_Obsolescent_Feature := True; -- -gnatwj Warn_On_Overlap := True; -- -gnatw.i Warn_On_Parameter_Order := True; -- -gnatw.p Warn_On_Questionable_Missing_Parens := True; -- -gnatwq Warn_On_Redundant_Constructs := True; -- -gnatwr Warn_On_Reverse_Bit_Order := True; -- -gnatw.v Warn_On_Size_Alignment := True; -- -gnatw.z Warn_On_Suspicious_Contract := True; -- -gnatw.t Warn_On_Suspicious_Modulus_Value := True; -- -gnatw.m Warn_On_Unchecked_Conversion := True; -- -gnatwz Warn_On_Unrecognized_Pragma := True; -- -gnatwg Warn_On_Unrepped_Components := True; -- -gnatw.c end WA_Warnings; end Warnsw;
pragma License (Unrestricted); -- with Ada.Streams; with Ada.Exception_Identification; private with System.Unwind; package Ada.Exceptions is pragma Preelaborate; -- type Exception_Id is private; -- pragma Preelaborable_Initialization (Exception_Id); subtype Exception_Id is Exception_Identification.Exception_Id; function "=" (Left, Right : Exception_Id) return Boolean -- CB41003 renames Exception_Identification."="; -- Null_Id : constant Exception_Id; Null_Id : Exception_Id renames Exception_Identification.Null_Id; function Exception_Name (Id : Exception_Id) return String renames Exception_Identification.Exception_Name; function Wide_Exception_Name (Id : Exception_Id) return Wide_String; function Wide_Wide_Exception_Name (Id : Exception_Id) return Wide_Wide_String; type Exception_Occurrence is limited private; pragma Preelaborable_Initialization (Exception_Occurrence); type Exception_Occurrence_Access is access all Exception_Occurrence; Null_Occurrence : constant Exception_Occurrence; procedure Raise_Exception (E : Exception_Id; Message : String := "") renames Exception_Identification.Raise_Exception; function Exception_Message (X : Exception_Occurrence) return String; procedure Reraise_Occurrence (X : Exception_Occurrence); -- extended -- Same as Reraise_Occurrence without checking Null_Occurrence. procedure Reraise_Nonnull_Occurrence (X : Exception_Occurrence) with Import, Convention => Ada, External_Name => "ada__exceptions__reraise_occurrence_always"; pragma No_Return (Reraise_Nonnull_Occurrence); function Exception_Identity (X : Exception_Occurrence) return Exception_Id; function Exception_Name (X : Exception_Occurrence) return String; -- Same as Exception_Name (Exception_Identity (X)). function Wide_Exception_Name (X : Exception_Occurrence) return Wide_String; -- Same as Wide_Exception_Name (Exception_Identity (X)). function Wide_Wide_Exception_Name (X : Exception_Occurrence) return Wide_Wide_String; -- Same as Wide_Wide_Exception_Name (Exception_Identity (X)). function Exception_Information (X : Exception_Occurrence) return String; pragma Inline (Exception_Identity); procedure Save_Occurrence ( Target : out Exception_Occurrence; Source : Exception_Occurrence) with Import, Convention => Ada, External_Name => "ada__exceptions__save_occurrence"; function Save_Occurrence ( Source : Exception_Occurrence) return Exception_Occurrence_Access; -- extended -- Efficient alternatives of: -- begin raise E; when X : E => Save_Occurrence (Target, X); end; procedure Save_Exception ( Target : out Exception_Occurrence; E : Exception_Id; Message : String := "") with Import, Convention => Ada, External_Name => "__drake_save_exception"; procedure Save_Exception_From_Here ( Target : out Exception_Occurrence; E : Exception_Id; File : String := Debug.File; Line : Integer := Debug.Line) with Import, Convention => Ada, External_Name => "__drake_save_exception_from_here"; procedure Save_Exception_From_Here ( Target : out Exception_Occurrence; E : Exception_Id; File : String := Debug.File; Line : Integer := Debug.Line; Message : String) with Import, Convention => Ada, External_Name => "__drake_save_exception_from_here_with"; -- procedure Read_Exception_Occurrence ( -- Stream : not null access Ada.Streams.Root_Stream_Type'Class; -- Item : out Exception_Occurrence); -- procedure Write_Exception_Occurrence ( -- Stream : not null access Ada.Streams.Root_Stream_Type'Class; -- Item : Exception_Occurrence); -- for Exception_Occurrence'Read use Read_Exception_Occurrence; -- for Exception_Occurrence'Write use Write_Exception_Occurrence; private type Exception_Occurrence is new System.Unwind.Exception_Occurrence; Null_Occurrence : constant Exception_Occurrence := ( Id => null, Machine_Occurrence => System.Null_Address, Msg_Length => 0, Msg => (others => ' '), Exception_Raised => False, Pid => 0, Num_Tracebacks => 0, Tracebacks => (others => System.Null_Address)); -- optionally required by compiler (a-except-2005.ads) -- Raise_Exception may be called if it is removed. (exp_ch6.adb) procedure Raise_Exception_Always (E : Exception_Id; Message : String := "") renames Raise_Exception; -- required by compiler (a-except-2005.ads) -- for reraising (exp_ch11.adb) procedure Reraise_Occurrence_Always (X : Exception_Occurrence) renames Reraise_Nonnull_Occurrence; -- required by compiler (a-except-2005.ads) -- for reraising from when all others (exp_ch11.adb) procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) with Import, Convention => Ada, External_Name => "ada__exceptions__reraise_occurrence_no_defer"; pragma No_Return (Reraise_Occurrence_No_Defer); -- optionally required by compiler (a-except-2005.ads) -- Raising Program_Error may be inserted if it is removed. (exp_ch7.adb) procedure Raise_From_Controlled_Operation (X : Exception_Occurrence) with Import, Convention => Ada, External_Name => "__gnat_raise_from_controlled_operation"; -- required by compiler (a-except-2005.ads) -- for finalizer (exp_ch7.adb) function Triggered_By_Abort return Boolean with Import, Convention => Ada, External_Name => "ada__exceptions__triggered_by_abort"; -- required by compiler (a-except-2005.ads) -- for intrinsic function Exception_Name (exp_intr.adb) function Exception_Name_Simple (X : Exception_Occurrence) return String renames Exception_Name; -- required by compiler (a-except-2005.ads) -- ??? (exp_ch11.adb, sem_ch11.adb) subtype Code_Loc is System.Address; -- not required for gcc (a-except-2005.ads) -- procedure Poll; end Ada.Exceptions;
------------------------------------------------------------------------------ -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a NT (native) version of this package. -- This package contains all the GNULL primitives that interface directly -- with the underlying OS. pragma Polling (Off); -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. with System.Tasking.Debug; -- used for Known_Tasks with Interfaces.C; -- used for int -- size_t with Interfaces.C.Strings; -- used for Null_Ptr with System.OS_Interface; -- used for various type, constant, and operations with System.Parameters; -- used for Size_Type with System.Tasking; -- used for Ada_Task_Control_Block -- Task_ID with System.Soft_Links; -- used for Defer/Undefer_Abort -- to initialize TSD for a C thread, in function Self -- Note that we do not use System.Tasking.Initialization directly since -- this is a higher level package that we shouldn't depend on. For example -- when using the restricted run time, it is replaced by -- System.Tasking.Restricted.Initialization with System.OS_Primitives; -- used for Delay_Modes with System.Task_Info; -- used for Unspecified_Task_Info with Unchecked_Conversion; with Unchecked_Deallocation; package body System.Task_Primitives.Operations is use System.Tasking.Debug; use System.Tasking; use Interfaces.C; use Interfaces.C.Strings; use System.OS_Interface; use System.Parameters; use System.OS_Primitives; pragma Linker_Options ("-Xlinker --stack=0x800000,0x1000"); package SSL renames System.Soft_Links; ------------------ -- Local Data -- ------------------ Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; -- See comments on locking rules in System.Tasking (spec). Time_Slice_Val : Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); Dispatching_Policy : Character; pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F'; -- Indicates whether FIFO_Within_Priorities is set. --------------------------------- -- Foreign Threads Detection -- --------------------------------- -- The following are used to allow the Self function to -- automatically generate ATCB's for C threads that happen to call -- Ada procedure, which in turn happen to call the Ada run-time system. type Fake_ATCB; type Fake_ATCB_Ptr is access Fake_ATCB; type Fake_ATCB is record Stack_Base : Interfaces.C.unsigned := 0; -- A value of zero indicates the node is not in use. Next : Fake_ATCB_Ptr; Real_ATCB : aliased Ada_Task_Control_Block (0); end record; Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. -- The list is protected by All_Tasks_L; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. Fake_Task_Elaborated : aliased Boolean := True; -- Used to identified fake tasks (i.e., non-Ada Threads). Next_Fake_ATCB : Fake_ATCB_Ptr; -- Used to allocate one Fake_ATCB in advance. See comment in New_Fake_ATCB --------------------------------- -- Support for New_Fake_ATCB -- --------------------------------- function New_Fake_ATCB return Task_ID; -- Allocate and Initialize a new ATCB. This code can safely be called from -- a foreign thread, as it doesn't access implicitly or explicitly -- "self" before having initialized the new ATCB. ------------------------------------ -- The thread local storage index -- ------------------------------------ TlsIndex : DWORD; pragma Export (Ada, TlsIndex); -- To ensure that this variable won't be local to this package, since -- in some cases, inlining forces this variable to be global anyway. ---------------------------------- -- Utility Conversion Functions -- ---------------------------------- function To_Task_Id is new Unchecked_Conversion (System.Address, Task_ID); function To_Address is new Unchecked_Conversion (Task_ID, System.Address); ------------------- -- New_Fake_ATCB -- ------------------- function New_Fake_ATCB return Task_ID is Self_ID : Task_ID; P, Q : Fake_ATCB_Ptr; Succeeded : Boolean; Res : BOOL; begin -- This section is ticklish. -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. Write_Lock (All_Tasks_L'Access); Q := null; P := Fake_ATCB_List; while P /= null loop if P.Stack_Base = 0 then Q := P; end if; P := P.Next; end loop; if Q = null then -- Create a new ATCB with zero entries. Self_ID := Next_Fake_ATCB.Real_ATCB'Access; Next_Fake_ATCB.Stack_Base := 1; Next_Fake_ATCB.Next := Fake_ATCB_List; Fake_ATCB_List := Next_Fake_ATCB; Next_Fake_ATCB := null; else -- Reuse an existing fake ATCB. Self_ID := Q.Real_ATCB'Access; Q.Stack_Base := 1; end if; -- Record this as the Task_ID for the current thread. Self_ID.Common.LL.Thread := GetCurrentThread; Res := TlsSetValue (TlsIndex, To_Address (Self_ID)); pragma Assert (Res = True); -- Do the standard initializations System.Tasking.Initialize_ATCB (Self_ID, null, Null_Address, Null_Task, Fake_Task_Elaborated'Access, System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_ID, Succeeded); pragma Assert (Succeeded); -- Finally, it is safe to use an allocator in this thread. if Next_Fake_ATCB = null then Next_Fake_ATCB := new Fake_ATCB; end if; Self_ID.Master_of_Task := 0; Self_ID.Master_Within := Self_ID.Master_of_Task + 1; for L in Self_ID.Entry_Calls'Range loop Self_ID.Entry_Calls (L).Self := Self_ID; Self_ID.Entry_Calls (L).Level := L; end loop; Self_ID.Common.State := Runnable; Self_ID.Awake_Count := 1; -- Since this is not an ordinary Ada task, we will start out undeferred Self_ID.Deferral_Level := 0; System.Soft_Links.Create_TSD (Self_ID.Common.Compiler_Data); -- ???? -- The following call is commented out to avoid dependence on -- the System.Tasking.Initialization package. -- It seems that if we want Ada.Task_Attributes to work correctly -- for C threads we will need to raise the visibility of this soft -- link to System.Soft_Links. -- We are putting that off until this new functionality is otherwise -- stable. -- System.Tasking.Initialization.Initialize_Attributes_Link.all (T); -- Must not unlock until Next_ATCB is again allocated. Unlock (All_Tasks_L'Access); return Self_ID; end New_Fake_ATCB; ---------------------------------- -- Condition Variable Functions -- ---------------------------------- procedure Initialize_Cond (Cond : access Condition_Variable); -- Initialize given condition variable Cond procedure Finalize_Cond (Cond : access Condition_Variable); -- Finalize given condition variable Cond. procedure Cond_Signal (Cond : access Condition_Variable); -- Signal condition variable Cond procedure Cond_Wait (Cond : access Condition_Variable; L : access RTS_Lock); -- Wait on conditional variable Cond, using lock L procedure Cond_Timed_Wait (Cond : access Condition_Variable; L : access RTS_Lock; Rel_Time : Duration; Timed_Out : out Boolean; Status : out Integer); -- Do timed wait on condition variable Cond using lock L. The duration -- of the timed wait is given by Rel_Time. When the condition is -- signalled, Timed_Out shows whether or not a time out occurred. -- Status shows whether Cond_Timed_Wait completed successfully. --------------------- -- Initialize_Cond -- --------------------- procedure Initialize_Cond (Cond : access Condition_Variable) is hEvent : HANDLE; begin hEvent := CreateEvent (null, True, False, Null_Ptr); pragma Assert (hEvent /= 0); Cond.all := Condition_Variable (hEvent); end Initialize_Cond; ------------------- -- Finalize_Cond -- ------------------- -- No such problem here, DosCloseEventSem has been derived. -- What does such refer to in above comment??? procedure Finalize_Cond (Cond : access Condition_Variable) is Result : BOOL; begin Result := CloseHandle (HANDLE (Cond.all)); pragma Assert (Result = True); end Finalize_Cond; ----------------- -- Cond_Signal -- ----------------- procedure Cond_Signal (Cond : access Condition_Variable) is Result : BOOL; begin Result := SetEvent (HANDLE (Cond.all)); pragma Assert (Result = True); end Cond_Signal; --------------- -- Cond_Wait -- --------------- -- Pre-assertion: Cond is posted -- L is locked. -- Post-assertion: Cond is posted -- L is locked. procedure Cond_Wait (Cond : access Condition_Variable; L : access RTS_Lock) is Result : DWORD; Result_Bool : BOOL; begin -- Must reset Cond BEFORE L is unlocked. Result_Bool := ResetEvent (HANDLE (Cond.all)); pragma Assert (Result_Bool = True); Unlock (L); -- No problem if we are interrupted here: if the condition is signaled, -- WaitForSingleObject will simply not block Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite); pragma Assert (Result = 0); Write_Lock (L); end Cond_Wait; --------------------- -- Cond_Timed_Wait -- --------------------- -- Pre-assertion: Cond is posted -- L is locked. -- Post-assertion: Cond is posted -- L is locked. procedure Cond_Timed_Wait (Cond : access Condition_Variable; L : access RTS_Lock; Rel_Time : Duration; Timed_Out : out Boolean; Status : out Integer) is Time_Out : DWORD; Result : BOOL; Int_Rel_Time : DWORD; Wait_Result : DWORD; begin -- Must reset Cond BEFORE L is unlocked. Result := ResetEvent (HANDLE (Cond.all)); pragma Assert (Result = True); Unlock (L); -- No problem if we are interrupted here: if the condition is signaled, -- WaitForSingleObject will simply not block if Rel_Time <= 0.0 then Timed_Out := True; else Int_Rel_Time := DWORD (Rel_Time); Time_Out := Int_Rel_Time * 1000 + DWORD ((Rel_Time - Duration (Int_Rel_Time)) * 1000.0); Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out); if Wait_Result = WAIT_TIMEOUT then Timed_Out := True; Wait_Result := 0; else Timed_Out := False; end if; end if; Write_Lock (L); -- Ensure post-condition if Timed_Out then Result := SetEvent (HANDLE (Cond.all)); pragma Assert (Result = True); end if; Status := Integer (Wait_Result); end Cond_Timed_Wait; ------------------ -- Stack_Guard -- ------------------ -- The underlying thread system sets a guard page at the -- bottom of a thread stack, so nothing is needed. -- ??? Check the comment above procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is begin null; end Stack_Guard; -------------------- -- Get_Thread_Id -- -------------------- function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id is begin return T.Common.LL.Thread; end Get_Thread_Id; ---------- -- Self -- ---------- function Self return Task_ID is Self_Id : Task_ID; begin Self_Id := To_Task_Id (TlsGetValue (TlsIndex)); if Self_Id = null then return New_Fake_ATCB; end if; return Self_Id; end Self; --------------------- -- Initialize_Lock -- --------------------- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is handled. -- Other mutexes (such as All_Tasks_Lock, Memory_Lock...) used in -- the RTS is initialized before any status change of RTS. -- Therefore raising Storage_Error in the following routines -- should be able to be handled safely. procedure Initialize_Lock (Prio : System.Any_Priority; L : access Lock) is begin InitializeCriticalSection (L.Mutex'Access); L.Owner_Priority := 0; L.Priority := Prio; end Initialize_Lock; procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is begin InitializeCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Initialize_Lock; ------------------- -- Finalize_Lock -- ------------------- procedure Finalize_Lock (L : access Lock) is begin DeleteCriticalSection (L.Mutex'Access); end Finalize_Lock; procedure Finalize_Lock (L : access RTS_Lock) is begin DeleteCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Finalize_Lock; ---------------- -- Write_Lock -- ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is begin L.Owner_Priority := Get_Priority (Self); if L.Priority < L.Owner_Priority then Ceiling_Violation := True; return; end if; EnterCriticalSection (L.Mutex'Access); Ceiling_Violation := False; end Write_Lock; procedure Write_Lock (L : access RTS_Lock) is begin EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Write_Lock; procedure Write_Lock (T : Task_ID) is begin EnterCriticalSection (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); end Write_Lock; --------------- -- Read_Lock -- --------------- procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is begin Write_Lock (L, Ceiling_Violation); end Read_Lock; ------------ -- Unlock -- ------------ procedure Unlock (L : access Lock) is begin LeaveCriticalSection (L.Mutex'Access); end Unlock; procedure Unlock (L : access RTS_Lock) is begin LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Unlock; procedure Unlock (T : Task_ID) is begin LeaveCriticalSection (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); end Unlock; ----------- -- Sleep -- ----------- procedure Sleep (Self_ID : Task_ID; Reason : System.Tasking.Task_States) is begin pragma Assert (Self_ID = Self); Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); if Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then Unlock (Self_ID); raise Standard'Abort_Signal; end if; end Sleep; ----------------- -- Timed_Sleep -- ----------------- -- This is for use within the run-time system, so abort is -- assumed to be already deferred, and the caller should be -- holding its own ATCB lock. procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes; Reason : System.Tasking.Task_States; Timedout : out Boolean; Yielded : out Boolean) is Check_Time : constant Duration := Monotonic_Clock; Rel_Time : Duration; Abs_Time : Duration; Result : Integer; Local_Timedout : Boolean; begin Timedout := True; Yielded := False; if Mode = Relative then Rel_Time := Time; Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; else Rel_Time := Time - Check_Time; Abs_Time := Time; end if; if Rel_Time > 0.0 then loop exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result); exit when Abs_Time <= Monotonic_Clock; if not Local_Timedout then -- somebody may have called Wakeup for us Timedout := False; exit; end if; Rel_Time := Abs_Time - Monotonic_Clock; end loop; end if; end Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes) is Check_Time : constant Duration := Monotonic_Clock; Rel_Time : Duration; Abs_Time : Duration; Result : Integer; Timedout : Boolean; begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; Write_Lock (Self_ID); if Mode = Relative then Rel_Time := Time; Abs_Time := Time + Check_Time; else Rel_Time := Time - Check_Time; Abs_Time := Time; end if; if Rel_Time > 0.0 then Self_ID.Common.State := Delay_Sleep; loop if Self_ID.Pending_Priority_Change then Self_ID.Pending_Priority_Change := False; Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; Set_Priority (Self_ID, Self_ID.Common.Base_Priority); end if; exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result); exit when Abs_Time <= Monotonic_Clock; Rel_Time := Abs_Time - Monotonic_Clock; end loop; Self_ID.Common.State := Runnable; end if; Unlock (Self_ID); Yield; SSL.Abort_Undefer.all; end Timed_Delay; ------------ -- Wakeup -- ------------ procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is begin Cond_Signal (T.Common.LL.CV'Access); end Wakeup; ----------- -- Yield -- ----------- procedure Yield (Do_Yield : Boolean := True) is begin if Do_Yield then Sleep (0); end if; end Yield; ------------------ -- Set_Priority -- ------------------ type Prio_Array_Type is array (System.Any_Priority) of Integer; pragma Atomic_Components (Prio_Array_Type); Prio_Array : Prio_Array_Type; -- Global array containing the id of the currently running task for -- each priority. -- -- Note: we assume that we are on a single processor with run-til-blocked -- scheduling. procedure Set_Priority (T : Task_ID; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Res : BOOL; Array_Item : Integer; begin Res := SetThreadPriority (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio))); pragma Assert (Res = True); -- ??? Work around a bug in NT 4.0 SP3 scheduler -- It looks like when a task with Thread_Priority_Idle (using RT class) -- never reaches its time slice (e.g by doing multiple and simple RV, -- see CXD8002), the scheduler never gives higher priority task a -- chance to run. -- Note that this works fine on NT 4.0 SP1 if Time_Slice_Val = 0 and then Underlying_Priorities (Prio) = Thread_Priority_Idle and then Loss_Of_Inheritance then Sleep (20); end if; if FIFO_Within_Priorities then -- Annex D requirement [RM D.2.2 par. 9]: -- If the task drops its priority due to the loss of inherited -- priority, it is added at the head of the ready queue for its -- new active priority. if Loss_Of_Inheritance and then Prio < T.Common.Current_Priority then Array_Item := Prio_Array (T.Common.Base_Priority) + 1; Prio_Array (T.Common.Base_Priority) := Array_Item; loop -- Let some processes a chance to arrive Yield; -- Then wait for our turn to proceed exit when Array_Item = Prio_Array (T.Common.Base_Priority) or else Prio_Array (T.Common.Base_Priority) = 1; end loop; Prio_Array (T.Common.Base_Priority) := Prio_Array (T.Common.Base_Priority) - 1; end if; end if; T.Common.Current_Priority := Prio; end Set_Priority; ------------------ -- Get_Priority -- ------------------ function Get_Priority (T : Task_ID) return System.Any_Priority is begin return T.Common.Current_Priority; end Get_Priority; ---------------- -- Enter_Task -- ---------------- -- There were two paths were we needed to call Enter_Task : -- 1) from System.Task_Primitives.Operations.Initialize -- 2) from System.Tasking.Stages.Task_Wrapper -- -- The thread initialisation has to be done only for the first case. -- -- This is because the GetCurrentThread NT call does not return the -- real thread handler but only a "pseudo" one. It is not possible to -- release the thread handle and free the system ressources from this -- "pseudo" handle. So we really want to keep the real thread handle -- set in System.Task_Primitives.Operations.Create_Task during the -- thread creation. procedure Enter_Task (Self_ID : Task_ID) is procedure Init_Float; pragma Import (C, Init_Float, "__gnat_init_float"); -- Properly initializes the FPU for x86 systems. Succeeded : BOOL; begin Succeeded := TlsSetValue (TlsIndex, To_Address (Self_ID)); pragma Assert (Succeeded = True); Init_Float; Self_ID.Common.LL.Thread_Id := GetCurrentThreadId; Lock_All_Tasks_List; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then Known_Tasks (J) := Self_ID; Self_ID.Known_Tasks_Index := J; exit; end if; end loop; Unlock_All_Tasks_List; end Enter_Task; -------------- -- New_ATCB -- -------------- function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is begin return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ---------------------- -- Initialize_TCB -- ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is begin Initialize_Cond (Self_ID.Common.LL.CV'Access); Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); Succeeded := True; end Initialize_TCB; ----------------- -- Create_Task -- ----------------- procedure Create_Task (T : Task_ID; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean) is hTask : HANDLE; TaskId : aliased DWORD; -- ??? The fact that we can't use PVOID because the compiler -- gives a "PVOID is not visible" error is a GNAT bug. -- The strange thing is that the file compiles fine during a regular -- build. pTaskParameter : System.OS_Interface.PVOID; dwStackSize : DWORD; Result : DWORD; Entry_Point : PTHREAD_START_ROUTINE; function To_PTHREAD_START_ROUTINE is new Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE); begin pTaskParameter := To_Address (T); if Stack_Size = Unspecified_Size then dwStackSize := DWORD (Default_Stack_Size); elsif Stack_Size < Minimum_Stack_Size then dwStackSize := DWORD (Minimum_Stack_Size); else dwStackSize := DWORD (Stack_Size); end if; Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper); hTask := CreateThread (null, dwStackSize, Entry_Point, pTaskParameter, DWORD (Create_Suspended), TaskId'Unchecked_Access); -- Step 1: Create the thread in blocked mode if hTask = 0 then raise Storage_Error; end if; -- Step 2: set its TCB T.Common.LL.Thread := hTask; -- Step 3: set its priority (child has inherited priority from parent) Set_Priority (T, Priority); -- Step 4: Now, start it for good: Result := ResumeThread (hTask); pragma Assert (Result = 1); Succeeded := Result = 1; end Create_Task; ------------------ -- Finalize_TCB -- ------------------ procedure Finalize_TCB (T : Task_ID) is Self_ID : Task_ID := T; Result : DWORD; Succeeded : BOOL; procedure Free is new Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin Finalize_Lock (T.Common.LL.L'Access); Finalize_Cond (T.Common.LL.CV'Access); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; -- Wait for the thread to terminate then close it. this is needed -- to release system ressources. Result := WaitForSingleObject (T.Common.LL.Thread, Wait_Infinite); pragma Assert (Result /= WAIT_FAILED); Succeeded := CloseHandle (T.Common.LL.Thread); pragma Assert (Succeeded = True); Free (Self_ID); end Finalize_TCB; --------------- -- Exit_Task -- --------------- procedure Exit_Task is begin ExitThread (0); end Exit_Task; ---------------- -- Abort_Task -- ---------------- procedure Abort_Task (T : Task_ID) is begin null; end Abort_Task; ---------------------- -- Environment_Task -- ---------------------- function Environment_Task return Task_ID is begin return Environment_Task_ID; end Environment_Task; ------------------------- -- Lock_All_Tasks_List -- ------------------------- procedure Lock_All_Tasks_List is begin Write_Lock (All_Tasks_L'Access); end Lock_All_Tasks_List; --------------------------- -- Unlock_All_Tasks_List -- --------------------------- procedure Unlock_All_Tasks_List is begin Unlock (All_Tasks_L'Access); end Unlock_All_Tasks_List; ---------------- -- Initialize -- ---------------- procedure Initialize (Environment_Task : Task_ID) is Res : BOOL; begin Environment_Task_ID := Environment_Task; if Time_Slice_Val = 0 or else FIFO_Within_Priorities then Res := OS_Interface.SetPriorityClass (GetCurrentProcess, Realtime_Priority_Class); end if; TlsIndex := TlsAlloc; -- Initialize the lock used to synchronize chain of all ATCBs. Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Environment_Task.Common.LL.Thread := GetCurrentThread; Enter_Task (Environment_Task); -- Create a free ATCB for use on the Fake_ATCB_List Next_Fake_ATCB := new Fake_ATCB; end Initialize; --------------------- -- Monotonic_Clock -- --------------------- function Monotonic_Clock return Duration renames System.OS_Primitives.Monotonic_Clock; ------------------- -- RT_Resolution -- ------------------- function RT_Resolution return Duration is begin return 0.000_001; -- 1 micro-second end RT_Resolution; ---------------- -- Check_Exit -- ---------------- -- Dummy versions. The only currently working versions is for solaris -- (native). function Check_Exit (Self_ID : ST.Task_ID) return Boolean is begin return True; end Check_Exit; -------------------- -- Check_No_Locks -- -------------------- function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean is begin return True; end Check_No_Locks; ------------------ -- Suspend_Task -- ------------------ function Suspend_Task (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin if T.Common.LL.Thread /= Thread_Self then return SuspendThread (T.Common.LL.Thread) = NO_ERROR; else return True; end if; end Suspend_Task; ----------------- -- Resume_Task -- ----------------- function Resume_Task (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin if T.Common.LL.Thread /= Thread_Self then return ResumeThread (T.Common.LL.Thread) = NO_ERROR; else return True; end if; end Resume_Task; end System.Task_Primitives.Operations;
generic type Gauss_Index_61 is range <>; type Real is digits <>; type Gauss_Values is array (Gauss_Index_61) of Real; package Gauss_Nodes_61 is Gauss_Weights_61 : constant Gauss_Values := (0.0013890136_9867700762_4551591226_760, 0.0038904611_2709988405_1267201844_516, 0.0066307039_1593129217_3319826369_750, 0.0092732796_5951776342_8441146892_024, 0.0118230152_5349634174_2232898853_251, 0.0143697295_0704580481_2451432443_580, 0.0169208891_8905327262_7572289420_322, 0.0194141411_9394238117_3408951050_128, 0.0218280358_2160919229_7167485738_339, 0.0241911620_7808060136_5686370725_232, 0.0265099548_8233310161_0601709335_075, 0.0287540487_6504129284_3978785354_334, 0.0309072575_6238776247_2884252943_092, 0.0329814470_5748372603_1814191016_854, 0.0349793380_2806002413_7499670731_468, 0.0368823646_5182122922_3911065617_136, 0.0386789456_2472759295_0348651532_281, 0.0403745389_5153595911_1995279752_468, 0.0419698102_1516424614_7147541285_970, 0.0434525397_0135606931_6831728117_073, 0.0448148001_3316266319_2355551616_723, 0.0460592382_7100698811_6271735559_374, 0.0471855465_6929915394_5261478181_099, 0.0481858617_5708712914_0779492298_305, 0.0490554345_5502977888_7528165367_238, 0.0497956834_2707420635_7811569379_942, 0.0504059214_0278234684_0893085653_585, 0.0508817958_9874960649_2297473049_805, 0.0512215478_4925877217_0656282604_944, 0.0514261285_3745902593_3862879215_781, 0.0514947294_2945156755_8340433647_099, 0.0514261285_3745902593_3862879215_781, 0.0512215478_4925877217_0656282604_944, 0.0508817958_9874960649_2297473049_805, 0.0504059214_0278234684_0893085653_585, 0.0497956834_2707420635_7811569379_942, 0.0490554345_5502977888_7528165367_238, 0.0481858617_5708712914_0779492298_305, 0.0471855465_6929915394_5261478181_099, 0.0460592382_7100698811_6271735559_374, 0.0448148001_3316266319_2355551616_723, 0.0434525397_0135606931_6831728117_073, 0.0419698102_1516424614_7147541285_970, 0.0403745389_5153595911_1995279752_468, 0.0386789456_2472759295_0348651532_281, 0.0368823646_5182122922_3911065617_136, 0.0349793380_2806002413_7499670731_468, 0.0329814470_5748372603_1814191016_854, 0.0309072575_6238776247_2884252943_092, 0.0287540487_6504129284_3978785354_334, 0.0265099548_8233310161_0601709335_075, 0.0241911620_7808060136_5686370725_232, 0.0218280358_2160919229_7167485738_339, 0.0194141411_9394238117_3408951050_128, 0.0169208891_8905327262_7572289420_322, 0.0143697295_0704580481_2451432443_580, 0.0118230152_5349634174_2232898853_251, 0.0092732796_5951776342_8441146892_024, 0.0066307039_1593129217_3319826369_750, 0.0038904611_2709988405_1267201844_516, 0.0013890136_9867700762_4551591226_760); Gauss_Roots_61 : constant Gauss_Values := (-0.9994844100_5049063757_1325895705_811, -0.9968934840_7464954027_1630050918_695, -0.9916309968_7040459485_8628366109_486, -0.9836681232_7974720997_0032581605_663, -0.9731163225_0112626837_4693868423_707, -0.9600218649_6830751221_6871025581_798, -0.9443744447_4855997941_5831324037_439, -0.9262000474_2927432587_9324277080_474, -0.9055733076_9990779854_6522558925_958, -0.8825605357_9205268154_3116462530_226, -0.8572052335_4606109895_8658510658_944, -0.8295657623_8276839744_2898119732_502, -0.7997278358_2183908301_3668942322_683, -0.7677774321_0482619491_7977340974_503, -0.7337900624_5322680472_6171131369_528, -0.6978504947_9331579693_2292388026_640, -0.6600610641_2662696137_0053668149_271, -0.6205261829_8924286114_0477556431_189, -0.5793452358_2636169175_6024932172_540, -0.5366241481_4201989926_4169793311_073, -0.4924804678_6177857499_3693061207_709, -0.4470337695_3808917678_0609900322_854, -0.4004012548_3039439253_5476211542_661, -0.3527047255_3087811347_1037207089_374, -0.3040732022_7362507737_2677107199_257, -0.2546369261_6788984643_9805129817_805, -0.2045251166_8230989143_8957671002_025, -0.1538699136_0858354696_3794672743_256, -0.1028069379_6673703014_7096751318_001, -0.0514718425_5531769583_3025213166_723, 0.0, 0.0514718425_5531769583_3025213166_723, 0.1028069379_6673703014_7096751318_001, 0.1538699136_0858354696_3794672743_256, 0.2045251166_8230989143_8957671002_025, 0.2546369261_6788984643_9805129817_805, 0.3040732022_7362507737_2677107199_257, 0.3527047255_3087811347_1037207089_374, 0.4004012548_3039439253_5476211542_661, 0.4470337695_3808917678_0609900322_854, 0.4924804678_6177857499_3693061207_709, 0.5366241481_4201989926_4169793311_073, 0.5793452358_2636169175_6024932172_540, 0.6205261829_8924286114_0477556431_189, 0.6600610641_2662696137_0053668149_271, 0.6978504947_9331579693_2292388026_640, 0.7337900624_5322680472_6171131369_528, 0.7677774321_0482619491_7977340974_503, 0.7997278358_2183908301_3668942322_683, 0.8295657623_8276839744_2898119732_502, 0.8572052335_4606109895_8658510658_944, 0.8825605357_9205268154_3116462530_226, 0.9055733076_9990779854_6522558925_958, 0.9262000474_2927432587_9324277080_474, 0.9443744447_4855997941_5831324037_439, 0.9600218649_6830751221_6871025581_798, 0.9731163225_0112626837_4693868423_707, 0.9836681232_7974720997_0032581605_663, 0.9916309968_7040459485_8628366109_486, 0.9968934840_7464954027_1630050918_695, 0.9994844100_5049063757_1325895705_811); -- The following weights are used in a 30 point gauss -- quadrature rule. Their usual purpose is to estimate the -- the error in the 61-point calculation. They are associated with -- X-axis points at index 2*I-1 = -3,-1,1,3 ... in the array -- Gauss_Roots. So its not necessary to re-evaluate the function to -- estimate error. subtype Gauss_Index_30 is Gauss_Index_61 range -14..15; Gauss_Weights_30 : constant array(Gauss_Index_30) of Real := (0.0079681924_9616660561_5465883474_674, 0.0184664683_1109095914_2302131912_047, 0.0287847078_8332336934_9719179611_292, 0.0387991925_6962704959_6801936446_348, 0.0484026728_3059405290_2938140422_808, 0.0574931562_1761906648_1721689402_056, 0.0659742298_8218049512_8128515115_962, 0.0737559747_3770520626_8243850022_191, 0.0807558952_2942021535_4694938460_530, 0.0868997872_0108297980_2387530715_126, 0.0921225222_3778612871_7632707087_619, 0.0963687371_7464425963_9468626351_810, 0.0995934205_8679526706_2780282103_569, 0.1017623897_4840550459_6428952168_554, 0.1028526528_9355884034_1285636705_415, 0.1028526528_9355884034_1285636705_415, 0.1017623897_4840550459_6428952168_554, 0.0995934205_8679526706_2780282103_569, 0.0963687371_7464425963_9468626351_810, 0.0921225222_3778612871_7632707087_619, 0.0868997872_0108297980_2387530715_126, 0.0807558952_2942021535_4694938460_530, 0.0737559747_3770520626_8243850022_191, 0.0659742298_8218049512_8128515115_962, 0.0574931562_1761906648_1721689402_056, 0.0484026728_3059405290_2938140422_808, 0.0387991925_6962704959_6801936446_348, 0.0287847078_8332336934_9719179611_292, 0.0184664683_1109095914_2302131912_047, 0.0079681924_9616660561_5465883474_674); end Gauss_Nodes_61;
with Ada.Text_IO; with Ada.Float_Text_IO; with Eval; with My_Custom_Int; procedure Eval_Main is package Eval_Integer is new Eval (T => Integer, Image => Integer'Image, "=" => "=", "+" => "+", "-" => "-", "*" => "*", "/" => "/"); package Eval_Float is new Eval (T => Float, Image => Float'Image, "=" => "=", "+" => "+", "-" => "-", "*" => "*", "/" => "/"); -- works for custom types as well package Eval_My_Custom_Int is new Eval (T => My_Custom_Int.My_Custom_Int, Image => My_Custom_Int.Image, "=" => My_Custom_Int."=", "+" => My_Custom_Int."+", "-" => My_Custom_Int."-", "*" => My_Custom_Int."*", "/" => My_Custom_Int."/"); -- 2 + 3 * 4 E1 : constant Eval_Integer.Expr := (Kind => Eval_Integer.Add, Left => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 2), Right => new Eval_Integer.Expr' (Kind => Eval_Integer.Mul, Left => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 3), Right => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 4))); -- 10 / 2 - 3 E2 : constant Eval_Integer.Expr := (Kind => Eval_Integer.Sub, Left => new Eval_Integer.Expr' (Kind => Eval_Integer.Div, Left => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 10), Right => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 2)), Right => new Eval_Integer.Expr'(Kind => Eval_Integer.Val, Val => 3)); -- 2.3 * 4.5 + 1.2 E3 : constant Eval_Float.Expr := (Kind => Eval_Float.Add, Left => new Eval_Float.Expr' (Kind => Eval_Float.Mul, Left => new Eval_Float.Expr'(Kind => Eval_Float.Val, Val => 2.3), Right => new Eval_Float.Expr'(Kind => Eval_Float.Val, Val => 4.5)), Right => new Eval_Float.Expr'(Kind => Eval_Float.Val, Val => 1.2)); -- 1.0 / 0.0 E4 : constant Eval_Float.Expr := (Kind => Eval_Float.Div, Left => new Eval_Float.Expr'(Kind => Eval_Float.Val, Val => 1.0), Right => new Eval_Float.Expr'(Kind => Eval_Float.Val, Val => 0.0)); -- My_Custom_Int { Int_Val : 10 } * My_Custom_Int { Int_Val : 2 } / My_Custom_Int { Int_Val : 5 } E5 : constant Eval_My_Custom_Int.Expr := (Kind => Eval_My_Custom_Int.Div, Left => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Mul, Left => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 10)), Right => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 2))), Right => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 5))); -- My_Custom_Int { Int_Val : 100 } * My_Custom_Int { Int_Val : 2 } / My_Custom_Int { Int_Val : 5 } E6 : constant Eval_My_Custom_Int.Expr := (Kind => Eval_My_Custom_Int.Div, Left => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Mul, Left => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 100)), Right => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 2))), Right => new Eval_My_Custom_Int.Expr' (Kind => Eval_My_Custom_Int.Val, Val => (Int_Val => 5))); begin Ada.Text_IO.Put ("The expression E1 is : "); Eval_Integer.Show (E1); Ada.Text_IO.New_Line; Ada.Text_IO.Put ("And its value is " & Integer'Image (Eval_Integer.Eval (E1))); Ada.Text_IO.New_Line (2); Ada.Text_IO.Put ("The expression E2 is : "); Eval_Integer.Show (E2); Ada.Text_IO.New_Line; Ada.Text_IO.Put ("And its value is " & Integer'Image (Eval_Integer.Eval (E2))); Ada.Text_IO.New_Line (2); Ada.Text_IO.Put ("The expression E3 is : "); Eval_Float.Show (E3); Ada.Text_IO.New_Line; Ada.Text_IO.Put ("And its value is "); Ada.Float_Text_IO.Put (Eval_Float.Eval (E3), Aft => 3, Exp => 0); Ada.Text_IO.New_Line (2); Ada.Text_IO.Put ("The expression E4 is : "); Eval_Float.Show (E4); Ada.Text_IO.Put ("And its value is : "); Ada.Float_Text_IO.Put (Eval_Float.Eval (E4), Aft => 3, Exp => 0); Ada.Text_IO.New_Line (2); Ada.Text_IO.Put ("The expression E5 is : "); Eval_My_Custom_Int.Show (E5); Ada.Text_IO.New_Line; Ada.Text_IO.Put ("And its value is : "); Ada.Text_IO.Put (My_Custom_Int.Image (Eval_My_Custom_Int.Eval (E5))); Ada.Text_IO.New_Line (2); declare begin Ada.Text_IO.Put ("The expression E6 is : "); Eval_My_Custom_Int.Show (E6); Ada.Text_IO.New_Line; Ada.Text_IO.Put ("And its value is : "); Ada.Text_IO.Put (My_Custom_Int.Image (Eval_My_Custom_Int.Eval (E6))); Ada.Text_IO.New_Line (2); exception when Constraint_Error => Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Range check failed - too big a value for the My_Custom_Int type"); end; end Eval_Main;
------------------------------------------------------------------------------ -- waiters.adb -- -- Implementation of the waiters. ------------------------------------------------------------------------------ with Philosophers, Cooks, Host, Meals, Orders, Reporter, Protected_Counters; use Philosophers, Cooks, Host, Meals, Orders, Reporter, Protected_Counters; with Ada.Exceptions, Ada.Strings.Unbounded, Ada.Text_IO; use Ada.Exceptions, Ada.Strings.Unbounded; package body Waiters is Waiters_Alive: Counter(Waiter_Array'Length); task body Waiter is My_Name: Unbounded_String; procedure Report_For_Work is begin Report (My_Name & " clocking in"); end Report_For_Work; procedure Retrieve_Food_From_Kitchen_If_Possible is An_Order: Order; begin select Heat_Lamp.Read (An_Order); Report (My_Name & " gets " & An_Order.Food & " from heat lamp"); Report (My_Name & " serves " & An_Order.Food); Philosopher_Array(An_Order.Diner).Here_Is_Your_Food; or delay 2.0; Report (My_Name & " found no food at heat lamp"); end select; end Retrieve_Food_From_Kitchen_If_Possible; procedure Go_Home is Is_Zero: Boolean; begin Report (My_Name & " clocking out"); Waiters_Alive.Decrement_And_Test_If_Zero (Is_Zero); if Is_Zero then Report ("The restaurant is closing down for the night"); end if; end Go_Home; begin accept Here_Is_Your_Name (Name: Waiter_Name) do My_Name := To_Unbounded_String(Waiter_Name'Image(Name)); end Here_Is_Your_Name; Report_For_Work; while not Norman_Bates'Terminated loop select accept Place_Order(An_Order: Order; Customer: Philosopher_Name; Cook_Immediately_Available: out boolean) do Cook_Immediately_Available := False; Report (My_Name & " takes an order from " & Philosopher_Name'Image(Customer)); for C in Cook_Array'Range loop select Cook_Array(C).Prepare(An_Order); Cook_Immediately_Available := True; exit; else null; end select; end loop; end Place_Order; or delay 5.0; end select; Retrieve_Food_From_Kitchen_If_Possible; end loop; Go_Home; exception when E: others => Report ("Error: " & My_Name & " unexpectedly dead from " & Exception_Information(E)); end Waiter; end Waiters;
-- -- Raytracer implementation in Ada -- by John Perry (github: johnperry-math) -- 2021 -- -- implementation for Cameras, that view the scene -- -- local packages with RayTracing_Constants; use RayTracing_Constants; package body Cameras is function Create_Camera(Position, Target: Vector) return Camera_Type is Result: Camera_Type; Down: Vector := Create_Vector(0.0, -1.0, 0.0); Forward: Vector := Target - Position; -- computed later Right_Norm, Up_Norm: Vector; begin Result.Position := Position; Result.Forward := Normal(Forward); Result.Right := Cross_Product(Result.Forward, Down); Result.Up := Cross_Product(Result.Forward, Result.Right); Right_Norm := Normal(Result.Right); Up_Norm := Normal(Result.Up); Result.Right := Right_Norm * 1.5; Result.Up := Up_Norm * 1.5; return Result; end Create_Camera; end Cameras;
package platform is function get_ui_specification_filepath return string; function get_covid_raw_data_filepath return string; end;
-- Copyright 2015,2016,2017 Steven Stewart-Gallus -- -- 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 Interfaces; package body Linted.Update is package Storage_Elements renames System.Storage_Elements; use type Interfaces.Unsigned_32; use type Storage_Elements.Storage_Offset; subtype Tuple is Storage_Elements.Storage_Array (1 .. 4); function To_Nat (Number : Int) return Nat; function To_Bytes (Number : Nat) return Tuple; function To_Int (T : Tuple) return Int; function From_Bytes (T : Tuple) return Nat; -- Big Endian function To_Bytes (Number : Nat) return Tuple is begin return (Storage_Elements.Storage_Element (Interfaces.Shift_Right (Interfaces.Unsigned_32 (Number), 24) and 16#FF#), Storage_Elements.Storage_Element (Interfaces.Shift_Right (Interfaces.Unsigned_32 (Number), 16) and 16#FF#), Storage_Elements.Storage_Element (Interfaces.Shift_Right (Interfaces.Unsigned_32 (Number), 8) and 16#FF#), Storage_Elements.Storage_Element (Number and 16#FF#)); end To_Bytes; function From_Bytes (T : Tuple) return Nat is begin return Nat (Interfaces.Unsigned_32 (T (4)) or Interfaces.Shift_Left (Interfaces.Unsigned_32 (T (3)), 8) or Interfaces.Shift_Left (Interfaces.Unsigned_32 (T (2)), 16) or Interfaces.Shift_Left (Interfaces.Unsigned_32 (T (1)), 24)); end From_Bytes; function To_Int (T : Tuple) return Int is X : Nat; Y : Int; begin X := From_Bytes (T); if X <= Nat (Int'Last) then Y := Int (X); else Y := -Int (not X) - 1; end if; return Y; end To_Int; function To_Nat (Number : Int) return Nat is Y : Nat; begin if Number < 0 then Y := Nat (Number - Int'First) - (Nat (Int'Last) + 1); else Y := Nat (Number); end if; return Y; end To_Nat; procedure From_Storage (S : Storage; U : out Update.Packet) is begin U.X_Position := To_Int (S (1 .. 4)); U.Y_Position := To_Int (S (5 .. 8)); U.Z_Position := To_Int (S (9 .. 12)); U.MX_Position := To_Int (S (13 .. 16)); U.MY_Position := To_Int (S (17 .. 20)); U.MZ_Position := To_Int (S (21 .. 24)); U.Z_Rotation := From_Bytes (S (25 .. 28)); U.X_Rotation := From_Bytes (S (29 .. 32)); end From_Storage; procedure To_Storage (U : Update.Packet; S : out Storage) is use type System.Storage_Elements.Storage_Array; begin S := To_Bytes (To_Nat (U.X_Position)) & To_Bytes (To_Nat (U.Y_Position)) & To_Bytes (To_Nat (U.Z_Position)) & To_Bytes (To_Nat (U.MX_Position)) & To_Bytes (To_Nat (U.MY_Position)) & To_Bytes (To_Nat (U.MZ_Position)) & To_Bytes (U.Z_Rotation) & To_Bytes (U.X_Rotation); end To_Storage; end Linted.Update;
with GESTE; with GESTE.Grid; with GESTE.Tile_Bank; with Game_Assets; with Game_Assets.Tileset; with Game_Assets.Tileset_Collisions; with Game_Assets.track_1; package body Levels is Tile_Bank : aliased GESTE.Tile_Bank.Instance (Game_Assets.Tileset.Tiles'Access, Game_Assets.Tileset_Collisions.Tiles'Access, Game_Assets.Palette'Access); Track2_Mid : aliased GESTE.Grid.Instance (Game_Assets.track_1.Track.Data'Access, Tile_Bank'Access); Track2_Back : aliased GESTE.Grid.Instance (Game_Assets.track_1.Background.Data'Access, Tile_Bank'Access); ----------- -- Enter -- ----------- procedure Enter (Id : Level_Id) is pragma Unreferenced (Id); begin Track2_Mid.Enable_Collisions; Track2_Mid.Move ((0, 0)); GESTE.Add (Track2_Mid'Access, 2); Track2_Back.Move ((0, 0)); GESTE.Add (Track2_Back'Access, 1); end Enter; ----------- -- Leave -- ----------- procedure Leave (Id : Level_Id) is begin null; end Leave; end Levels;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Animals.Humans is function Make (Name : String; Sex : Sex_Type) return Human is H : Human; begin H.Number_Of_Legs := 2; H.Number_Of_Wings := 0; H.Name := To_Unbounded_String (Name); H.Sex := Sex; return H; end Make; function Get_Name (H : Human) return Unbounded_String is (H.Name); function Get_Sex (H : Human) return Sex_Type is (H.Sex); overriding procedure Add_Wings (A : in out Human; N : Positive) is begin null; end Add_Wings; end Animals.Humans;
with AUnit.Test_Suites; generic with function Suite return AUnit.Test_Suites.Access_Test_Suite is <>; procedure AUnit.Run.Generic_Runner;
package openGL.Conversions is function to_Vector_4 (From : in rgba_Color) return Vector_4; function to_Vector_4 (From : in lucid_Color) return Vector_4; function to_Vector_3 (From : in rgb_Color) return Vector_3; function to_Vector_3 (From : in Color) return Vector_3; end openGL.Conversions;
package body Meassure_Velocity is procedure Retrieve_Velocity (Velocity_Z : out Float) is begin --if Imu.Gyro.Read.Available() not true then -- raise Gyro_Not_Available ; --end if; --Imu.gyro.read(data); --z_gyro = gyro.data(z_angle); --return z_gyro; Z_Coordinate := 2.0; Velocity_Z := Z_Coordinate; end Retrieve_Velocity; end Meassure_Velocity;
with Ada.Command_Line, Ada.Text_IO; with URL; procedure Test_URL_Decode is use Ada.Command_Line, Ada.Text_IO; begin if Argument_Count = 0 then Put_Line (URL.Decode ("http%3A%2F%2Ffoo%20bar%2F")); else for I in 1 .. Argument_Count loop Put_Line (URL.Decode (Argument (I))); end loop; end if; end Test_URL_Decode;
with Ada.Unchecked_Conversion; package body Inline1_Pkg is type Ieee_Short_Real is record Mantisse_Sign : Integer range 0 .. 1; Exponent : Integer range 0 .. 2 ** 8 - 1; Mantisse : Integer range 0 .. 2 ** 23 - 1; end record; for Ieee_Short_Real use record Mantisse_Sign at 0 range 31 .. 31; Exponent at 0 range 23 .. 30; Mantisse at 0 range 0 .. 22; end record; function Valid_Real (Number : Float) return Boolean is function To_Ieee_Short_Real is new Ada.Unchecked_Conversion (Float, Ieee_Short_Real); begin return To_Ieee_Short_Real (Number).Exponent /= 255; end Valid_Real; function Invalid_Real return Float is function To_Float is new Ada.Unchecked_Conversion (Ieee_Short_Real, Float); begin return To_Float (Ieee_Short_Real'(Mantisse_Sign => 0, Exponent => 255, Mantisse => 0)); end Invalid_Real; end Inline1_Pkg;
function Get_String return String is Line : String (1 .. 1_000); Last : Natural; begin Get_Line (Line, Last); return Line (1 .. Last); end Get_String; function Get_Integer return Integer is S : constant String := Get_String; begin return Integer'Value (S); -- may raise exception Constraint_Error if value entered is not a well-formed integer end Get_Integer;
with sys_h, Interfaces.C.Strings, Interfaces.C.Extensions; use sys_h, Interfaces.C; package body Libtcod.Clipboard is use type Extensions.bool; --------- -- set -- --------- procedure set(value : String) is c_value : aliased char_array := To_C(value); status : constant Extensions.bool := TCOD_sys_clipboard_set(Strings.To_Chars_Ptr(c_value'Unchecked_Access)); begin if not status then raise Constraint_Error with "Failed to copy to the clipboard"; end if; end set; --------- -- get -- --------- function get return String is (Strings.Value(TCOD_sys_clipboard_get)); end Libtcod.Clipboard;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . T C H K -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2005, 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, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Token scan routines -- Error recovery: none of the T_xxx or TF_xxx routines raise Error_Resync separate (Par) package body Tchk is type Position is (SC, BC, AP); -- Specify position of error message (see Error_Msg_SC/BC/AP) ----------------------- -- Local Subprograms -- ----------------------- procedure Check_Token (T : Token_Type; P : Position); pragma Inline (Check_Token); -- Called by T_xx routines to check for reserved keyword token. P is the -- position of the error message if the token is missing (see Wrong_Token) procedure Wrong_Token (T : Token_Type; P : Position); -- Called when scanning a reserved keyword when the keyword is not -- present. T is the token type for the keyword, and P indicates the -- position to be used to place a message relative to the current -- token if the keyword is not located nearby. ----------------- -- Check_Token -- ----------------- procedure Check_Token (T : Token_Type; P : Position) is begin if Token = T then Scan; return; else Wrong_Token (T, P); end if; end Check_Token; ------------- -- T_Abort -- ------------- procedure T_Abort is begin Check_Token (Tok_Abort, SC); end T_Abort; ------------- -- T_Arrow -- ------------- procedure T_Arrow is begin if Token = Tok_Arrow then Scan; -- A little recovery helper, accept then in place of => elsif Token = Tok_Then then Error_Msg_BC ("missing ""='>"""); Scan; -- past THEN used in place of => elsif Token = Tok_Colon_Equal then Error_Msg_SC (""":="" should be ""='>"""); Scan; -- past := used in place of => else Error_Msg_AP ("missing ""='>"""); end if; end T_Arrow; ---------- -- T_At -- ---------- procedure T_At is begin Check_Token (Tok_At, SC); end T_At; ------------ -- T_Body -- ------------ procedure T_Body is begin Check_Token (Tok_Body, BC); end T_Body; ----------- -- T_Box -- ----------- procedure T_Box is begin if Token = Tok_Box then Scan; else Error_Msg_AP ("missing ""'<'>"""); end if; end T_Box; ------------- -- T_Colon -- ------------- procedure T_Colon is begin if Token = Tok_Colon then Scan; else Error_Msg_AP ("missing "":"""); end if; end T_Colon; ------------------- -- T_Colon_Equal -- ------------------- procedure T_Colon_Equal is begin if Token = Tok_Colon_Equal then Scan; elsif Token = Tok_Equal then Error_Msg_SC ("""="" should be "":="""); Scan; elsif Token = Tok_Colon then Error_Msg_SC (""":"" should be "":="""); Scan; elsif Token = Tok_Is then Error_Msg_SC ("IS should be "":="""); Scan; else Error_Msg_AP ("missing "":="""); end if; end T_Colon_Equal; ------------- -- T_Comma -- ------------- procedure T_Comma is begin if Token = Tok_Comma then Scan; else if Token = Tok_Pragma then P_Pragmas_Misplaced; end if; if Token = Tok_Comma then Scan; else Error_Msg_AP ("missing "","""); end if; end if; if Token = Tok_Pragma then P_Pragmas_Misplaced; end if; end T_Comma; --------------- -- T_Dot_Dot -- --------------- procedure T_Dot_Dot is begin if Token = Tok_Dot_Dot then Scan; else Error_Msg_AP ("missing "".."""); end if; end T_Dot_Dot; ----------- -- T_For -- ----------- procedure T_For is begin Check_Token (Tok_For, AP); end T_For; ----------------------- -- T_Greater_Greater -- ----------------------- procedure T_Greater_Greater is begin if Token = Tok_Greater_Greater then Scan; else Error_Msg_AP ("missing ""'>'>"""); end if; end T_Greater_Greater; ------------------ -- T_Identifier -- ------------------ procedure T_Identifier is begin if Token = Tok_Identifier then Scan; elsif Token in Token_Class_Literal then Error_Msg_SC ("identifier expected"); Scan; else Error_Msg_AP ("identifier expected"); end if; end T_Identifier; ---------- -- T_In -- ---------- procedure T_In is begin Check_Token (Tok_In, AP); end T_In; ---------- -- T_Is -- ---------- procedure T_Is is begin if Token = Tok_Is then Scan; Ignore (Tok_Semicolon); -- Allow OF, => or = to substitute for IS with complaint elsif Token = Tok_Arrow or else Token = Tok_Of or else Token = Tok_Equal then Error_Msg_SC ("missing IS"); Scan; -- token used in place of IS else Wrong_Token (Tok_Is, AP); end if; while Token = Tok_Is loop Error_Msg_SC ("extra IS ignored"); Scan; end loop; end T_Is; ------------------ -- T_Left_Paren -- ------------------ procedure T_Left_Paren is begin if Token = Tok_Left_Paren then Scan; else Error_Msg_AP ("missing ""("""); end if; end T_Left_Paren; ------------ -- T_Loop -- ------------ procedure T_Loop is begin if Token = Tok_Do then Error_Msg_SC ("LOOP expected"); Scan; else Check_Token (Tok_Loop, AP); end if; end T_Loop; ----------- -- T_Mod -- ----------- procedure T_Mod is begin Check_Token (Tok_Mod, AP); end T_Mod; ----------- -- T_New -- ----------- procedure T_New is begin Check_Token (Tok_New, AP); end T_New; ---------- -- T_Of -- ---------- procedure T_Of is begin Check_Token (Tok_Of, AP); end T_Of; ---------- -- T_Or -- ---------- procedure T_Or is begin Check_Token (Tok_Or, AP); end T_Or; --------------- -- T_Private -- --------------- procedure T_Private is begin Check_Token (Tok_Private, SC); end T_Private; ------------- -- T_Range -- ------------- procedure T_Range is begin Check_Token (Tok_Range, AP); end T_Range; -------------- -- T_Record -- -------------- procedure T_Record is begin Check_Token (Tok_Record, AP); end T_Record; ------------------- -- T_Right_Paren -- ------------------- procedure T_Right_Paren is begin if Token = Tok_Right_Paren then Scan; else Error_Msg_AP ("missing "")"""); end if; end T_Right_Paren; ----------------- -- T_Semicolon -- ----------------- procedure T_Semicolon is begin if Token = Tok_Semicolon then Scan; if Token = Tok_Semicolon then Error_Msg_SC ("extra "";"" ignored"); Scan; end if; return; elsif Token = Tok_Colon then Error_Msg_SC (""":"" should be "";"""); Scan; return; elsif Token = Tok_Comma then Error_Msg_SC (""","" should be "";"""); Scan; return; elsif Token = Tok_Dot then Error_Msg_SC ("""."" should be "";"""); Scan; return; -- An interesting little kludge here. If the previous token is a -- semicolon, then there is no way that we can legitimately need -- another semicolon. This could only arise in an error situation -- where an error has already been signalled. By simply ignoring -- the request for a semicolon in this case, we avoid some spurious -- missing semicolon messages. elsif Prev_Token = Tok_Semicolon then return; -- If the current token is | then this is a reasonable -- place to suggest the possibility of a "C" confusion :-) elsif Token = Tok_Vertical_Bar then Error_Msg_SC ("unexpected occurrence of ""'|"", did you mean OR'?"); Resync_Past_Semicolon; return; -- Deal with pragma. If pragma is not at start of line, it is -- considered misplaced otherwise we treat it as a normal -- missing semicolong case. elsif Token = Tok_Pragma and then not Token_Is_At_Start_Of_Line then P_Pragmas_Misplaced; if Token = Tok_Semicolon then Scan; return; end if; end if; -- If none of those tests return, we really have a missing semicolon Error_Msg_AP ("|missing "";"""); return; end T_Semicolon; ------------ -- T_Then -- ------------ procedure T_Then is begin Check_Token (Tok_Then, AP); end T_Then; ------------ -- T_Type -- ------------ procedure T_Type is begin Check_Token (Tok_Type, BC); end T_Type; ----------- -- T_Use -- ----------- procedure T_Use is begin Check_Token (Tok_Use, SC); end T_Use; ------------ -- T_When -- ------------ procedure T_When is begin Check_Token (Tok_When, SC); end T_When; ------------ -- T_With -- ------------ procedure T_With is begin Check_Token (Tok_With, BC); end T_With; -------------- -- TF_Arrow -- -------------- procedure TF_Arrow is Scan_State : Saved_Scan_State; begin if Token = Tok_Arrow then Scan; -- skip arrow and we are done elsif Token = Tok_Colon_Equal then T_Arrow; -- Let T_Arrow give the message else T_Arrow; -- give missing arrow message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Arrow then Scan; -- past arrow return; end if; end loop; end if; end TF_Arrow; ----------- -- TF_Is -- ----------- procedure TF_Is is Scan_State : Saved_Scan_State; begin if Token = Tok_Is then T_Is; -- past IS and we are done -- Allow OF or => or = in place of IS (with error message) elsif Token = Tok_Of or else Token = Tok_Arrow or else Token = Tok_Equal then T_Is; -- give missing IS message and skip bad token else T_Is; -- give missing IS message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Is or else Token = Tok_Of or else Token = Tok_Arrow then Scan; -- past IS or OF or => return; end if; end loop; end if; end TF_Is; ------------- -- TF_Loop -- ------------- procedure TF_Loop is Scan_State : Saved_Scan_State; begin if Token = Tok_Loop then Scan; -- past LOOP and we are done -- Allow DO or THEN in place of LOOP elsif Token = Tok_Then or else Token = Tok_Do then T_Loop; -- give missing LOOP message else T_Loop; -- give missing LOOP message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Loop or else Token = Tok_Then then Scan; -- past loop or then (message already generated) return; end if; end loop; end if; end TF_Loop; -------------- -- TF_Return-- -------------- procedure TF_Return is Scan_State : Saved_Scan_State; begin if Token = Tok_Return then Scan; -- skip RETURN and we are done else Error_Msg_SC ("missing RETURN"); Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were! return; end if; Scan; -- continue search! if Token = Tok_Return then Scan; -- past RETURN return; end if; end loop; end if; end TF_Return; ------------------ -- TF_Semicolon -- ------------------ procedure TF_Semicolon is Scan_State : Saved_Scan_State; begin if Token = Tok_Semicolon then T_Semicolon; return; -- An interesting little kludge here. If the previous token is a -- semicolon, then there is no way that we can legitimately need -- another semicolon. This could only arise in an error situation -- where an error has already been signalled. By simply ignoring -- the request for a semicolon in this case, we avoid some spurious -- missing semicolon messages. elsif Prev_Token = Tok_Semicolon then return; else -- Deal with pragma. If pragma is not at start of line, it is -- considered misplaced otherwise we treat it as a normal -- missing semicolong case. if Token = Tok_Pragma and then not Token_Is_At_Start_Of_Line then P_Pragmas_Misplaced; if Token = Tok_Semicolon then T_Semicolon; return; end if; end if; -- Here we definitely have a missing semicolon, so give message T_Semicolon; -- Scan out junk on rest of line Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search if Token = Tok_Semicolon then T_Semicolon; return; elsif Token in Token_Class_After_SM then return; end if; end loop; end if; end TF_Semicolon; ------------- -- TF_Then -- ------------- procedure TF_Then is Scan_State : Saved_Scan_State; begin if Token = Tok_Then then Scan; -- past THEN and we are done else T_Then; -- give missing THEN message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search! if Token = Tok_Then then Scan; -- past THEN return; end if; end loop; end if; end TF_Then; ------------ -- TF_Use -- ------------ procedure TF_Use is Scan_State : Saved_Scan_State; begin if Token = Tok_Use then Scan; -- past USE and we are done else T_Use; -- give USE expected message Save_Scan_State (Scan_State); -- at start of junk tokens loop if Prev_Token_Ptr < Current_Line_Start or else Token = Tok_Semicolon or else Token = Tok_EOF then Restore_Scan_State (Scan_State); -- to where we were return; end if; Scan; -- continue search! if Token = Tok_Use then Scan; -- past use return; end if; end loop; end if; end TF_Use; ----------------- -- Wrong_Token -- ----------------- procedure Wrong_Token (T : Token_Type; P : Position) is Missing : constant String := "missing "; Image : constant String := Token_Type'Image (T); Tok_Name : constant String := Image (5 .. Image'Length); M : String (1 .. Missing'Length + Tok_Name'Length); begin -- Set M to Missing & Tok_Name M (1 .. Missing'Length) := Missing; M (Missing'Length + 1 .. M'Last) := Tok_Name; if Token = Tok_Semicolon then Scan; if Token = T then Error_Msg_SP ("extra "";"" ignored"); Scan; else Error_Msg_SP (M); end if; elsif Token = Tok_Comma then Scan; if Token = T then Error_Msg_SP ("extra "","" ignored"); Scan; else Error_Msg_SP (M); end if; else case P is when SC => Error_Msg_SC (M); when BC => Error_Msg_BC (M); when AP => Error_Msg_AP (M); end case; end if; end Wrong_Token; end Tchk;
package DFA with SPARK_Mode => On is -- This package illustrates the basics of data-flow analysis (DFA) in SPARK function F1 (X : in Integer) return Integer; function F2 (X : in Integer) return Integer; end DFA;
separate (Numerics.Sparse_Matrices) -- function Minus (Left : in Sparse_Matrix; -- Right : in Sparse_Matrix) return Sparse_Matrix is -- Result : Sparse_Matrix := Right; -- begin -- for X of Result.X loop -- X := -X; -- end loop; -- return Left + Result; -- end Minus; function Minus (Left : in Sparse_Matrix; Right : in Sparse_Matrix) return Sparse_Matrix is use Ada.Containers, Ada.Text_IO; A : Sparse_Matrix renames Left; B : Sparse_Matrix renames Right; C : Sparse_Matrix; N_Col : Nat renames A.N_Col; N_Row : constant Count_Type := Count_Type (A.N_Row); Res : constant Count_Type := Count_Type'Max (A.X.Length, B.X.Length); Sum : Pos := 1; P : Pos; N, M : Pos; L, R : Pos; AI, BI : Nat; begin if A.X.Length = 0 then return B; elsif B.X.Length = 0 then return A; end if; C.Format := CSC; C.N_Col := N_Col; C.N_Row := Pos (N_Row); C.P.Reserve_Capacity (Count_Type (N_Col + 1)); C.X.Reserve_Capacity (Res); C.I.Reserve_Capacity (Res); C.P.Append (1); -- 1st element is always 1 for I in 1 .. Nat (N_Col) loop if C.X.Capacity < C.X.Length + N_Row then C.X.Reserve_Capacity (C.X.Capacity + N_Row); C.I.Reserve_Capacity (C.X.Capacity + N_Row); end if; N := A.P (I); L := A.P (I + 1) - 1; M := B.P (I); R := B.P (I + 1) - 1; P := 0; while N <= L and M <= R loop P := P + 1; AI := A.I (N); BI := B.I (M); if AI = BI then C.X.Append (A.X (N) - B.X (M)); C.I.Append (AI); N := N + 1; M := M + 1; elsif AI < BI then C.X.Append (A.X (N)); C.I.Append (AI); N := N + 1; elsif AI > BI then C.X.Append (-B.X (M)); C.I.Append (BI); M := M + 1; end if; end loop; while M > R and then N <= L loop P := P + 1; C.X.Append (A.X (N)); C.I.Append (A.I (N)); N := N + 1; end loop; while N > L and then M <= R loop P := P + 1; C.X.Append (-B.X (M)); C.I.Append (B.I (M)); M := M + 1; end loop; Sum := Sum + P; C.P.Append (Sum); end loop; Sum := Sum - 1; C.X.Reserve_Capacity (Count_Type (Sum)); C.I.Reserve_Capacity (Count_Type (Sum)); return C; end Minus;
with FLTK.Event, Interfaces.C, System; use type Interfaces.C.unsigned_long, System.Address; package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure text_editor_set_draw_hook (W, D : in System.Address); pragma Import (C, text_editor_set_draw_hook, "text_editor_set_draw_hook"); pragma Inline (text_editor_set_draw_hook); procedure text_editor_set_handle_hook (W, H : in System.Address); pragma Import (C, text_editor_set_handle_hook, "text_editor_set_handle_hook"); pragma Inline (text_editor_set_handle_hook); function new_fl_text_editor (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_text_editor, "new_fl_text_editor"); pragma Inline (new_fl_text_editor); procedure free_fl_text_editor (TE : in System.Address); pragma Import (C, free_fl_text_editor, "free_fl_text_editor"); pragma Inline (free_fl_text_editor); procedure fl_text_editor_default (TE : in System.Address; K : in Interfaces.C.int); pragma Import (C, fl_text_editor_default, "fl_text_editor_default"); pragma Inline (fl_text_editor_default); procedure fl_text_editor_undo (TE : in System.Address); pragma Import (C, fl_text_editor_undo, "fl_text_editor_undo"); pragma Inline (fl_text_editor_undo); procedure fl_text_editor_cut (TE : in System.Address); pragma Import (C, fl_text_editor_cut, "fl_text_editor_cut"); pragma Inline (fl_text_editor_cut); procedure fl_text_editor_copy (TE : in System.Address); pragma Import (C, fl_text_editor_copy, "fl_text_editor_copy"); pragma Inline (fl_text_editor_copy); procedure fl_text_editor_paste (TE : in System.Address); pragma Import (C, fl_text_editor_paste, "fl_text_editor_paste"); pragma Inline (fl_text_editor_paste); procedure fl_text_editor_delete (TE : in System.Address); pragma Import (C, fl_text_editor_delete, "fl_text_editor_delete"); pragma Inline (fl_text_editor_delete); procedure fl_text_editor_select_all (TE : in System.Address); pragma Import (C, fl_text_editor_select_all, "fl_text_editor_select_all"); pragma Inline (fl_text_editor_select_all); procedure fl_text_editor_backspace (TE : in System.Address); pragma Import (C, fl_text_editor_backspace, "fl_text_editor_backspace"); pragma Inline (fl_text_editor_backspace); procedure fl_text_editor_insert (TE : in System.Address); pragma Import (C, fl_text_editor_insert, "fl_text_editor_insert"); pragma Inline (fl_text_editor_insert); procedure fl_text_editor_enter (TE : in System.Address); pragma Import (C, fl_text_editor_enter, "fl_text_editor_enter"); pragma Inline (fl_text_editor_enter); procedure fl_text_editor_ignore (TE : in System.Address); pragma Import (C, fl_text_editor_ignore, "fl_text_editor_ignore"); pragma Inline (fl_text_editor_ignore); procedure fl_text_editor_home (TE : in System.Address); pragma Import (C, fl_text_editor_home, "fl_text_editor_home"); pragma Inline (fl_text_editor_home); procedure fl_text_editor_end (TE : in System.Address); pragma Import (C, fl_text_editor_end, "fl_text_editor_end"); pragma Inline (fl_text_editor_end); procedure fl_text_editor_page_down (TE : in System.Address); pragma Import (C, fl_text_editor_page_down, "fl_text_editor_page_down"); pragma Inline (fl_text_editor_page_down); procedure fl_text_editor_page_up (TE : in System.Address); pragma Import (C, fl_text_editor_page_up, "fl_text_editor_page_up"); pragma Inline (fl_text_editor_page_up); procedure fl_text_editor_down (TE : in System.Address); pragma Import (C, fl_text_editor_down, "fl_text_editor_down"); pragma Inline (fl_text_editor_down); procedure fl_text_editor_left (TE : in System.Address); pragma Import (C, fl_text_editor_left, "fl_text_editor_left"); pragma Inline (fl_text_editor_left); procedure fl_text_editor_right (TE : in System.Address); pragma Import (C, fl_text_editor_right, "fl_text_editor_right"); pragma Inline (fl_text_editor_right); procedure fl_text_editor_up (TE : in System.Address); pragma Import (C, fl_text_editor_up, "fl_text_editor_up"); pragma Inline (fl_text_editor_up); procedure fl_text_editor_shift_home (TE : in System.Address); pragma Import (C, fl_text_editor_shift_home, "fl_text_editor_shift_home"); pragma Inline (fl_text_editor_shift_home); procedure fl_text_editor_shift_end (TE : in System.Address); pragma Import (C, fl_text_editor_shift_end, "fl_text_editor_shift_end"); pragma Inline (fl_text_editor_shift_end); procedure fl_text_editor_shift_page_down (TE : in System.Address); pragma Import (C, fl_text_editor_shift_page_down, "fl_text_editor_shift_page_down"); pragma Inline (fl_text_editor_shift_page_down); procedure fl_text_editor_shift_page_up (TE : in System.Address); pragma Import (C, fl_text_editor_shift_page_up, "fl_text_editor_shift_page_up"); pragma Inline (fl_text_editor_shift_page_up); procedure fl_text_editor_shift_down (TE : in System.Address); pragma Import (C, fl_text_editor_shift_down, "fl_text_editor_shift_down"); pragma Inline (fl_text_editor_shift_down); procedure fl_text_editor_shift_left (TE : in System.Address); pragma Import (C, fl_text_editor_shift_left, "fl_text_editor_shift_left"); pragma Inline (fl_text_editor_shift_left); procedure fl_text_editor_shift_right (TE : in System.Address); pragma Import (C, fl_text_editor_shift_right, "fl_text_editor_shift_right"); pragma Inline (fl_text_editor_shift_right); procedure fl_text_editor_shift_up (TE : in System.Address); pragma Import (C, fl_text_editor_shift_up, "fl_text_editor_shift_up"); pragma Inline (fl_text_editor_shift_up); procedure fl_text_editor_ctrl_home (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_home, "fl_text_editor_ctrl_home"); pragma Inline (fl_text_editor_ctrl_home); procedure fl_text_editor_ctrl_end (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_end, "fl_text_editor_ctrl_end"); pragma Inline (fl_text_editor_ctrl_end); procedure fl_text_editor_ctrl_page_down (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_page_down, "fl_text_editor_ctrl_page_down"); pragma Inline (fl_text_editor_ctrl_page_down); procedure fl_text_editor_ctrl_page_up (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_page_up, "fl_text_editor_ctrl_page_up"); pragma Inline (fl_text_editor_ctrl_page_up); procedure fl_text_editor_ctrl_down (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_down, "fl_text_editor_ctrl_down"); pragma Inline (fl_text_editor_ctrl_down); procedure fl_text_editor_ctrl_left (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_left, "fl_text_editor_ctrl_left"); pragma Inline (fl_text_editor_ctrl_left); procedure fl_text_editor_ctrl_right (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_right, "fl_text_editor_ctrl_right"); pragma Inline (fl_text_editor_ctrl_right); procedure fl_text_editor_ctrl_up (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_up, "fl_text_editor_ctrl_up"); pragma Inline (fl_text_editor_ctrl_up); procedure fl_text_editor_ctrl_shift_home (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_home, "fl_text_editor_ctrl_shift_home"); pragma Inline (fl_text_editor_ctrl_shift_home); procedure fl_text_editor_ctrl_shift_end (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_end, "fl_text_editor_ctrl_shift_end"); pragma Inline (fl_text_editor_ctrl_shift_end); procedure fl_text_editor_ctrl_shift_page_down (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_page_down, "fl_text_editor_ctrl_shift_page_down"); pragma Inline (fl_text_editor_ctrl_shift_page_down); procedure fl_text_editor_ctrl_shift_page_up (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_page_up, "fl_text_editor_ctrl_shift_page_up"); pragma Inline (fl_text_editor_ctrl_shift_page_up); procedure fl_text_editor_ctrl_shift_down (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_down, "fl_text_editor_ctrl_shift_down"); pragma Inline (fl_text_editor_ctrl_shift_down); procedure fl_text_editor_ctrl_shift_left (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_left, "fl_text_editor_ctrl_shift_left"); pragma Inline (fl_text_editor_ctrl_shift_left); procedure fl_text_editor_ctrl_shift_right (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_right, "fl_text_editor_ctrl_shift_right"); pragma Inline (fl_text_editor_ctrl_shift_right); procedure fl_text_editor_ctrl_shift_up (TE : in System.Address); pragma Import (C, fl_text_editor_ctrl_shift_up, "fl_text_editor_ctrl_shift_up"); pragma Inline (fl_text_editor_ctrl_shift_up); procedure fl_text_editor_add_key_binding (TE : in System.Address; K, S : in Interfaces.C.int; F : in System.Address); pragma Import (C, fl_text_editor_add_key_binding, "fl_text_editor_add_key_binding"); pragma Inline (fl_text_editor_add_key_binding); -- this particular procedure won't be necessary when FLTK keybindings fixed procedure fl_text_editor_remove_key_binding (TE : in System.Address; K, S : in Interfaces.C.int); pragma Import (C, fl_text_editor_remove_key_binding, "fl_text_editor_remove_key_binding"); pragma Inline (fl_text_editor_remove_key_binding); procedure fl_text_editor_remove_all_key_bindings (TE : in System.Address); pragma Import (C, fl_text_editor_remove_all_key_bindings, "fl_text_editor_remove_all_key_bindings"); pragma Inline (fl_text_editor_remove_all_key_bindings); procedure fl_text_editor_set_default_key_function (TE, F : in System.Address); pragma Import (C, fl_text_editor_set_default_key_function, "fl_text_editor_set_default_key_function"); pragma Inline (fl_text_editor_set_default_key_function); function fl_text_editor_get_insert_mode (TE : in System.Address) return Interfaces.C.int; pragma Import (C, fl_text_editor_get_insert_mode, "fl_text_editor_get_insert_mode"); pragma Inline (fl_text_editor_get_insert_mode); procedure fl_text_editor_set_insert_mode (TE : in System.Address; I : in Interfaces.C.int); pragma Import (C, fl_text_editor_set_insert_mode, "fl_text_editor_set_insert_mode"); pragma Inline (fl_text_editor_set_insert_mode); -- function fl_text_editor_get_tab_nav -- (TE : in System.Address) -- return Interfaces.C.int; -- pragma Import (C, fl_text_editor_get_tab_nav, "fl_text_editor_get_tab_nav"); -- pragma Inline (fl_text_editor_get_tab_nav); -- procedure fl_text_editor_set_tab_nav -- (TE : in System.Address; -- T : in Interfaces.C.int); -- pragma Import (C, fl_text_editor_set_tab_nav, "fl_text_editor_set_tab_nav"); -- pragma Inline (fl_text_editor_set_tab_nav); procedure fl_text_editor_draw (W : in System.Address); pragma Import (C, fl_text_editor_draw, "fl_text_editor_draw"); pragma Inline (fl_text_editor_draw); function fl_text_editor_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_text_editor_handle, "fl_text_editor_handle"); pragma Inline (fl_text_editor_handle); function Key_Func_Hook (K : in Interfaces.C.int; E : in System.Address) return Interfaces.C.int is Ada_Editor : access Text_Editor'Class := Editor_Convert.To_Pointer (fl_widget_get_user_data (E)); Modi : Modifier := FLTK.Event.Last_Modifier; Ada_Key : Key_Combo := To_Ada (Interfaces.C.unsigned_long (K) + To_C (Modi)); Found_Binding : Boolean := False; begin for B of Ada_Editor.Bindings loop if B.Key = Ada_Key then B.Func (Ada_Editor.all); Found_Binding := True; end if; end loop; if not Found_Binding and then Ada_Editor.Default_Func /= null then Ada_Editor.Default_Func (Ada_Editor.all, Ada_Key); end if; return 1; end Key_Func_Hook; procedure Finalize (This : in out Text_Editor) is begin if This.Void_Ptr /= System.Null_Address and then This in Text_Editor'Class then This.Clear; free_fl_text_editor (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Text_Display (This)); end Finalize; -- remove this type and array once FLTK keybindings fixed -- type To_Remove is record -- Press : Keypress; -- Modif : Interfaces.C.int; -- end record; -- To_Remove_List : array (Positive range <>) of To_Remove := -- ((Home_Key, 0), -- (End_Key, 0), -- (Page_Down_Key, 0), -- (Page_Up_Key, 0), -- (Down_Key, 0), -- (Left_Key, 0), -- (Right_Key, 0), -- (Up_Key, 0), -- (Character'Pos ('/'), Interfaces.C.int (Mod_Ctrl)), -- (Delete_Key, Interfaces.C.int (Mod_Shift)), -- (Insert_Key, Interfaces.C.int (Mod_Ctrl)), -- (Insert_Key, Interfaces.C.int (Mod_Shift))); -- use type Interfaces.C.int; -- To_Remove_Weird : array (Positive range <>) of To_Remove := -- ((Enter_Key, -1), -- (Keypad_Enter_Key, -1), -- (Backspace_Key, -1), -- (Insert_Key, -1), -- (Delete_Key, -1), -- (Escape_Key, -1)); package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Text_Editor is use type Interfaces.C.int; begin return This : Text_Editor do This.Void_Ptr := new_fl_text_editor (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_group_end (This.Void_Ptr); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); text_editor_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); text_editor_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); -- change things over so key bindings are all handled from the Ada side This.Bindings := Binding_Vectors.Empty_Vector; for B of Default_Key_Bindings loop This.Bindings.Append (B); end loop; This.Default_Func := Default'Access; -- remove these loops and uncomment subsequent "remove_all_key_bindings" -- when FLTK keybindings fixed -- for B of To_Remove_List loop -- fl_text_editor_remove_key_binding -- (This.Void_Ptr, -- Interfaces.C.int (B.Press), -- B.Modif * 65536); -- end loop; -- for B of To_Remove_Weird loop -- fl_text_editor_remove_key_binding -- (This.Void_Ptr, -- Interfaces.C.int (B.Press), -- B.Modif); -- end loop; fl_text_editor_remove_all_key_bindings (This.Void_Ptr); fl_text_editor_set_default_key_function (This.Void_Ptr, Key_Func_Hook'Address); -- this is irritatingly required due to how FLTK handles certain keys -- for B of Default_Key_Bindings loop -- -- remove this conditional once FLTK keybindings fixed -- if B.Key.Modcode = Mod_None then -- fl_text_editor_add_key_binding -- (This.Void_Ptr, -- Interfaces.C.int (B.Key.Keycode), -- Interfaces.C.int (B.Key.Modcode) * 65536, -- Key_Func_Hook'Address); -- end if; -- end loop; end return; end Create; end Forge; procedure Default (This : in out Text_Editor'Class; Key : in Key_Combo) is begin fl_text_editor_default (This.Void_Ptr, Interfaces.C.int (Key.Keycode)); end Default; procedure Undo (This : in out Text_Editor'Class) is begin fl_text_editor_undo (This.Void_Ptr); end Undo; procedure Cut (This : in out Text_Editor'Class) is begin fl_text_editor_cut (This.Void_Ptr); end Cut; procedure Copy (This : in out Text_Editor'Class) is begin fl_text_editor_copy (This.Void_Ptr); end Copy; procedure Paste (This : in out Text_Editor'Class) is begin fl_text_editor_paste (This.Void_Ptr); end Paste; procedure Delete (This : in out Text_Editor'Class) is begin fl_text_editor_delete (This.Void_Ptr); end Delete; procedure Select_All (This : in out Text_Editor'Class) is begin fl_text_editor_select_all (This.Void_Ptr); end Select_All; procedure KF_Backspace (This : in out Text_Editor'Class) is begin fl_text_editor_backspace (This.Void_Ptr); end KF_Backspace; procedure KF_Insert (This : in out Text_Editor'Class) is begin fl_text_editor_insert (This.Void_Ptr); end KF_Insert; procedure KF_Enter (This : in out Text_Editor'Class) is begin fl_text_editor_enter (This.Void_Ptr); end KF_Enter; procedure KF_Ignore (This : in out Text_Editor'Class) is begin fl_text_editor_ignore (This.Void_Ptr); end KF_Ignore; procedure KF_Home (This : in out Text_Editor'Class) is begin fl_text_editor_home (This.Void_Ptr); end KF_Home; procedure KF_End (This : in out Text_Editor'Class) is begin fl_text_editor_end (This.Void_Ptr); end KF_End; procedure KF_Page_Down (This : in out Text_Editor'Class) is begin fl_text_editor_page_down (This.Void_Ptr); end KF_Page_Down; procedure KF_Page_Up (This : in out Text_Editor'Class) is begin fl_text_editor_page_up (This.Void_Ptr); end KF_Page_Up; procedure KF_Down (This : in out Text_Editor'Class) is begin fl_text_editor_down (This.Void_Ptr); end KF_Down; procedure KF_Left (This : in out Text_Editor'Class) is begin fl_text_editor_left (This.Void_Ptr); end KF_Left; procedure KF_Right (This : in out Text_Editor'Class) is begin fl_text_editor_right (This.Void_Ptr); end KF_Right; procedure KF_Up (This : in out Text_Editor'Class) is begin fl_text_editor_up (This.Void_Ptr); end KF_Up; procedure KF_Shift_Home (This : in out Text_Editor'Class) is begin fl_text_editor_shift_home (This.Void_Ptr); end KF_Shift_Home; procedure KF_Shift_End (This : in out Text_Editor'Class) is begin fl_text_editor_shift_end (This.Void_Ptr); end KF_Shift_End; procedure KF_Shift_Page_Down (This : in out Text_Editor'Class) is begin fl_text_editor_shift_page_down (This.Void_Ptr); end KF_Shift_Page_Down; procedure KF_Shift_Page_Up (This : in out Text_Editor'Class) is begin fl_text_editor_shift_page_up (This.Void_Ptr); end KF_Shift_Page_Up; procedure KF_Shift_Down (This : in out Text_Editor'Class) is begin fl_text_editor_shift_down (This.Void_Ptr); end KF_Shift_Down; procedure KF_Shift_Left (This : in out Text_Editor'Class) is begin fl_text_editor_shift_left (This.Void_Ptr); end KF_Shift_Left; procedure KF_Shift_Right (This : in out Text_Editor'Class) is begin fl_text_editor_shift_right (This.Void_Ptr); end KF_Shift_Right; procedure KF_Shift_Up (This : in out Text_Editor'Class) is begin fl_text_editor_shift_up (This.Void_Ptr); end KF_Shift_Up; procedure KF_Ctrl_Home (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_home (This.Void_Ptr); end KF_Ctrl_Home; procedure KF_Ctrl_End (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_end (This.Void_Ptr); end KF_Ctrl_End; procedure KF_Ctrl_Page_Down (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_page_down (This.Void_Ptr); end KF_Ctrl_Page_Down; procedure KF_Ctrl_Page_Up (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_page_up (This.Void_Ptr); end KF_Ctrl_Page_Up; procedure KF_Ctrl_Down (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_down (This.Void_Ptr); end KF_Ctrl_Down; procedure KF_Ctrl_Left (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_left (This.Void_Ptr); end KF_Ctrl_Left; procedure KF_Ctrl_Right (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_right (This.Void_Ptr); end KF_Ctrl_Right; procedure KF_Ctrl_Up (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_up (This.Void_Ptr); end KF_Ctrl_Up; procedure KF_Ctrl_Shift_Home (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_home (This.Void_Ptr); end KF_Ctrl_Shift_Home; procedure KF_Ctrl_Shift_End (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_end (This.Void_Ptr); end KF_Ctrl_Shift_End; procedure KF_Ctrl_Shift_Page_Down (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_page_down (This.Void_Ptr); end KF_Ctrl_Shift_Page_Down; procedure KF_Ctrl_Shift_Page_Up (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_page_up (This.Void_Ptr); end KF_Ctrl_Shift_Page_Up; procedure KF_Ctrl_Shift_Down (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_down (This.Void_Ptr); end KF_Ctrl_Shift_Down; procedure KF_Ctrl_Shift_Left (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_left (This.Void_Ptr); end KF_Ctrl_Shift_Left; procedure KF_Ctrl_Shift_Right (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_right (This.Void_Ptr); end KF_Ctrl_Shift_Right; procedure KF_Ctrl_Shift_Up (This : in out Text_Editor'Class) is begin fl_text_editor_ctrl_shift_up (This.Void_Ptr); end KF_Ctrl_Shift_Up; procedure Add_Key_Binding (This : in out Text_Editor; Key : in Key_Combo; Func : in Key_Func) is begin This.Bindings.Append ((Key, Func)); end Add_Key_Binding; procedure Add_Key_Binding (This : in out Text_Editor; Bind : in Key_Binding) is begin This.Bindings.Append (Bind); end Add_Key_Binding; procedure Add_Key_Bindings (This : in out Text_Editor; List : in Key_Binding_List) is begin for I of List loop This.Bindings.Append (I); end loop; end Add_Key_Bindings; function Get_Bound_Key_Function (This : in Text_Editor; Key : in Key_Combo) return Key_Func is begin for I in 1 .. Integer (This.Bindings.Length) loop if This.Bindings.Element (I).Key = Key then return This.Bindings.Element (I).Func; end if; end loop; return null; end Get_Bound_Key_Function; procedure Remove_Key_Binding (This : in out Text_Editor; Key : in Key_Combo) is use type Interfaces.C.int; begin for I in reverse 1 .. Integer (This.Bindings.Length) loop if This.Bindings.Reference (I).Key = Key then This.Bindings.Delete (I); end if; end loop; -- remove this once FLTK keybindings fixed -- if Key.Modcode /= Mod_None then -- fl_text_editor_remove_key_binding -- (This.Void_Ptr, -- Interfaces.C.int (Key.Keycode), -- Interfaces.C.int (Key.Modcode) * 65536); -- end if; end Remove_Key_Binding; procedure Remove_Key_Binding (This : in out Text_Editor; Bind : in Key_Binding) is -- use type Interfaces.C.int; begin for I in reverse 1 .. Integer (This.Bindings.Length) loop if This.Bindings.Reference (I).Key = Bind.Key then This.Bindings.Delete (I); end if; end loop; -- remove this once FLTK keybindings fixed -- if Bind.Key.Modcode /= Mod_None then -- fl_text_editor_remove_key_binding -- (This.Void_Ptr, -- Interfaces.C.int (Bind.Key.Keycode), -- Interfaces.C.int (Bind.Key.Modcode) * 65536); -- end if; end Remove_Key_Binding; procedure Remove_Key_Bindings (This : in out Text_Editor; List : in Key_Binding_List) is begin for I of List loop This.Remove_Key_Binding (I); end loop; end Remove_Key_Bindings; procedure Remove_All_Key_Bindings (This : in out Text_Editor) is begin This.Bindings := Binding_Vectors.Empty_Vector; -- This.Default_Func := null; -- remove this once FLTK keybindings fixed -- fl_text_editor_remove_all_key_bindings (This.Void_Ptr); end Remove_All_Key_Bindings; function Get_Default_Key_Function (This : in Text_Editor) return Default_Key_Func is begin return This.Default_Func; end Get_Default_Key_Function; procedure Set_Default_Key_Function (This : in out Text_Editor; Func : in Default_Key_Func) is begin This.Default_Func := Func; end Set_Default_Key_Function; function Get_Insert_Mode (This : in Text_Editor) return Insert_Mode is begin return Insert_Mode'Val (fl_text_editor_get_insert_mode (This.Void_Ptr)); end Get_Insert_Mode; procedure Set_Insert_Mode (This : in out Text_Editor; To : in Insert_Mode) is begin fl_text_editor_set_insert_mode (This.Void_Ptr, Insert_Mode'Pos (To)); end Set_Insert_Mode; -- function Get_Tab_Nav_Mode -- (This : in Text_Editor) -- return Tab_Navigation is -- begin -- return Tab_Navigation'Val (fl_text_editor_get_tab_nav (This.Void_Ptr)); -- end Get_Tab_Nav_Mode; -- procedure Set_Tab_Nav_Mode -- (This : in out Text_Editor; -- To : in Tab_Navigation) is -- begin -- fl_text_editor_set_tab_nav (This.Void_Ptr, Tab_Navigation'Pos (To)); -- end Set_Tab_Nav_Mode; procedure Draw (This : in out Text_Editor) is begin fl_text_editor_draw (This.Void_Ptr); end Draw; function Handle (This : in out Text_Editor; Event : in Event_Kind) return Event_Outcome is begin return Event_Outcome'Val (fl_text_editor_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; end FLTK.Widgets.Groups.Text_Displays.Text_Editors;
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ with Ada.Numerics.Generic_Complex_Types; generic with package Complex_Types is new Ada.Numerics.Generic_Complex_Types (<>); package Ada.Numerics.Generic_Complex_Elementary_Functions is pragma Pure (Generic_Complex_Elementary_Functions); function Sqrt (X : in Complex_Types.Complex) return Complex_Types.Complex; function Log (X : in Complex_Types.Complex) return Complex_Types.Complex; function Exp (X : in Complex_Types.Complex) return Complex_Types.Complex; function Exp (X : in Complex_Types.Imaginary) return Complex_Types.Complex; function "**" (Left : in Complex_Types.Complex; Right : in Complex_Types.Complex) return Complex_Types.Complex; function "**" (Left : in Complex_Types.Complex; Right : in Complex_Types.Real'Base) return Complex_Types.Complex; function "**" (Left : in Complex_Types.Real'Base; Right : in Complex_Types.Complex) return Complex_Types.Complex; function Sin (X : in Complex_Types.Complex) return Complex_Types.Complex; function Cos (X : in Complex_Types.Complex) return Complex_Types.Complex; function Tan (X : in Complex_Types.Complex) return Complex_Types.Complex; function Cot (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arcsin (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arccos (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arctan (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arccot (X : in Complex_Types.Complex) return Complex_Types.Complex; function Sinh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Cosh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Tanh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Coth (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arcsinh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arccosh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arctanh (X : in Complex_Types.Complex) return Complex_Types.Complex; function Arccoth (X : in Complex_Types.Complex) return Complex_Types.Complex; end Ada.Numerics.Generic_Complex_Elementary_Functions;
with SubmarineSubSystem; use SubmarineSubSystem; with Ada.Text_IO; use Ada.Text_IO; package body SubmarineSubSystem with SPARK_Mode is ----------------------------------------------------------------------------------------------- -----------------------------------DOOR FUNCTIONALITY------------------------------------------ ----------------------------------------------------------------------------------------------- procedure D1Close is begin if (NuclearSubmarine.ClosingOne = Open and then NuclearSubmarine.ClosingTwo = Closed) then NuclearSubmarine.ClosingOne := Closed; end if; end D1Close; procedure D2Close is begin if (NuclearSubmarine.ClosingTwo = Open and then NuclearSubmarine.ClosingOne = Closed) then NuclearSubmarine.ClosingTwo := Closed; end if; end D2Close; procedure D1Lock is begin if (NuclearSubmarine.ClosingOne = Closed and then NuclearSubmarine.LockingOne = Unlocked) then NuclearSubmarine.LockingOne := Locked; end if; end D1Lock; procedure D2Lock is begin if (NuclearSubmarine.ClosingTwo = Closed and then NuclearSubmarine.LockingTwo = Unlocked) then NuclearSubmarine.LockingTwo := Locked; end if; end D2Lock; procedure D1Open is begin if (NuclearSubmarine.LockingOne = Unlocked and then NuclearSubmarine.ClosingOne = Closed and then NuclearSubmarine.ClosingTwo = Closed) then NuclearSubmarine.ClosingOne := Open; end if; end D1Open; procedure D2Open is begin if (NuclearSubmarine.LockingTwo = Unlocked and then NuclearSubmarine.ClosingTwo = Closed and then NuclearSubmarine.ClosingOne = Closed) then NuclearSubmarine.ClosingTwo := Open; end if; end D2Open; procedure D1Unlock is begin if (NuclearSubmarine.ClosingOne = Closed and then NuclearSubmarine.LockingOne = Locked) then NuclearSubmarine.LockingOne := Unlocked; end if; end D1Unlock; procedure D2Unlock is begin if (NuclearSubmarine.ClosingTwo = Closed and then NuclearSubmarine.LockingTwo = Locked) then NuclearSubmarine.LockingTwo := Unlocked; end if; end D2Unlock; ----------------------------------------------------------------------------------------------- -----------------------------------END OF DOOR FUNCTIONALITY----------------------------------- ----------------------------------------------------------------------------------------------- procedure StartSubmarine is begin if (NuclearSubmarine.GoodToGo = Off and then NuclearSubmarine.ClosingOne = Closed and then NuclearSubmarine.LockingOne = Locked and then NuclearSubmarine.ClosingTwo = Closed and then NuclearSubmarine.LockingTwo = Locked) then NuclearSubmarine.GoodToGo := On; else NuclearSubmarine.GoodToGo := Off; end if; end StartSubmarine; --procedure StartSubmarine is --begin -- while NuclearSubmarine.GoodToGo = Off -- and then NuclearSubmarine.ClosingOne = Closed -- and then NuclearSubmarine.LockingOne = Locked -- and then NuclearSubmarine.ClosingTwo = Closed -- and then NuclearSubmarine.LockingTwo = Locked loop -- NuclearSubmarine.GoodToGo := On; -- if NuclearSubmarine.GoodToGo = On then exit; -- else NuclearSubmarine.GoodToGo := Off; -- end if; -- end loop; --end StartSubmarine; --This procedure was made when I wanted to test if the Submarien could do something, -- ONLY when the NuclearSubmarine.GoodToGo = On. This was so I could see in the main File -- If the submarine could or could not perform actions while it was On and Off. -- As I developed the other systems though (Doors/locking was first, followed by -- submarine becoming operational) this procedure/Pre condition became a main stay with all the -- other features as along as the Submaine is operational. -- It now essentially acts as a "Two Stage" operational verification condition. Submarine -- CANNOT perform any actions (excluding door or locking related) unless -- NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.OpTest = Fire procedure SubmarineAction is begin if (NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.ClosingOne = Closed and then NuclearSubmarine.LockingOne = Locked and then NuclearSubmarine.ClosingTwo = Closed and then NuclearSubmarine.LockingTwo = Locked) then NuclearSubmarine.OpTest := Fire; else NuclearSubmarine.OpTest := CantFire; end if; end SubmarineAction; ----------------------------------------------------------------------------------------------- -----------------------------------DEPTH SENSOR FUNCTIONALITY---------------------------------- ----------------------------------------------------------------------------------------------- procedure DepthMeterCheck is begin if (NuclearSubmarine.DLevel >= 0 and NuclearSubmarine.DLevel < 5) then NuclearSubmarine.DStage := Nominal; elsif (NuclearSubmarine.DLevel >= 5 and NuclearSubmarine.DLevel < 7) then NuclearSubmarine.DStage := Warning; else NuclearSubmarine.DStage := Danger; --Put_Line("Submarine cannot go any lower! Advise going to surface!"); end if; end DepthMeterCheck; -- Test to change Depth to Test Depth Sensor Checks procedure ChangeDepth is begin if (NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.DDive = Dive and then NuclearSubmarine.DLevel < 8) then NuclearSubmarine.DLevel := NuclearSubmarine.Dlevel + 3; elsif (NuclearSubmarine.DLevel >=9) then NuclearSubmarine.DLevel := NuclearSubmarine.DLevel + 0; end if; end ChangeDepth; procedure DiveOrNot is begin if (NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.DDive = Surface and then NuclearSubmarine.RTemp = Fine) then NuclearSubmarine.DDive := Dive; else NuclearSubmarine.DDive := Surface; end if; end DiveOrNot; procedure Resurface is begin if (NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.DDive = Dive) then NuclearSubmarine.DLevel := 0; NuclearSubmarine.DDive := Surface; NuclearSubmarine.OTank := 100; end if; end Resurface; ----------------------------------------------------------------------------------------------- --------------------------- END OF DEPTH SENSOR FUNCTIONALITY---------------------------------- ----------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------- ----------------------------------- OXYGEN FUNCTIONALITY -------------------------------------- ----------------------------------------------------------------------------------------------- -- Checks Oxygen reserves within OTank. if less than a specific amount then -- Adjust it's OSate procedure OxygenReserveCheck is begin if (NuclearSubmarine.OTank = 100 or NuclearSubmarine.OTank > 30) then NuclearSubmarine.OState := High; elsif (NuclearSubmarine.OTank <= 30 and NuclearSubmarine.OTank >=1) then NuclearSubmarine.OState := Low; NuclearSubmarine.OWarning := Oxygen_Warning; --Put_Line(NuclearSubmarine.OWarning'Image); end if; end OxygenReserveCheck; procedure ConsumeOxygen is begin if (NuclearSubmarine.GoodToGo = On and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.DDive = Dive and then NuclearSubmarine.OTank >= 31) then NuclearSubmarine.OTank := NuclearSubmarine.OTank - 10; elsif (NuclearSubmarine.OTank <= 30 and NuclearSubmarine.OTank >= 10) then NuclearSubmarine.OTank := NuclearSubmarine.OTank - 10; NuclearSubmarine.OWarning := Oxygen_Warning; Put_Line(NuclearSubmarine.OWarning'Image); -- Don't know how to proof a Put_Line. elsif (NuclearSubmarine.OTank < 10) then -- List of states that will be printed in "main" when -- The Submarine runs out of oxygen. Put_Line(NuclearSubmarine.OWarning'Image); -- Don't know how to proof a Put_Line. Put_Line("Submarine has to resurface!"); -- Don't know how to proof a Put_Line. -- Submarine will resruface when this condition has been met Resurface; Put_Line(NuclearSubmarine.DDive'Image); -- Don't know how to proof a Put_Line. Put_Line("Submarine has now resurfaced"); -- Don't know how to proof a Put_Line. end if; end ConsumeOxygen; ----------------------------------------------------------------------------------------------- ------------------------------- END OF OXYGEN FUNCTIONALITY ----------------------------------- ----------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------- ----------------------------------- REACTOR FUNCTIONALITY ------------------------------------- ----------------------------------------------------------------------------------------------- procedure ReactorOverheatRoutine is begin if (NuclearSubmarine.GoodToGo = on and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.RTemp = Fine and then NuclearSubmarine.DDive = Dive) then -- Post Condition Triggers here because it cannot prove if RTemp is Overhearing or not -- I find that odd though because the code below makes it so RTemp = Fine to -- RTemp = Overheating. Therefore would trigger the NuclearSubmarine.RTemp = Overheating -- Post Condition. I cannot figure out why this is a problem and so I have to leave -- It as it as it is, because I have ran out of time to finish this assignment. -- This procedure will still pass "Bronze" level of Proofing NuclearSubmarine.RTemp := Overheating; Put_Line("The Reactor is: "); -- Don't know how to proof a Put_Line. Put_Line(NuclearSubmarine.RTemp'Image); -- Don't know how to proof a Put_Line. Put_Line("Reactor is Overheating, must resurface!"); -- Don't know how to proof a Put_Line. Resurface; Put_Line(NuclearSubmarine.DDive'Image); -- Don't know how to proof a Put_Line. end if; end ReactorOverheatRoutine; procedure CoolReactor is begin if (NuclearSubmarine.GoodToGo = on and then NuclearSubmarine.OpTest = Fire and then NuclearSubmarine.DDive = Surface and then NuclearSubmarine.RTemp = Overheating) then NuclearSubmarine.RTemp := Fine; else -- Don't know how to proof a Put_Line. Put_Line("Conditions have not been met to cool the reactor. Reactor is still: "); Put_Line(NuclearSubmarine.RTemp'Image); -- Don't know how to proof a Put_Line. end if; end CoolReactor; ----------------------------------------------------------------------------------------------- ------------------------------- END OF REACTOR FUNCTIONALITY ---------------------------------- ----------------------------------------------------------------------------------------------- end SubmarineSubSystem;
-- 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;
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ with Ada.Task_Identification; with Ada.Exceptions; package Ada.Task_Termination is pragma Preelaborate(Task_Termination); type Cause_Of_Termination is (Normal, Abnormal, Unhandled_Exception); type Termination_Handler is access protected procedure (Cause : in Cause_Of_Termination; T : in Ada.Task_Identification.Task_Id; X : in Ada.Exceptions.Exception_Occurrence); procedure Set_Dependents_Fallback_Handler (Handler: in Termination_Handler); function Current_Task_Fallback_Handler return Termination_Handler; procedure Set_Specific_Handler (T : in Ada.Task_Identification.Task_Id; Handler : in Termination_Handler); function Specific_Handler (T : Ada.Task_Identification.Task_Id) return Termination_Handler; end Ada.Task_Termination;
with Ada.Text_IO; with GNAT.OS_Lib; package body GPR_Tools.Gprslaves.Configuration is HOME : GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Getenv ("HOME"); Config_File_Path : constant String := Ada.Directories.Compose (HOME.all, Config_File_Name); --------------- -- Trace_Log -- --------------- procedure Trace_Log (Level : Verbose_Level; Message : VString) is begin Trace_Log (Level => Level, Message => S (Message)); end Trace_Log; --------------- -- Trace_Log -- --------------- procedure Trace_Log (Level : Verbose_Level; Message : String) is begin if Level > Verbosity then Ada.Text_IO.Put_Line (Message); end if; end Trace_Log; procedure Read (F : String) is begin if Exists (Config_File_Name) then Read (Config_File_Name); elsif Exists (Config_File_Path) then Read (Config_File_Path); end if; end GPR_Tools.Gprslaves.Configuration;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body LSM303AGR is function To_Axis_Data is new Ada.Unchecked_Conversion (UInt10, Axis_Data); function Read_Register (This : LSM303AGR_Accelerometer'Class; Device_Address : I2C_Address; Register_Addr : Register_Address) return UInt8; procedure Write_Register (This : LSM303AGR_Accelerometer'Class; Device_Address : I2C_Address; Register_Addr : Register_Address; Val : UInt8); function Check_Device_Id (This : LSM303AGR_Accelerometer; Device_Address : I2C_Address; WHO_AM_I_Register : Register_Address; Device_Id : Device_Identifier) return Boolean; function To_Multi_Byte_Read_Address (Register_Addr : Register_Address) return UInt16; procedure Configure (This : LSM303AGR_Accelerometer; Date_Rate : Data_Rate) is CTRLA : CTRL_REG1_A_Register; begin CTRLA.Xen := 1; CTRLA.Yen := 1; CTRLA.Zen := 1; CTRLA.LPen := 0; CTRLA.ODR := Date_Rate'Enum_Rep; This.Write_Register (Accelerometer_Address, CTRL_REG1_A, To_UInt8 (CTRLA)); end Configure; procedure Assert_Status (Status : I2C_Status); ------------------- -- Read_Register -- ------------------- function Read_Register (This : LSM303AGR_Accelerometer'Class; Device_Address : I2C_Address; Register_Addr : Register_Address) return UInt8 is Data : I2C_Data (1 .. 1); Status : I2C_Status; begin This.Port.Mem_Read (Addr => Device_Address, Mem_Addr => UInt16 (Register_Addr), Mem_Addr_Size => Memory_Size_8b, Data => Data, Status => Status); Assert_Status (Status); return Data (Data'First); end Read_Register; -------------------- -- Write_Register -- -------------------- procedure Write_Register (This : LSM303AGR_Accelerometer'Class; Device_Address : I2C_Address; Register_Addr : Register_Address; Val : UInt8) is Status : I2C_Status; begin This.Port.Mem_Write (Addr => Device_Address, Mem_Addr => UInt16 (Register_Addr), Mem_Addr_Size => Memory_Size_8b, Data => (1 => Val), Status => Status); Assert_Status (Status); end Write_Register; ----------------------------------- -- Check_Accelerometer_Device_Id -- ----------------------------------- function Check_Accelerometer_Device_Id (This : LSM303AGR_Accelerometer) return Boolean is begin return Check_Device_Id (This, Accelerometer_Address, WHO_AM_I_A, Accelerometer_Device_Id); end Check_Accelerometer_Device_Id; ---------------------------------- -- Check_Magnetometer_Device_Id -- ---------------------------------- function Check_Magnetometer_Device_Id (This : LSM303AGR_Accelerometer) return Boolean is begin return Check_Device_Id (This, Magnetometer_Address, WHO_AM_I_M, Magnetometer_Device_Id); end Check_Magnetometer_Device_Id; --------------------- -- Check_Device_Id -- --------------------- function Check_Device_Id (This : LSM303AGR_Accelerometer; Device_Address : I2C_Address; WHO_AM_I_Register : Register_Address; Device_Id : Device_Identifier) return Boolean is begin return Read_Register (This, Device_Address, WHO_AM_I_Register) = UInt8 (Device_Id); end Check_Device_Id; ------------------------ -- Read_Accelerometer -- ------------------------ function Read_Accelerometer (This : LSM303AGR_Accelerometer) return All_Axes_Data is ------------- -- Convert -- ------------- function Convert (Low, High : UInt8) return Axis_Data; function Convert (Low, High : UInt8) return Axis_Data is Tmp : UInt10; begin -- TODO: support HiRes and LoPow modes -- in conversion. Tmp := UInt10 (Shift_Right (Low, 6)); Tmp := Tmp or UInt10 (High) * 2**2; return To_Axis_Data (Tmp); end Convert; Status : I2C_Status; Data : I2C_Data (1 .. 6) := (others => 0); AxisData : All_Axes_Data := (X => 0, Y => 0, Z => 0); begin This.Port.Mem_Read (Addr => Accelerometer_Address, Mem_Addr => To_Multi_Byte_Read_Address (OUT_X_L_A), Mem_Addr_Size => Memory_Size_8b, Data => Data, Status => Status); Assert_Status (Status); -- LSM303AGR has its X-axis in the opposite direction -- of the MMA8653FCR1 sensor. AxisData.X := Convert (Data (1), Data (2)) * Axis_Data (-1); AxisData.Y := Convert (Data (3), Data (4)); AxisData.Z := Convert (Data (5), Data (6)); return AxisData; end Read_Accelerometer; function To_Multi_Byte_Read_Address (Register_Addr : Register_Address) return UInt16 -- Based on the i2c behavior of the sensor p.38, -- high MSB address allows reading multiple bytes -- from slave devices. is begin return UInt16 (Register_Addr) or MULTI_BYTE_READ; end To_Multi_Byte_Read_Address; procedure Assert_Status (Status : I2C_Status) is begin if Status /= Ok then -- No error handling... raise Program_Error; end if; end Assert_Status; end LSM303AGR;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; with Ada.Numerics; use Ada.Numerics; package Angle is function To_Degrees (Radians : Float) return Float; function To_Radians (Degrees : Float) return Float; function Find_Angle (X_Coordinate, Y_Coordinate : Float) return Float; private Pi_As_Float : Constant Float := Float(Pi); Max_Deg : Constant Float := 180.0; end Angle;
-- This file is generated by SWIG. Please do not modify by hand. -- with xcb.Pointers; with Interfaces.C; with Interfaces.C.Pointers; package xcb.pointer_Pointers is -- xcb_connection_t_Pointer_Pointer -- package C_xcb_connection_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_connection_t_Pointer, Element_Array => xcb.Pointers.xcb_connection_t_Pointer_Array, Default_Terminator => null); subtype xcb_connection_t_Pointer_Pointer is C_xcb_connection_t_Pointer_Pointers.Pointer; -- xcb_special_event_t_Pointer_Pointer -- package C_xcb_special_event_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_special_event_t_Pointer, Element_Array => xcb.Pointers.xcb_special_event_t_Pointer_Array, Default_Terminator => null); subtype xcb_special_event_t_Pointer_Pointer is C_xcb_special_event_t_Pointer_Pointers.Pointer; -- xcb_window_t_Pointer_Pointer -- package C_xcb_window_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_window_t_Pointer, Element_Array => xcb.Pointers.xcb_window_t_Pointer_Array, Default_Terminator => null); subtype xcb_window_t_Pointer_Pointer is C_xcb_window_t_Pointer_Pointers.Pointer; -- xcb_pixmap_t_Pointer_Pointer -- package C_xcb_pixmap_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_pixmap_t_Pointer, Element_Array => xcb.Pointers.xcb_pixmap_t_Pointer_Array, Default_Terminator => null); subtype xcb_pixmap_t_Pointer_Pointer is C_xcb_pixmap_t_Pointer_Pointers.Pointer; -- xcb_cursor_t_Pointer_Pointer -- package C_xcb_cursor_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_cursor_t_Pointer, Element_Array => xcb.Pointers.xcb_cursor_t_Pointer_Array, Default_Terminator => null); subtype xcb_cursor_t_Pointer_Pointer is C_xcb_cursor_t_Pointer_Pointers.Pointer; -- xcb_font_t_Pointer_Pointer -- package C_xcb_font_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_font_t_Pointer, Element_Array => xcb.Pointers.xcb_font_t_Pointer_Array, Default_Terminator => null); subtype xcb_font_t_Pointer_Pointer is C_xcb_font_t_Pointer_Pointers.Pointer; -- xcb_gcontext_t_Pointer_Pointer -- package C_xcb_gcontext_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_gcontext_t_Pointer, Element_Array => xcb.Pointers.xcb_gcontext_t_Pointer_Array, Default_Terminator => null); subtype xcb_gcontext_t_Pointer_Pointer is C_xcb_gcontext_t_Pointer_Pointers.Pointer; -- xcb_colormap_t_Pointer_Pointer -- package C_xcb_colormap_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_colormap_t_Pointer, Element_Array => xcb.Pointers.xcb_colormap_t_Pointer_Array, Default_Terminator => null); subtype xcb_colormap_t_Pointer_Pointer is C_xcb_colormap_t_Pointer_Pointers.Pointer; -- xcb_atom_t_Pointer_Pointer -- package C_xcb_atom_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_atom_t_Pointer, Element_Array => xcb.Pointers.xcb_atom_t_Pointer_Array, Default_Terminator => null); subtype xcb_atom_t_Pointer_Pointer is C_xcb_atom_t_Pointer_Pointers.Pointer; -- xcb_drawable_t_Pointer_Pointer -- package C_xcb_drawable_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_drawable_t_Pointer, Element_Array => xcb.Pointers.xcb_drawable_t_Pointer_Array, Default_Terminator => null); subtype xcb_drawable_t_Pointer_Pointer is C_xcb_drawable_t_Pointer_Pointers.Pointer; -- xcb_fontable_t_Pointer_Pointer -- package C_xcb_fontable_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_fontable_t_Pointer, Element_Array => xcb.Pointers.xcb_fontable_t_Pointer_Array, Default_Terminator => null); subtype xcb_fontable_t_Pointer_Pointer is C_xcb_fontable_t_Pointer_Pointers.Pointer; -- xcb_bool32_t_Pointer_Pointer -- package C_xcb_bool32_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_bool32_t_Pointer, Element_Array => xcb.Pointers.xcb_bool32_t_Pointer_Array, Default_Terminator => null); subtype xcb_bool32_t_Pointer_Pointer is C_xcb_bool32_t_Pointer_Pointers.Pointer; -- xcb_visualid_t_Pointer_Pointer -- package C_xcb_visualid_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_visualid_t_Pointer, Element_Array => xcb.Pointers.xcb_visualid_t_Pointer_Array, Default_Terminator => null); subtype xcb_visualid_t_Pointer_Pointer is C_xcb_visualid_t_Pointer_Pointers.Pointer; -- xcb_timestamp_t_Pointer_Pointer -- package C_xcb_timestamp_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_timestamp_t_Pointer, Element_Array => xcb.Pointers.xcb_timestamp_t_Pointer_Array, Default_Terminator => null); subtype xcb_timestamp_t_Pointer_Pointer is C_xcb_timestamp_t_Pointer_Pointers.Pointer; -- xcb_keysym_t_Pointer_Pointer -- package C_xcb_keysym_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_keysym_t_Pointer, Element_Array => xcb.Pointers.xcb_keysym_t_Pointer_Array, Default_Terminator => null); subtype xcb_keysym_t_Pointer_Pointer is C_xcb_keysym_t_Pointer_Pointers.Pointer; -- xcb_keycode_t_Pointer_Pointer -- package C_xcb_keycode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_keycode_t_Pointer, Element_Array => xcb.Pointers.xcb_keycode_t_Pointer_Array, Default_Terminator => null); subtype xcb_keycode_t_Pointer_Pointer is C_xcb_keycode_t_Pointer_Pointers.Pointer; -- xcb_keycode32_t_Pointer_Pointer -- package C_xcb_keycode32_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_keycode32_t_Pointer, Element_Array => xcb.Pointers.xcb_keycode32_t_Pointer_Array, Default_Terminator => null); subtype xcb_keycode32_t_Pointer_Pointer is C_xcb_keycode32_t_Pointer_Pointers.Pointer; -- xcb_button_t_Pointer_Pointer -- package C_xcb_button_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_button_t_Pointer, Element_Array => xcb.Pointers.xcb_button_t_Pointer_Array, Default_Terminator => null); subtype xcb_button_t_Pointer_Pointer is C_xcb_button_t_Pointer_Pointers.Pointer; -- xcb_visual_class_t_Pointer_Pointer -- package C_xcb_visual_class_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_visual_class_t_Pointer, Element_Array => xcb.Pointers.xcb_visual_class_t_Pointer_Array, Default_Terminator => null); subtype xcb_visual_class_t_Pointer_Pointer is C_xcb_visual_class_t_Pointer_Pointers.Pointer; -- xcb_event_mask_t_Pointer_Pointer -- package C_xcb_event_mask_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_event_mask_t_Pointer, Element_Array => xcb.Pointers.xcb_event_mask_t_Pointer_Array, Default_Terminator => null); subtype xcb_event_mask_t_Pointer_Pointer is C_xcb_event_mask_t_Pointer_Pointers.Pointer; -- xcb_backing_store_t_Pointer_Pointer -- package C_xcb_backing_store_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_backing_store_t_Pointer, Element_Array => xcb.Pointers.xcb_backing_store_t_Pointer_Array, Default_Terminator => null); subtype xcb_backing_store_t_Pointer_Pointer is C_xcb_backing_store_t_Pointer_Pointers.Pointer; -- xcb_image_order_t_Pointer_Pointer -- package C_xcb_image_order_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_image_order_t_Pointer, Element_Array => xcb.Pointers.xcb_image_order_t_Pointer_Array, Default_Terminator => null); subtype xcb_image_order_t_Pointer_Pointer is C_xcb_image_order_t_Pointer_Pointers.Pointer; -- xcb_mod_mask_t_Pointer_Pointer -- package C_xcb_mod_mask_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_mod_mask_t_Pointer, Element_Array => xcb.Pointers.xcb_mod_mask_t_Pointer_Array, Default_Terminator => null); subtype xcb_mod_mask_t_Pointer_Pointer is C_xcb_mod_mask_t_Pointer_Pointers.Pointer; -- xcb_key_but_mask_t_Pointer_Pointer -- package C_xcb_key_but_mask_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_key_but_mask_t_Pointer, Element_Array => xcb.Pointers.xcb_key_but_mask_t_Pointer_Array, Default_Terminator => null); subtype xcb_key_but_mask_t_Pointer_Pointer is C_xcb_key_but_mask_t_Pointer_Pointers.Pointer; -- xcb_window_enum_t_Pointer_Pointer -- package C_xcb_window_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_window_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_window_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_window_enum_t_Pointer_Pointer is C_xcb_window_enum_t_Pointer_Pointers.Pointer; -- xcb_button_mask_t_Pointer_Pointer -- package C_xcb_button_mask_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_button_mask_t_Pointer, Element_Array => xcb.Pointers.xcb_button_mask_t_Pointer_Array, Default_Terminator => null); subtype xcb_button_mask_t_Pointer_Pointer is C_xcb_button_mask_t_Pointer_Pointers.Pointer; -- xcb_motion_t_Pointer_Pointer -- package C_xcb_motion_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_motion_t_Pointer, Element_Array => xcb.Pointers.xcb_motion_t_Pointer_Array, Default_Terminator => null); subtype xcb_motion_t_Pointer_Pointer is C_xcb_motion_t_Pointer_Pointers.Pointer; -- xcb_notify_detail_t_Pointer_Pointer -- package C_xcb_notify_detail_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_notify_detail_t_Pointer, Element_Array => xcb.Pointers.xcb_notify_detail_t_Pointer_Array, Default_Terminator => null); subtype xcb_notify_detail_t_Pointer_Pointer is C_xcb_notify_detail_t_Pointer_Pointers.Pointer; -- xcb_notify_mode_t_Pointer_Pointer -- package C_xcb_notify_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_notify_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_notify_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_notify_mode_t_Pointer_Pointer is C_xcb_notify_mode_t_Pointer_Pointers.Pointer; -- xcb_visibility_t_Pointer_Pointer -- package C_xcb_visibility_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_visibility_t_Pointer, Element_Array => xcb.Pointers.xcb_visibility_t_Pointer_Array, Default_Terminator => null); subtype xcb_visibility_t_Pointer_Pointer is C_xcb_visibility_t_Pointer_Pointers.Pointer; -- xcb_place_t_Pointer_Pointer -- package C_xcb_place_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_place_t_Pointer, Element_Array => xcb.Pointers.xcb_place_t_Pointer_Array, Default_Terminator => null); subtype xcb_place_t_Pointer_Pointer is C_xcb_place_t_Pointer_Pointers.Pointer; -- xcb_property_t_Pointer_Pointer -- package C_xcb_property_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_property_t_Pointer, Element_Array => xcb.Pointers.xcb_property_t_Pointer_Array, Default_Terminator => null); subtype xcb_property_t_Pointer_Pointer is C_xcb_property_t_Pointer_Pointers.Pointer; -- xcb_time_t_Pointer_Pointer -- package C_xcb_time_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_time_t_Pointer, Element_Array => xcb.Pointers.xcb_time_t_Pointer_Array, Default_Terminator => null); subtype xcb_time_t_Pointer_Pointer is C_xcb_time_t_Pointer_Pointers.Pointer; -- xcb_atom_enum_t_Pointer_Pointer -- package C_xcb_atom_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_atom_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_atom_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_atom_enum_t_Pointer_Pointer is C_xcb_atom_enum_t_Pointer_Pointers.Pointer; -- xcb_colormap_state_t_Pointer_Pointer -- package C_xcb_colormap_state_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_colormap_state_t_Pointer, Element_Array => xcb.Pointers.xcb_colormap_state_t_Pointer_Array, Default_Terminator => null); subtype xcb_colormap_state_t_Pointer_Pointer is C_xcb_colormap_state_t_Pointer_Pointers.Pointer; -- xcb_colormap_enum_t_Pointer_Pointer -- package C_xcb_colormap_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_colormap_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_colormap_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_colormap_enum_t_Pointer_Pointer is C_xcb_colormap_enum_t_Pointer_Pointers.Pointer; -- xcb_mapping_t_Pointer_Pointer -- package C_xcb_mapping_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_mapping_t_Pointer, Element_Array => xcb.Pointers.xcb_mapping_t_Pointer_Array, Default_Terminator => null); subtype xcb_mapping_t_Pointer_Pointer is C_xcb_mapping_t_Pointer_Pointers.Pointer; -- xcb_window_class_t_Pointer_Pointer -- package C_xcb_window_class_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_window_class_t_Pointer, Element_Array => xcb.Pointers.xcb_window_class_t_Pointer_Array, Default_Terminator => null); subtype xcb_window_class_t_Pointer_Pointer is C_xcb_window_class_t_Pointer_Pointers.Pointer; -- xcb_cw_t_Pointer_Pointer -- package C_xcb_cw_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_cw_t_Pointer, Element_Array => xcb.Pointers.xcb_cw_t_Pointer_Array, Default_Terminator => null); subtype xcb_cw_t_Pointer_Pointer is C_xcb_cw_t_Pointer_Pointers.Pointer; -- xcb_back_pixmap_t_Pointer_Pointer -- package C_xcb_back_pixmap_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_back_pixmap_t_Pointer, Element_Array => xcb.Pointers.xcb_back_pixmap_t_Pointer_Array, Default_Terminator => null); subtype xcb_back_pixmap_t_Pointer_Pointer is C_xcb_back_pixmap_t_Pointer_Pointers.Pointer; -- xcb_gravity_t_Pointer_Pointer -- package C_xcb_gravity_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_gravity_t_Pointer, Element_Array => xcb.Pointers.xcb_gravity_t_Pointer_Array, Default_Terminator => null); subtype xcb_gravity_t_Pointer_Pointer is C_xcb_gravity_t_Pointer_Pointers.Pointer; -- xcb_map_state_t_Pointer_Pointer -- package C_xcb_map_state_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_map_state_t_Pointer, Element_Array => xcb.Pointers.xcb_map_state_t_Pointer_Array, Default_Terminator => null); subtype xcb_map_state_t_Pointer_Pointer is C_xcb_map_state_t_Pointer_Pointers.Pointer; -- xcb_set_mode_t_Pointer_Pointer -- package C_xcb_set_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_set_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_set_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_set_mode_t_Pointer_Pointer is C_xcb_set_mode_t_Pointer_Pointers.Pointer; -- xcb_config_window_t_Pointer_Pointer -- package C_xcb_config_window_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_config_window_t_Pointer, Element_Array => xcb.Pointers.xcb_config_window_t_Pointer_Array, Default_Terminator => null); subtype xcb_config_window_t_Pointer_Pointer is C_xcb_config_window_t_Pointer_Pointers.Pointer; -- xcb_stack_mode_t_Pointer_Pointer -- package C_xcb_stack_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_stack_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_stack_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_stack_mode_t_Pointer_Pointer is C_xcb_stack_mode_t_Pointer_Pointers.Pointer; -- xcb_circulate_t_Pointer_Pointer -- package C_xcb_circulate_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_circulate_t_Pointer, Element_Array => xcb.Pointers.xcb_circulate_t_Pointer_Array, Default_Terminator => null); subtype xcb_circulate_t_Pointer_Pointer is C_xcb_circulate_t_Pointer_Pointers.Pointer; -- xcb_prop_mode_t_Pointer_Pointer -- package C_xcb_prop_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_prop_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_prop_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_prop_mode_t_Pointer_Pointer is C_xcb_prop_mode_t_Pointer_Pointers.Pointer; -- xcb_get_property_type_t_Pointer_Pointer -- package C_xcb_get_property_type_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_get_property_type_t_Pointer, Element_Array => xcb.Pointers.xcb_get_property_type_t_Pointer_Array, Default_Terminator => null); subtype xcb_get_property_type_t_Pointer_Pointer is C_xcb_get_property_type_t_Pointer_Pointers.Pointer; -- xcb_send_event_dest_t_Pointer_Pointer -- package C_xcb_send_event_dest_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_send_event_dest_t_Pointer, Element_Array => xcb.Pointers.xcb_send_event_dest_t_Pointer_Array, Default_Terminator => null); subtype xcb_send_event_dest_t_Pointer_Pointer is C_xcb_send_event_dest_t_Pointer_Pointers.Pointer; -- xcb_grab_mode_t_Pointer_Pointer -- package C_xcb_grab_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_grab_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_grab_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_grab_mode_t_Pointer_Pointer is C_xcb_grab_mode_t_Pointer_Pointers.Pointer; -- xcb_grab_status_t_Pointer_Pointer -- package C_xcb_grab_status_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_grab_status_t_Pointer, Element_Array => xcb.Pointers.xcb_grab_status_t_Pointer_Array, Default_Terminator => null); subtype xcb_grab_status_t_Pointer_Pointer is C_xcb_grab_status_t_Pointer_Pointers.Pointer; -- xcb_cursor_enum_t_Pointer_Pointer -- package C_xcb_cursor_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_cursor_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_cursor_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_cursor_enum_t_Pointer_Pointer is C_xcb_cursor_enum_t_Pointer_Pointers.Pointer; -- xcb_button_index_t_Pointer_Pointer -- package C_xcb_button_index_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_button_index_t_Pointer, Element_Array => xcb.Pointers.xcb_button_index_t_Pointer_Array, Default_Terminator => null); subtype xcb_button_index_t_Pointer_Pointer is C_xcb_button_index_t_Pointer_Pointers.Pointer; -- xcb_grab_t_Pointer_Pointer -- package C_xcb_grab_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_grab_t_Pointer, Element_Array => xcb.Pointers.xcb_grab_t_Pointer_Array, Default_Terminator => null); subtype xcb_grab_t_Pointer_Pointer is C_xcb_grab_t_Pointer_Pointers.Pointer; -- xcb_allow_t_Pointer_Pointer -- package C_xcb_allow_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_allow_t_Pointer, Element_Array => xcb.Pointers.xcb_allow_t_Pointer_Array, Default_Terminator => null); subtype xcb_allow_t_Pointer_Pointer is C_xcb_allow_t_Pointer_Pointers.Pointer; -- xcb_input_focus_t_Pointer_Pointer -- package C_xcb_input_focus_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_input_focus_t_Pointer, Element_Array => xcb.Pointers.xcb_input_focus_t_Pointer_Array, Default_Terminator => null); subtype xcb_input_focus_t_Pointer_Pointer is C_xcb_input_focus_t_Pointer_Pointers.Pointer; -- xcb_font_draw_t_Pointer_Pointer -- package C_xcb_font_draw_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_font_draw_t_Pointer, Element_Array => xcb.Pointers.xcb_font_draw_t_Pointer_Array, Default_Terminator => null); subtype xcb_font_draw_t_Pointer_Pointer is C_xcb_font_draw_t_Pointer_Pointers.Pointer; -- xcb_gc_t_Pointer_Pointer -- package C_xcb_gc_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_gc_t_Pointer, Element_Array => xcb.Pointers.xcb_gc_t_Pointer_Array, Default_Terminator => null); subtype xcb_gc_t_Pointer_Pointer is C_xcb_gc_t_Pointer_Pointers.Pointer; -- xcb_gx_t_Pointer_Pointer -- package C_xcb_gx_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_gx_t_Pointer, Element_Array => xcb.Pointers.xcb_gx_t_Pointer_Array, Default_Terminator => null); subtype xcb_gx_t_Pointer_Pointer is C_xcb_gx_t_Pointer_Pointers.Pointer; -- xcb_line_style_t_Pointer_Pointer -- package C_xcb_line_style_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_line_style_t_Pointer, Element_Array => xcb.Pointers.xcb_line_style_t_Pointer_Array, Default_Terminator => null); subtype xcb_line_style_t_Pointer_Pointer is C_xcb_line_style_t_Pointer_Pointers.Pointer; -- xcb_cap_style_t_Pointer_Pointer -- package C_xcb_cap_style_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_cap_style_t_Pointer, Element_Array => xcb.Pointers.xcb_cap_style_t_Pointer_Array, Default_Terminator => null); subtype xcb_cap_style_t_Pointer_Pointer is C_xcb_cap_style_t_Pointer_Pointers.Pointer; -- xcb_join_style_t_Pointer_Pointer -- package C_xcb_join_style_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_join_style_t_Pointer, Element_Array => xcb.Pointers.xcb_join_style_t_Pointer_Array, Default_Terminator => null); subtype xcb_join_style_t_Pointer_Pointer is C_xcb_join_style_t_Pointer_Pointers.Pointer; -- xcb_fill_style_t_Pointer_Pointer -- package C_xcb_fill_style_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_fill_style_t_Pointer, Element_Array => xcb.Pointers.xcb_fill_style_t_Pointer_Array, Default_Terminator => null); subtype xcb_fill_style_t_Pointer_Pointer is C_xcb_fill_style_t_Pointer_Pointers.Pointer; -- xcb_fill_rule_t_Pointer_Pointer -- package C_xcb_fill_rule_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_fill_rule_t_Pointer, Element_Array => xcb.Pointers.xcb_fill_rule_t_Pointer_Array, Default_Terminator => null); subtype xcb_fill_rule_t_Pointer_Pointer is C_xcb_fill_rule_t_Pointer_Pointers.Pointer; -- xcb_subwindow_mode_t_Pointer_Pointer -- package C_xcb_subwindow_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_subwindow_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_subwindow_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_subwindow_mode_t_Pointer_Pointer is C_xcb_subwindow_mode_t_Pointer_Pointers.Pointer; -- xcb_arc_mode_t_Pointer_Pointer -- package C_xcb_arc_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_arc_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_arc_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_arc_mode_t_Pointer_Pointer is C_xcb_arc_mode_t_Pointer_Pointers.Pointer; -- xcb_clip_ordering_t_Pointer_Pointer -- package C_xcb_clip_ordering_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_clip_ordering_t_Pointer, Element_Array => xcb.Pointers.xcb_clip_ordering_t_Pointer_Array, Default_Terminator => null); subtype xcb_clip_ordering_t_Pointer_Pointer is C_xcb_clip_ordering_t_Pointer_Pointers.Pointer; -- xcb_coord_mode_t_Pointer_Pointer -- package C_xcb_coord_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_coord_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_coord_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_coord_mode_t_Pointer_Pointer is C_xcb_coord_mode_t_Pointer_Pointers.Pointer; -- xcb_poly_shape_t_Pointer_Pointer -- package C_xcb_poly_shape_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_poly_shape_t_Pointer, Element_Array => xcb.Pointers.xcb_poly_shape_t_Pointer_Array, Default_Terminator => null); subtype xcb_poly_shape_t_Pointer_Pointer is C_xcb_poly_shape_t_Pointer_Pointers.Pointer; -- xcb_image_format_t_Pointer_Pointer -- package C_xcb_image_format_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_image_format_t_Pointer, Element_Array => xcb.Pointers.xcb_image_format_t_Pointer_Array, Default_Terminator => null); subtype xcb_image_format_t_Pointer_Pointer is C_xcb_image_format_t_Pointer_Pointers.Pointer; -- xcb_colormap_alloc_t_Pointer_Pointer -- package C_xcb_colormap_alloc_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_colormap_alloc_t_Pointer, Element_Array => xcb.Pointers.xcb_colormap_alloc_t_Pointer_Array, Default_Terminator => null); subtype xcb_colormap_alloc_t_Pointer_Pointer is C_xcb_colormap_alloc_t_Pointer_Pointers.Pointer; -- xcb_color_flag_t_Pointer_Pointer -- package C_xcb_color_flag_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_color_flag_t_Pointer, Element_Array => xcb.Pointers.xcb_color_flag_t_Pointer_Array, Default_Terminator => null); subtype xcb_color_flag_t_Pointer_Pointer is C_xcb_color_flag_t_Pointer_Pointers.Pointer; -- xcb_pixmap_enum_t_Pointer_Pointer -- package C_xcb_pixmap_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_pixmap_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_pixmap_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_pixmap_enum_t_Pointer_Pointer is C_xcb_pixmap_enum_t_Pointer_Pointers.Pointer; -- xcb_font_enum_t_Pointer_Pointer -- package C_xcb_font_enum_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_font_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_font_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_font_enum_t_Pointer_Pointer is C_xcb_font_enum_t_Pointer_Pointers.Pointer; -- xcb_query_shape_of_t_Pointer_Pointer -- package C_xcb_query_shape_of_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_query_shape_of_t_Pointer, Element_Array => xcb.Pointers.xcb_query_shape_of_t_Pointer_Array, Default_Terminator => null); subtype xcb_query_shape_of_t_Pointer_Pointer is C_xcb_query_shape_of_t_Pointer_Pointers.Pointer; -- xcb_kb_t_Pointer_Pointer -- package C_xcb_kb_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_kb_t_Pointer, Element_Array => xcb.Pointers.xcb_kb_t_Pointer_Array, Default_Terminator => null); subtype xcb_kb_t_Pointer_Pointer is C_xcb_kb_t_Pointer_Pointers.Pointer; -- xcb_led_mode_t_Pointer_Pointer -- package C_xcb_led_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_led_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_led_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_led_mode_t_Pointer_Pointer is C_xcb_led_mode_t_Pointer_Pointers.Pointer; -- xcb_auto_repeat_mode_t_Pointer_Pointer -- package C_xcb_auto_repeat_mode_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_auto_repeat_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_auto_repeat_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_auto_repeat_mode_t_Pointer_Pointer is C_xcb_auto_repeat_mode_t_Pointer_Pointers.Pointer; -- xcb_blanking_t_Pointer_Pointer -- package C_xcb_blanking_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_blanking_t_Pointer, Element_Array => xcb.Pointers.xcb_blanking_t_Pointer_Array, Default_Terminator => null); subtype xcb_blanking_t_Pointer_Pointer is C_xcb_blanking_t_Pointer_Pointers.Pointer; -- xcb_exposures_t_Pointer_Pointer -- package C_xcb_exposures_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_exposures_t_Pointer, Element_Array => xcb.Pointers.xcb_exposures_t_Pointer_Array, Default_Terminator => null); subtype xcb_exposures_t_Pointer_Pointer is C_xcb_exposures_t_Pointer_Pointers.Pointer; -- xcb_host_mode_t_Pointer_Pointer -- package C_xcb_host_mode_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_host_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_host_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_host_mode_t_Pointer_Pointer is C_xcb_host_mode_t_Pointer_Pointers.Pointer; -- xcb_family_t_Pointer_Pointer -- package C_xcb_family_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_family_t_Pointer, Element_Array => xcb.Pointers.xcb_family_t_Pointer_Array, Default_Terminator => null); subtype xcb_family_t_Pointer_Pointer is C_xcb_family_t_Pointer_Pointers.Pointer; -- xcb_access_control_t_Pointer_Pointer -- package C_xcb_access_control_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_access_control_t_Pointer, Element_Array => xcb.Pointers.xcb_access_control_t_Pointer_Array, Default_Terminator => null); subtype xcb_access_control_t_Pointer_Pointer is C_xcb_access_control_t_Pointer_Pointers.Pointer; -- xcb_close_down_t_Pointer_Pointer -- package C_xcb_close_down_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_close_down_t_Pointer, Element_Array => xcb.Pointers.xcb_close_down_t_Pointer_Array, Default_Terminator => null); subtype xcb_close_down_t_Pointer_Pointer is C_xcb_close_down_t_Pointer_Pointers.Pointer; -- xcb_kill_t_Pointer_Pointer -- package C_xcb_kill_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_kill_t_Pointer, Element_Array => xcb.Pointers.xcb_kill_t_Pointer_Array, Default_Terminator => null); subtype xcb_kill_t_Pointer_Pointer is C_xcb_kill_t_Pointer_Pointers.Pointer; -- xcb_screen_saver_t_Pointer_Pointer -- package C_xcb_screen_saver_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_screen_saver_t_Pointer, Element_Array => xcb.Pointers.xcb_screen_saver_t_Pointer_Array, Default_Terminator => null); subtype xcb_screen_saver_t_Pointer_Pointer is C_xcb_screen_saver_t_Pointer_Pointers.Pointer; -- xcb_mapping_status_t_Pointer_Pointer -- package C_xcb_mapping_status_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_mapping_status_t_Pointer, Element_Array => xcb.Pointers.xcb_mapping_status_t_Pointer_Array, Default_Terminator => null); subtype xcb_mapping_status_t_Pointer_Pointer is C_xcb_mapping_status_t_Pointer_Pointers.Pointer; -- xcb_map_index_t_Pointer_Pointer -- package C_xcb_map_index_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_map_index_t_Pointer, Element_Array => xcb.Pointers.xcb_map_index_t_Pointer_Array, Default_Terminator => null); subtype xcb_map_index_t_Pointer_Pointer is C_xcb_map_index_t_Pointer_Pointers.Pointer; -- xcb_render_pict_type_t_Pointer_Pointer -- package C_xcb_render_pict_type_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_pict_type_t_Pointer, Element_Array => xcb.Pointers.xcb_render_pict_type_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_pict_type_t_Pointer_Pointer is C_xcb_render_pict_type_t_Pointer_Pointers.Pointer; -- xcb_render_picture_enum_t_Pointer_Pointer -- package C_xcb_render_picture_enum_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_picture_enum_t_Pointer, Element_Array => xcb.Pointers.xcb_render_picture_enum_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_picture_enum_t_Pointer_Pointer is C_xcb_render_picture_enum_t_Pointer_Pointers.Pointer; -- xcb_render_pict_op_t_Pointer_Pointer -- package C_xcb_render_pict_op_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_pict_op_t_Pointer, Element_Array => xcb.Pointers.xcb_render_pict_op_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_pict_op_t_Pointer_Pointer is C_xcb_render_pict_op_t_Pointer_Pointers.Pointer; -- xcb_render_poly_edge_t_Pointer_Pointer -- package C_xcb_render_poly_edge_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_poly_edge_t_Pointer, Element_Array => xcb.Pointers.xcb_render_poly_edge_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_poly_edge_t_Pointer_Pointer is C_xcb_render_poly_edge_t_Pointer_Pointers.Pointer; -- xcb_render_poly_mode_t_Pointer_Pointer -- package C_xcb_render_poly_mode_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_poly_mode_t_Pointer, Element_Array => xcb.Pointers.xcb_render_poly_mode_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_poly_mode_t_Pointer_Pointer is C_xcb_render_poly_mode_t_Pointer_Pointers.Pointer; -- xcb_render_cp_t_Pointer_Pointer -- package C_xcb_render_cp_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_cp_t_Pointer, Element_Array => xcb.Pointers.xcb_render_cp_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_cp_t_Pointer_Pointer is C_xcb_render_cp_t_Pointer_Pointers.Pointer; -- xcb_render_sub_pixel_t_Pointer_Pointer -- package C_xcb_render_sub_pixel_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_sub_pixel_t_Pointer, Element_Array => xcb.Pointers.xcb_render_sub_pixel_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_sub_pixel_t_Pointer_Pointer is C_xcb_render_sub_pixel_t_Pointer_Pointers.Pointer; -- xcb_render_repeat_t_Pointer_Pointer -- package C_xcb_render_repeat_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_repeat_t_Pointer, Element_Array => xcb.Pointers.xcb_render_repeat_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_repeat_t_Pointer_Pointer is C_xcb_render_repeat_t_Pointer_Pointers.Pointer; -- xcb_render_glyph_t_Pointer_Pointer -- package C_xcb_render_glyph_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_glyph_t_Pointer, Element_Array => xcb.Pointers.xcb_render_glyph_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_glyph_t_Pointer_Pointer is C_xcb_render_glyph_t_Pointer_Pointers.Pointer; -- xcb_render_glyphset_t_Pointer_Pointer -- package C_xcb_render_glyphset_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_glyphset_t_Pointer, Element_Array => xcb.Pointers.xcb_render_glyphset_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_glyphset_t_Pointer_Pointer is C_xcb_render_glyphset_t_Pointer_Pointers.Pointer; -- xcb_render_picture_t_Pointer_Pointer -- package C_xcb_render_picture_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_picture_t_Pointer, Element_Array => xcb.Pointers.xcb_render_picture_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_picture_t_Pointer_Pointer is C_xcb_render_picture_t_Pointer_Pointers.Pointer; -- xcb_render_pictformat_t_Pointer_Pointer -- package C_xcb_render_pictformat_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_pictformat_t_Pointer, Element_Array => xcb.Pointers.xcb_render_pictformat_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_pictformat_t_Pointer_Pointer is C_xcb_render_pictformat_t_Pointer_Pointers.Pointer; -- xcb_render_fixed_t_Pointer_Pointer -- package C_xcb_render_fixed_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_fixed_t_Pointer, Element_Array => xcb.Pointers.xcb_render_fixed_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_fixed_t_Pointer_Pointer is C_xcb_render_fixed_t_Pointer_Pointers.Pointer; -- iovec_Pointer_Pointer -- package C_iovec_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.iovec_Pointer, Element_Array => xcb.Pointers.iovec_Pointer_Array, Default_Terminator => null); subtype iovec_Pointer_Pointer is C_iovec_Pointer_Pointers.Pointer; -- xcb_send_request_flags_t_Pointer_Pointer -- package C_xcb_send_request_flags_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_send_request_flags_t_Pointer, Element_Array => xcb.Pointers.xcb_send_request_flags_t_Pointer_Array, Default_Terminator => null); subtype xcb_send_request_flags_t_Pointer_Pointer is C_xcb_send_request_flags_t_Pointer_Pointers.Pointer; -- xcb_pict_format_t_Pointer_Pointer -- package C_xcb_pict_format_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_pict_format_t_Pointer, Element_Array => xcb.Pointers.xcb_pict_format_t_Pointer_Array, Default_Terminator => null); subtype xcb_pict_format_t_Pointer_Pointer is C_xcb_pict_format_t_Pointer_Pointers.Pointer; -- xcb_pict_standard_t_Pointer_Pointer -- package C_xcb_pict_standard_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_pict_standard_t_Pointer, Element_Array => xcb.Pointers.xcb_pict_standard_t_Pointer_Array, Default_Terminator => null); subtype xcb_pict_standard_t_Pointer_Pointer is C_xcb_pict_standard_t_Pointer_Pointers.Pointer; -- xcb_render_util_composite_text_stream_t_Pointer_Pointer -- package C_xcb_render_util_composite_text_stream_t_Pointer_Pointers is new Interfaces .C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_render_util_composite_text_stream_t_Pointer, Element_Array => xcb.Pointers.xcb_render_util_composite_text_stream_t_Pointer_Array, Default_Terminator => null); subtype xcb_render_util_composite_text_stream_t_Pointer_Pointer is C_xcb_render_util_composite_text_stream_t_Pointer_Pointers.Pointer; -- xcb_glx_pixmap_t_Pointer_Pointer -- package C_xcb_glx_pixmap_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_pixmap_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_pixmap_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_pixmap_t_Pointer_Pointer is C_xcb_glx_pixmap_t_Pointer_Pointers.Pointer; -- xcb_glx_context_t_Pointer_Pointer -- package C_xcb_glx_context_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_context_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_context_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_context_t_Pointer_Pointer is C_xcb_glx_context_t_Pointer_Pointers.Pointer; -- xcb_glx_pbuffer_t_Pointer_Pointer -- package C_xcb_glx_pbuffer_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_pbuffer_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_pbuffer_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_pbuffer_t_Pointer_Pointer is C_xcb_glx_pbuffer_t_Pointer_Pointers.Pointer; -- xcb_glx_window_t_Pointer_Pointer -- package C_xcb_glx_window_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_window_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_window_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_window_t_Pointer_Pointer is C_xcb_glx_window_t_Pointer_Pointers.Pointer; -- xcb_glx_fbconfig_t_Pointer_Pointer -- package C_xcb_glx_fbconfig_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_fbconfig_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_fbconfig_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_fbconfig_t_Pointer_Pointer is C_xcb_glx_fbconfig_t_Pointer_Pointers.Pointer; -- xcb_glx_drawable_t_Pointer_Pointer -- package C_xcb_glx_drawable_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_drawable_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_drawable_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_drawable_t_Pointer_Pointer is C_xcb_glx_drawable_t_Pointer_Pointers.Pointer; -- xcb_glx_float32_t_Pointer_Pointer -- package C_xcb_glx_float32_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_float32_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_float32_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_float32_t_Pointer_Pointer is C_xcb_glx_float32_t_Pointer_Pointers.Pointer; -- xcb_glx_float64_t_Pointer_Pointer -- package C_xcb_glx_float64_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_float64_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_float64_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_float64_t_Pointer_Pointer is C_xcb_glx_float64_t_Pointer_Pointers.Pointer; -- xcb_glx_bool32_t_Pointer_Pointer -- package C_xcb_glx_bool32_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_bool32_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_bool32_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_bool32_t_Pointer_Pointer is C_xcb_glx_bool32_t_Pointer_Pointers.Pointer; -- xcb_glx_context_tag_t_Pointer_Pointer -- package C_xcb_glx_context_tag_t_Pointer_Pointers is new Interfaces.C .Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_context_tag_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_context_tag_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_context_tag_t_Pointer_Pointer is C_xcb_glx_context_tag_t_Pointer_Pointers.Pointer; -- xcb_glx_pbcet_t_Pointer_Pointer -- package C_xcb_glx_pbcet_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_pbcet_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_pbcet_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_pbcet_t_Pointer_Pointer is C_xcb_glx_pbcet_t_Pointer_Pointers.Pointer; -- xcb_glx_pbcdt_t_Pointer_Pointer -- package C_xcb_glx_pbcdt_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_pbcdt_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_pbcdt_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_pbcdt_t_Pointer_Pointer is C_xcb_glx_pbcdt_t_Pointer_Pointers.Pointer; -- xcb_glx_gc_t_Pointer_Pointer -- package C_xcb_glx_gc_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_gc_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_gc_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_gc_t_Pointer_Pointer is C_xcb_glx_gc_t_Pointer_Pointers.Pointer; -- xcb_glx_rm_t_Pointer_Pointer -- package C_xcb_glx_rm_t_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.xcb_glx_rm_t_Pointer, Element_Array => xcb.Pointers.xcb_glx_rm_t_Pointer_Array, Default_Terminator => null); subtype xcb_glx_rm_t_Pointer_Pointer is C_xcb_glx_rm_t_Pointer_Pointers.Pointer; -- Display_Pointer_Pointer -- package C_Display_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.Display_Pointer, Element_Array => xcb.Pointers.Display_Pointer_Array, Default_Terminator => null); subtype Display_Pointer_Pointer is C_Display_Pointer_Pointers.Pointer; -- XEventQueueOwner_Pointer_Pointer -- package C_XEventQueueOwner_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.Pointers.XEventQueueOwner_Pointer, Element_Array => xcb.Pointers.XEventQueueOwner_Pointer_Array, Default_Terminator => null); subtype XEventQueueOwner_Pointer_Pointer is C_XEventQueueOwner_Pointer_Pointers.Pointer; end xcb.pointer_Pointers;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- A D A . E X C E P T I O N S . E X C E P T I O N _ P R O P A G A T I O N -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, 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, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the version using the GCC EH mechanism with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Storage_Elements; use System.Storage_Elements; separate (Ada.Exceptions) package body Exception_Propagation is ------------------------------------------------ -- Entities to interface with the GCC runtime -- ------------------------------------------------ -- These come from "C++ ABI for Itanium: Exception handling", which is -- the reference for GCC. They are used only when we are relying on -- back-end tables for exception propagation, which in turn is currenly -- only the case for Zero_Cost_Exceptions in GNAT5. -- Return codes from the GCC runtime functions used to propagate -- an exception. type Unwind_Reason_Code is (URC_NO_REASON, URC_FOREIGN_EXCEPTION_CAUGHT, URC_PHASE2_ERROR, URC_PHASE1_ERROR, URC_NORMAL_STOP, URC_END_OF_STACK, URC_HANDLER_FOUND, URC_INSTALL_CONTEXT, URC_CONTINUE_UNWIND); pragma Unreferenced (URC_FOREIGN_EXCEPTION_CAUGHT, URC_PHASE2_ERROR, URC_PHASE1_ERROR, URC_NORMAL_STOP, URC_END_OF_STACK, URC_HANDLER_FOUND, URC_INSTALL_CONTEXT, URC_CONTINUE_UNWIND); pragma Convention (C, Unwind_Reason_Code); -- Phase identifiers type Unwind_Action is (UA_SEARCH_PHASE, UA_CLEANUP_PHASE, UA_HANDLER_FRAME, UA_FORCE_UNWIND); for Unwind_Action use (UA_SEARCH_PHASE => 1, UA_CLEANUP_PHASE => 2, UA_HANDLER_FRAME => 4, UA_FORCE_UNWIND => 8); pragma Convention (C, Unwind_Action); -- Mandatory common header for any exception object handled by the -- GCC unwinding runtime. type Exception_Class is mod 2 ** 64; GNAT_Exception_Class : constant Exception_Class := 16#474e552d41646100#; -- "GNU-Ada\0" type Unwind_Word is mod 2 ** System.Word_Size; for Unwind_Word'Size use System.Word_Size; -- Map the corresponding C type used in Unwind_Exception below type Unwind_Exception is record Class : Exception_Class := GNAT_Exception_Class; Cleanup : System.Address := System.Null_Address; Private1 : Unwind_Word; Private2 : Unwind_Word; end record; -- Map the GCC struct used for exception handling for Unwind_Exception'Alignment use Standard'Maximum_Alignment; -- The C++ ABI mandates the common exception header to be at least -- doubleword aligned, and the libGCC implementation actually makes it -- maximally aligned (see unwind.h). See additional comments on the -- alignment below. -------------------------------------------------------------- -- GNAT Specific Entities To Deal With The GCC EH Circuitry -- -------------------------------------------------------------- -- A GNAT exception object to be dealt with by the personality routine -- called by the GCC unwinding runtime. type GNAT_GCC_Exception is record Header : Unwind_Exception; -- ABI Exception header first Id : Exception_Id; -- GNAT Exception identifier. This is filled by Propagate_Exception -- and then used by the personality routine to determine if the context -- it examines contains a handler for the exception beeing propagated. N_Cleanups_To_Trigger : Integer; -- Number of cleanup only frames encountered in SEARCH phase. This is -- initialized to 0 by Propagate_Exception and maintained by the -- personality routine to control a forced unwinding phase triggering -- all the cleanups before calling Unhandled_Exception_Terminate when -- an exception is not handled. Next_Exception : EOA; -- Used to create a linked list of exception occurrences end record; pragma Convention (C, GNAT_GCC_Exception); -- There is a subtle issue with the common header alignment, since the C -- version is aligned on BIGGEST_ALIGNMENT, the Ada version is aligned on -- Standard'Maximum_Alignment, and those two values don't quite represent -- the same concepts and so may be decoupled someday. One typical reason -- is that BIGGEST_ALIGNMENT may be larger than what the underlying system -- allocator guarantees, and there are extra costs involved in allocating -- objects aligned to such factors. -- To deal with the potential alignment differences between the C and Ada -- representations, the Ada part of the whole structure is only accessed -- by the personality routine through the accessors declared below. Ada -- specific fields are thus always accessed through consistent layout, and -- we expect the actual alignment to always be large enough to avoid traps -- from the C accesses to the common header. Besides, accessors aleviate -- the need for a C struct whole conterpart, both painful and errorprone -- to maintain anyway. type GNAT_GCC_Exception_Access is access all GNAT_GCC_Exception; function To_GNAT_GCC_Exception is new Unchecked_Conversion (System.Address, GNAT_GCC_Exception_Access); procedure Free is new Unchecked_Deallocation (GNAT_GCC_Exception, GNAT_GCC_Exception_Access); procedure Free is new Unchecked_Deallocation (Exception_Occurrence, EOA); function CleanupUnwind_Handler (UW_Version : Integer; UW_Phases : Unwind_Action; UW_Eclass : Exception_Class; UW_Exception : access GNAT_GCC_Exception; UW_Context : System.Address; UW_Argument : System.Address) return Unwind_Reason_Code; -- Hook called at each step of the forced unwinding we perform to -- trigger cleanups found during the propagation of an unhandled -- exception. -- GCC runtime functions used. These are C non-void functions, actually, -- but we ignore the return values. See raise.c as to why we are using -- __gnat stubs for these. procedure Unwind_RaiseException (UW_Exception : access GNAT_GCC_Exception); pragma Import (C, Unwind_RaiseException, "__gnat_Unwind_RaiseException"); procedure Unwind_ForcedUnwind (UW_Exception : access GNAT_GCC_Exception; UW_Handler : System.Address; UW_Argument : System.Address); pragma Import (C, Unwind_ForcedUnwind, "__gnat_Unwind_ForcedUnwind"); ------------------------------------------------------------------ -- Occurrence Stack Management Facilities for the GCC-EH Scheme -- ------------------------------------------------------------------ function Remove (Top : EOA; Excep : GNAT_GCC_Exception_Access) return Boolean; -- Remove Excep from the stack starting at Top. -- Return True if Excep was found and removed, false otherwise. -- Hooks called when entering/leaving an exception handler for a given -- occurrence, aimed at handling the stack of active occurrences. The -- calls are generated by gigi in tree_transform/N_Exception_Handler. procedure Begin_Handler (GCC_Exception : GNAT_GCC_Exception_Access); pragma Export (C, Begin_Handler, "__gnat_begin_handler"); procedure End_Handler (GCC_Exception : GNAT_GCC_Exception_Access); pragma Export (C, End_Handler, "__gnat_end_handler"); Setup_Key : constant := 16#DEAD#; -- To handle the case of a task "transferring" an exception occurrence to -- another task, for instance via Exceptional_Complete_Rendezvous, we need -- to be able to identify occurrences which have been Setup and not yet -- Propagated. We hijack one of the common header fields for that purpose, -- setting it to a special key value during the setup process, clearing it -- at the very beginning of the propagation phase, and expecting it never -- to be reset to the special value later on. A 16-bit value is used rather -- than a 32-bit value for static compatibility with 16-bit targets such as -- AAMP (where type Unwind_Word will be 16 bits). function Is_Setup_And_Not_Propagated (E : EOA) return Boolean; procedure Set_Setup_And_Not_Propagated (E : EOA); procedure Clear_Setup_And_Not_Propagated (E : EOA); procedure Save_Occurrence_And_Private (Target : out Exception_Occurrence; Source : Exception_Occurrence); -- Copy all the components of Source to Target as well as the -- Private_Data pointer. ------------------------------------------------------------ -- Accessors to basic components of a GNAT exception data -- ------------------------------------------------------------ -- As of today, these are only used by the C implementation of the -- GCC propagation personality routine to avoid having to rely on a C -- counterpart of the whole exception_data structure, which is both -- painful and error prone. These subprograms could be moved to a -- more widely visible location if need be. function Is_Handled_By_Others (E : Exception_Data_Ptr) return Boolean; pragma Export (C, Is_Handled_By_Others, "__gnat_is_handled_by_others"); function Language_For (E : Exception_Data_Ptr) return Character; pragma Export (C, Language_For, "__gnat_language_for"); function Import_Code_For (E : Exception_Data_Ptr) return Exception_Code; pragma Export (C, Import_Code_For, "__gnat_import_code_for"); function EID_For (GNAT_Exception : GNAT_GCC_Exception_Access) return Exception_Id; pragma Export (C, EID_For, "__gnat_eid_for"); procedure Adjust_N_Cleanups_For (GNAT_Exception : GNAT_GCC_Exception_Access; Adjustment : Integer); pragma Export (C, Adjust_N_Cleanups_For, "__gnat_adjust_n_cleanups_for"); --------------------------------------------------------------------------- -- Objects to materialize "others" and "all others" in the GCC EH tables -- --------------------------------------------------------------------------- -- Currently, these only have their address taken and compared so there is -- no real point having whole exception data blocks allocated. In any case -- the types should match what gigi and the personality routine expect. -- The initial value is an arbitrary value that will not exceed the range -- of Integer on 16-bit targets (such as AAMP). Others_Value : constant Integer := 16#7FFF#; pragma Export (C, Others_Value, "__gnat_others_value"); All_Others_Value : constant Integer := 16#7FFF#; pragma Export (C, All_Others_Value, "__gnat_all_others_value"); ------------ -- Remove -- ------------ function Remove (Top : EOA; Excep : GNAT_GCC_Exception_Access) return Boolean is Prev : GNAT_GCC_Exception_Access := null; Iter : EOA := Top; GCC_Exception : GNAT_GCC_Exception_Access; begin -- Pop stack loop pragma Assert (Iter.Private_Data /= System.Null_Address); GCC_Exception := To_GNAT_GCC_Exception (Iter.Private_Data); if GCC_Exception = Excep then if Prev = null then -- Special case for the top of the stack: shift the contents -- of the next item to the top, since top is at a fixed -- location and can't be changed. Iter := GCC_Exception.Next_Exception; if Iter = null then -- Stack is now empty Top.Private_Data := System.Null_Address; else Save_Occurrence_And_Private (Top.all, Iter.all); Free (Iter); end if; else Prev.Next_Exception := GCC_Exception.Next_Exception; Free (Iter); end if; Free (GCC_Exception); return True; end if; exit when GCC_Exception.Next_Exception = null; Prev := GCC_Exception; Iter := GCC_Exception.Next_Exception; end loop; return False; end Remove; --------------------------- -- CleanupUnwind_Handler -- --------------------------- function CleanupUnwind_Handler (UW_Version : Integer; UW_Phases : Unwind_Action; UW_Eclass : Exception_Class; UW_Exception : access GNAT_GCC_Exception; UW_Context : System.Address; UW_Argument : System.Address) return Unwind_Reason_Code is pragma Unreferenced (UW_Version, UW_Phases, UW_Eclass, UW_Context, UW_Argument); begin -- Terminate as soon as we know there is nothing more to run. The -- count is maintained by the personality routine. if UW_Exception.N_Cleanups_To_Trigger = 0 then Unhandled_Exception_Terminate; end if; -- We know there is at least one cleanup further up. Return so that it -- is searched and entered, after which Unwind_Resume will be called -- and this hook will gain control (with an updated count) again. return URC_NO_REASON; end CleanupUnwind_Handler; --------------------------------- -- Is_Setup_And_Not_Propagated -- --------------------------------- function Is_Setup_And_Not_Propagated (E : EOA) return Boolean is GCC_E : constant GNAT_GCC_Exception_Access := To_GNAT_GCC_Exception (E.Private_Data); begin return GCC_E /= null and then GCC_E.Header.Private1 = Setup_Key; end Is_Setup_And_Not_Propagated; ------------------------------------ -- Clear_Setup_And_Not_Propagated -- ------------------------------------ procedure Clear_Setup_And_Not_Propagated (E : EOA) is GCC_E : constant GNAT_GCC_Exception_Access := To_GNAT_GCC_Exception (E.Private_Data); begin pragma Assert (GCC_E /= null); GCC_E.Header.Private1 := 0; end Clear_Setup_And_Not_Propagated; ---------------------------------- -- Set_Setup_And_Not_Propagated -- ---------------------------------- procedure Set_Setup_And_Not_Propagated (E : EOA) is GCC_E : constant GNAT_GCC_Exception_Access := To_GNAT_GCC_Exception (E.Private_Data); begin pragma Assert (GCC_E /= null); GCC_E.Header.Private1 := Setup_Key; end Set_Setup_And_Not_Propagated; -------------------------------- -- Save_Occurrence_And_Private -- -------------------------------- procedure Save_Occurrence_And_Private (Target : out Exception_Occurrence; Source : Exception_Occurrence) is begin Save_Occurrence_No_Private (Target, Source); Target.Private_Data := Source.Private_Data; end Save_Occurrence_And_Private; --------------------- -- Setup_Exception -- --------------------- -- In the GCC-EH implementation of the propagation scheme, this -- subprogram should be understood as: Setup the exception occurrence -- stack headed at Current for a forthcoming raise of Excep. procedure Setup_Exception (Excep : EOA; Current : EOA; Reraised : Boolean := False) is Top : constant EOA := Current; Next : EOA; GCC_Exception : GNAT_GCC_Exception_Access; begin -- The exception Excep is soon to be propagated, and the -- storage used for that will be the occurrence statically allocated -- for the current thread. This storage might currently be used for a -- still active occurrence, so we need to push it on the thread's -- occurrence stack (headed at that static occurrence) before it gets -- clobbered. -- What we do here is to trigger this push when need be, and allocate a -- Private_Data block for the forthcoming Propagation. -- Some tasking rendez-vous attempts lead to an occurrence transfer -- from the server to the client (see Exceptional_Complete_Rendezvous). -- In those cases Setup is called twice for the very same occurrence -- before it gets propagated: once from the server, because this is -- where the occurrence contents is elaborated and known, and then -- once from the client when it detects the case and actually raises -- the exception in its own context. -- The Is_Setup_And_Not_Propagated predicate tells us when we are in -- the second call to Setup for a Transferred occurrence, and there is -- nothing to be done here in this situation. This predicate cannot be -- True if we are dealing with a Reraise, and we may even be called -- with a raw uninitialized Excep occurrence in this case so we should -- not check anyway. Observe the front-end expansion for a "raise;" to -- see that happening. We get a local occurrence and a direct call to -- Save_Occurrence without the intermediate init-proc call. if not Reraised and then Is_Setup_And_Not_Propagated (Excep) then return; end if; -- Allocate what will be the Private_Data block for the exception -- to be propagated. GCC_Exception := new GNAT_GCC_Exception; -- If the Top of the occurrence stack is not currently used for an -- active exception (the stack is empty) we just need to setup the -- Private_Data pointer. -- Otherwise, we also need to shift the contents of the Top of the -- stack in a freshly allocated entry and link everything together. if Top.Private_Data /= System.Null_Address then Next := new Exception_Occurrence; Save_Occurrence_And_Private (Next.all, Top.all); GCC_Exception.Next_Exception := Next; Top.Private_Data := GCC_Exception.all'Address; end if; Top.Private_Data := GCC_Exception.all'Address; Set_Setup_And_Not_Propagated (Top); end Setup_Exception; ------------------- -- Begin_Handler -- ------------------- procedure Begin_Handler (GCC_Exception : GNAT_GCC_Exception_Access) is pragma Unreferenced (GCC_Exception); begin -- Every necessary operation related to the occurrence stack has -- already been performed by Propagate_Exception. This hook remains for -- potential future necessity in optimizing the overall scheme, as well -- a useful debugging tool. null; end Begin_Handler; ----------------- -- End_Handler -- ----------------- procedure End_Handler (GCC_Exception : GNAT_GCC_Exception_Access) is Removed : Boolean; begin Removed := Remove (Get_Current_Excep.all, GCC_Exception); pragma Assert (Removed); end End_Handler; ------------------------- -- Propagate_Exception -- ------------------------- -- Build an object suitable for the libgcc processing and call -- Unwind_RaiseException to actually throw, taking care of handling -- the two phase scheme it implements. procedure Propagate_Exception (E : Exception_Id; From_Signal_Handler : Boolean) is pragma Inspection_Point (E); pragma Unreferenced (From_Signal_Handler); Excep : constant EOA := Get_Current_Excep.all; GCC_Exception : GNAT_GCC_Exception_Access; begin pragma Assert (Excep.Private_Data /= System.Null_Address); -- Retrieve the Private_Data for this occurrence and set the useful -- flags for the personality routine, which will be called for each -- frame via Unwind_RaiseException below. GCC_Exception := To_GNAT_GCC_Exception (Excep.Private_Data); Clear_Setup_And_Not_Propagated (Excep); GCC_Exception.Id := Excep.Id; GCC_Exception.N_Cleanups_To_Trigger := 0; -- Compute the backtrace for this occurrence if the corresponding -- binder option has been set. Call_Chain takes care of the reraise -- case. -- ??? Using Call_Chain here means we are going to walk up the stack -- once only for backtracing purposes before doing it again for the -- propagation per se. -- The first inspection is much lighter, though, as it only requires -- partial unwinding of each frame. Additionally, although we could use -- the personality routine to record the addresses while propagating, -- this method has two drawbacks: -- 1) the trace is incomplete if the exception is handled since we -- don't walk past the frame with the handler, -- and -- 2) we would miss the frames for which our personality routine is not -- called, e.g. if C or C++ calls are on the way. Call_Chain (Excep); -- Perform a standard raise first. If a regular handler is found, it -- will be entered after all the intermediate cleanups have run. If -- there is no regular handler, control will get back to after the -- call, with N_Cleanups_To_Trigger set to the number of frames with -- cleanups found on the way up, and none of these already run. Unwind_RaiseException (GCC_Exception); -- If we get here we know the exception is not handled, as otherwise -- Unwind_RaiseException arranges for the handler to be entered. Take -- the necessary steps to enable the debugger to gain control while the -- stack is still intact. Notify_Unhandled_Exception; -- Now, if cleanups have been found, run a forced unwind to trigger -- them. Control should not resume there, as the unwinding hook calls -- Unhandled_Exception_Terminate as soon as the last cleanup has been -- triggered. if GCC_Exception.N_Cleanups_To_Trigger /= 0 then Unwind_ForcedUnwind (GCC_Exception, CleanupUnwind_Handler'Address, System.Null_Address); end if; -- We get here when there is no handler or cleanup to be run at all. -- The debugger has been notified before the second step above. Unhandled_Exception_Terminate; end Propagate_Exception; --------------------------- -- Adjust_N_Cleanups_For -- --------------------------- procedure Adjust_N_Cleanups_For (GNAT_Exception : GNAT_GCC_Exception_Access; Adjustment : Integer) is begin GNAT_Exception.N_Cleanups_To_Trigger := GNAT_Exception.N_Cleanups_To_Trigger + Adjustment; end Adjust_N_Cleanups_For; ------------- -- EID_For -- ------------- function EID_For (GNAT_Exception : GNAT_GCC_Exception_Access) return Exception_Id is begin return GNAT_Exception.Id; end EID_For; --------------------- -- Import_Code_For -- --------------------- function Import_Code_For (E : SSL.Exception_Data_Ptr) return Exception_Code is begin return E.all.Import_Code; end Import_Code_For; -------------------------- -- Is_Handled_By_Others -- -------------------------- function Is_Handled_By_Others (E : SSL.Exception_Data_Ptr) return Boolean is begin return not E.all.Not_Handled_By_Others; end Is_Handled_By_Others; ------------------ -- Language_For -- ------------------ function Language_For (E : SSL.Exception_Data_Ptr) return Character is begin return E.all.Lang; end Language_For; ----------- -- Notes -- ----------- -- The current model implemented for the stack of occurrences is a -- simplification of previous attempts, which all prooved to be flawed or -- would have needed significant additional circuitry to be made to work -- correctly. -- We now represent every propagation by a new entry on the stack, which -- means that an exception occurrence may appear more than once (e.g. when -- it is reraised during the course of its own handler). -- This may seem overcostly compared to the C++ model as implemented in -- the g++ v3 libstd. This is actually understandable when one considers -- the extra variations of possible run-time configurations induced by the -- freedom offered by the Save_Occurrence/Reraise_Occurrence public -- interface. -- The basic point is that arranging for an occurrence to always appear at -- most once on the stack requires a way to determine if a given occurence -- is already there, which is not as easy as it might seem. -- An attempt was made to use the Private_Data pointer for this purpose. -- It did not work because: -- 1) The Private_Data has to be saved by Save_Occurrence to be usable -- as a key in case of a later reraise, -- 2) There is no easy way to synchronize End_Handler for an occurrence -- and the data attached to potential copies, so these copies may end -- up pointing to stale data. Moreover ... -- 3) The same address may be reused for different occurrences, which -- defeats the idea of using it as a key. -- The example below illustrates: -- Saved_CE : Exception_Occurrence; -- begin -- raise Constraint_Error; -- exception -- when CE: others => -- Save_Occurrence (Saved_CE, CE); <= Saved_CE.PDA = CE.PDA -- end; -- <= Saved_CE.PDA is stale (!) -- begin -- raise Program_Error; <= Saved_CE.PDA = PE.PDA (!!) -- exception -- when others => -- Reraise_Occurrence (Saved_CE); -- end; -- Not releasing the Private_Data via End_Handler could be an option, -- but making this to work while still avoiding memory leaks is far -- from trivial. -- The current scheme has the advantage of beeing simple, and induces -- extra costs only in reraise cases which is acceptable. end Exception_Propagation;
pragma License (Unrestricted); -- implementation unit with Ada.IO_Exceptions; with Ada.IO_Modes; with Ada.Streams.Naked_Stream_IO.Standard_Files; with System.Native_IO; with System.Native_Text_IO; package Ada.Naked_Text_IO is -- the parameter Form Default_Form : constant System.Native_Text_IO.Packed_Form := ( Stream_Form => Streams.Naked_Stream_IO.Default_Form, External => IO_Modes.By_Target, New_Line => IO_Modes.By_Target); procedure Set ( Form : in out System.Native_Text_IO.Packed_Form; Keyword : String; Item : String); function Pack (Form : String) return System.Native_Text_IO.Packed_Form; procedure Unpack ( Form : System.Native_Text_IO.Packed_Form; Result : out Streams.Naked_Stream_IO.Form_String; Last : out Natural); -- non-controlled type Text_Type (<>) is limited private; type Non_Controlled_File_Type is access all Text_Type; procedure Create ( File : in out Non_Controlled_File_Type; Mode : IO_Modes.File_Mode := IO_Modes.Out_File; Name : String := ""; Form : System.Native_Text_IO.Packed_Form := Default_Form); procedure Open ( File : in out Non_Controlled_File_Type; Mode : IO_Modes.File_Mode; Name : String; Form : System.Native_Text_IO.Packed_Form := Default_Form); procedure Close ( File : aliased in out Non_Controlled_File_Type; Raise_On_Error : Boolean := True); procedure Delete (File : aliased in out Non_Controlled_File_Type); procedure Reset ( File : aliased in out Non_Controlled_File_Type; Mode : IO_Modes.File_Mode); function Mode (File : Non_Controlled_File_Type) return IO_Modes.File_Mode; function Name (File : Non_Controlled_File_Type) return String; function Form (File : Non_Controlled_File_Type) return System.Native_Text_IO.Packed_Form; function External (File : Non_Controlled_File_Type) return IO_Modes.File_External; pragma Inline (External); function Is_Open (File : Non_Controlled_File_Type) return Boolean; pragma Inline (Is_Open); procedure Flush (File : Non_Controlled_File_Type); procedure Set_Size ( File : Non_Controlled_File_Type; Line_Length, Page_Length : Natural); procedure Set_Line_Length (File : Non_Controlled_File_Type; To : Natural); procedure Set_Page_Length (File : Non_Controlled_File_Type; To : Natural); procedure Size ( File : Non_Controlled_File_Type; Line_Length, Page_Length : out Natural); function Line_Length (File : Non_Controlled_File_Type) return Natural; function Page_Length (File : Non_Controlled_File_Type) return Natural; pragma Inline (Line_Length); pragma Inline (Page_Length); procedure New_Line ( File : Non_Controlled_File_Type; Spacing : Positive := 1); procedure Skip_Line ( File : Non_Controlled_File_Type; Spacing : Positive := 1); function End_Of_Line (File : Non_Controlled_File_Type) return Boolean; procedure New_Page (File : Non_Controlled_File_Type); procedure Skip_Page (File : Non_Controlled_File_Type); function End_Of_Page (File : Non_Controlled_File_Type) return Boolean; function End_Of_File (File : Non_Controlled_File_Type) return Boolean; procedure Set_Col (File : Non_Controlled_File_Type; To : Positive); procedure Set_Line (File : Non_Controlled_File_Type; To : Positive); procedure Position ( File : Non_Controlled_File_Type; Col, Line : out Positive); function Col (File : Non_Controlled_File_Type) return Positive; function Line (File : Non_Controlled_File_Type) return Positive; function Page (File : Non_Controlled_File_Type) return Positive; pragma Inline (Col); pragma Inline (Line); pragma Inline (Page); procedure Get ( File : Non_Controlled_File_Type; Item : out Character); procedure Get ( File : Non_Controlled_File_Type; Item : out Wide_Character); procedure Get ( File : Non_Controlled_File_Type; Item : out Wide_Wide_Character); procedure Put ( File : Non_Controlled_File_Type; Item : Character); procedure Put ( File : Non_Controlled_File_Type; Item : Wide_Character); procedure Put ( File : Non_Controlled_File_Type; Item : Wide_Wide_Character); procedure Look_Ahead ( File : Non_Controlled_File_Type; Item : out Character; End_Of_Line : out Boolean); procedure Look_Ahead ( File : Non_Controlled_File_Type; Item : out Wide_Character; End_Of_Line : out Boolean); procedure Look_Ahead ( File : Non_Controlled_File_Type; Item : out Wide_Wide_Character; End_Of_Line : out Boolean); procedure Skip_Ahead (File : Non_Controlled_File_Type); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Character); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Wide_Character); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Wide_Wide_Character); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Character; Available : out Boolean); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Wide_Character; Available : out Boolean); procedure Get_Immediate ( File : Non_Controlled_File_Type; Item : out Wide_Wide_Character; Available : out Boolean); -- handle of stream for non-controlled procedure Open ( File : in out Non_Controlled_File_Type; Mode : IO_Modes.File_Mode; Stream : not null access Streams.Root_Stream_Type'Class; Name : String := ""; Form : System.Native_Text_IO.Packed_Form := Default_Form); function Stream (File : not null Non_Controlled_File_Type) return not null access Streams.Root_Stream_Type'Class; function Stream_IO (File : Non_Controlled_File_Type) return not null access Streams.Naked_Stream_IO.Non_Controlled_File_Type; pragma Inline (Stream_IO); function Terminal_Handle (File : Non_Controlled_File_Type) return System.Native_IO.Handle_Type; -- standard I/O Standard_Input : constant Non_Controlled_File_Type; Standard_Output : constant Non_Controlled_File_Type; Standard_Error : constant Non_Controlled_File_Type; -- exceptions Status_Error : exception renames IO_Exceptions.Status_Error; Mode_Error : exception renames IO_Exceptions.Mode_Error; Use_Error : exception renames IO_Exceptions.Use_Error; Device_Error : exception renames IO_Exceptions.Device_Error; End_Error : exception renames IO_Exceptions.End_Error; Data_Error : exception renames IO_Exceptions.Data_Error; Layout_Error : exception renames IO_Exceptions.Layout_Error; private type Virtual_Mark_Type is (None, EOP, EOP_EOF, EOF); pragma Discard_Names (Virtual_Mark_Type); type Text_Type is record -- "limited" prevents No_Elaboration_Code Stream : System.Address := -- access Streams.Root_Stream_Type'Class System.Null_Address; File : aliased Streams.Naked_Stream_IO.Non_Controlled_File_Type; Name : System.Native_IO.Name_Pointer; -- used when File is not assigned Line : Natural := 1; Page : Natural := 1; Col : Natural := 1; Line_Length : Natural := 0; Page_Length : Natural := 0; Last : Natural := 0; Ahead_Last : Natural := 0; -- one-character Length, only In_File mode Ahead_Col : Natural := 0; -- one-character Col Looked_Ahead_Last : Natural := 0; Looked_Ahead_Second : String (1 .. 3); -- second of surrogate pair Buffer : System.Native_Text_IO.Buffer_Type; End_Of_File : Boolean := False; Virtual_Mark : Virtual_Mark_Type := None; Mode : IO_Modes.File_Mode; External : IO_Modes.File_External; New_Line : IO_Modes.File_New_Line; end record; pragma Suppress_Initialization (Text_Type); Standard_Input_Text : aliased Text_Type := ( Stream => System.Null_Address, -- be overwritten File => Streams.Naked_Stream_IO.Standard_Files.Standard_Input, Name => null, Line => 1, Page => 1, Col => 1, Line_Length => 0, Page_Length => 0, Last => 0, Ahead_Last => 0, Ahead_Col => 0, Looked_Ahead_Last => 0, Looked_Ahead_Second => (others => Character'Val (0)), Buffer => (others => Character'Val (0)), End_Of_File => False, Virtual_Mark => None, Mode => IO_Modes.In_File, External => System.Native_Text_IO.Default_External, -- be overwritten New_Line => System.Native_Text_IO.Default_New_Line); Standard_Output_Text : aliased Text_Type := ( Stream => System.Null_Address, -- be overwritten File => Streams.Naked_Stream_IO.Standard_Files.Standard_Output, Name => null, Line => 1, Page => 1, Col => 1, Line_Length => 0, Page_Length => 0, Last => 0, Ahead_Last => 0, Ahead_Col => 0, Looked_Ahead_Last => 0, Looked_Ahead_Second => (others => Character'Val (0)), Buffer => (others => Character'Val (0)), End_Of_File => False, Virtual_Mark => None, Mode => IO_Modes.Out_File, External => System.Native_Text_IO.Default_External, -- be overwritten New_Line => System.Native_Text_IO.Default_New_Line); Standard_Error_Text : aliased Text_Type := ( Stream => System.Null_Address, -- be overwritten File => Streams.Naked_Stream_IO.Standard_Files.Standard_Error, Name => null, Line => 1, Page => 1, Col => 1, Line_Length => 0, Page_Length => 0, Last => 0, Ahead_Last => 0, Ahead_Col => 0, Looked_Ahead_Last => 0, Looked_Ahead_Second => (others => Character'Val (0)), Buffer => (others => Character'Val (0)), End_Of_File => False, Virtual_Mark => None, Mode => IO_Modes.Out_File, External => System.Native_Text_IO.Default_External, -- be overwritten New_Line => System.Native_Text_IO.Default_New_Line); Standard_Input : constant Non_Controlled_File_Type := Standard_Input_Text'Access; Standard_Output : constant Non_Controlled_File_Type := Standard_Output_Text'Access; Standard_Error : constant Non_Controlled_File_Type := Standard_Error_Text'Access; end Ada.Naked_Text_IO;
with agar.core.error; with agar.core; package body demo is use type agar.gui.window.window_access_t; procedure init (name : string; video_width : integer := 640; video_height : integer := 480; window_width : integer := 320; window_height : integer := 240) is begin if not agar.core.init (name) then raise program_error with agar.core.error.get; end if; if not agar.gui.init_video (width => video_width, height => video_height, bpp => 32) then raise program_error with agar.core.error.get; end if; window := agar.gui.window.allocate_named (name => name & " test"); if window = null then raise program_error with agar.core.error.get; end if; agar.gui.window.set_caption (window, "demo"); agar.gui.window.set_geometry (window => window, x => 10, y => 10, width => window_width, height => window_height); end init; procedure run is begin agar.gui.window.show (window); agar.gui.event_loop; end run; procedure finish is begin null; end finish; end demo;
-- AOC 2020, Day 21 with Day; use Day; procedure main is begin ingredient_count("input.txt"); end main;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2011, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Characters.Wide_Wide_Latin_1; with Ada.Containers.Ordered_Maps; with Ada.Strings.Wide_Wide_Fixed; package body XMLConf.Canonical_Writers is use Ada.Characters.Wide_Wide_Latin_1; use type League.Strings.Universal_String; package Universal_String_Integer_Maps is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, Positive); function Escape_Character_Data (Item : League.Strings.Universal_String; Version : XML_Version) return League.Strings.Universal_String; -- Escape character data according to canonical form representation. -- '&', '<', '>' and '"' characters are replaced by general entity -- reference; TAB, CR and LF characters are replaced by character -- reference in hexadecimal format. procedure Set_Version (Self : in out Canonical_Writer); -- Sets version. ---------------- -- Characters -- ---------------- overriding procedure Characters (Self : in out Canonical_Writer; Text : League.Strings.Universal_String; Success : in out Boolean) is begin Self.Result.Append (Escape_Character_Data (Text, Self.Version)); end Characters; ------------- -- End_DTD -- ------------- overriding procedure End_DTD (Self : in out Canonical_Writer; Success : in out Boolean) is procedure Output_Notation (Position : Notation_Maps.Cursor); -- Outputs notation declaration. --------------------- -- Output_Notation -- --------------------- procedure Output_Notation (Position : Notation_Maps.Cursor) is Notation : constant Notation_Information := Notation_Maps.Element (Position); begin if Notation.Public_Id.Is_Empty then Self.Result.Append ("<!NOTATION " & Notation.Name & " SYSTEM '" & Notation.System_Id & "'>" & LF); elsif Notation.System_Id.Is_Empty then Self.Result.Append ("<!NOTATION " & Notation.Name & " PUBLIC '" & Notation.Public_Id & "'>" & LF); else Self.Result.Append ("<!NOTATION " & Notation.Name & " PUBLIC '" & Notation.Public_Id & "' '" & Notation.System_Id & "'>" & LF); end if; end Output_Notation; begin if not Self.Notations.Is_Empty then Self.Result.Append ("<!DOCTYPE " & Self.Name & " [" & LF); Self.Notations.Iterate (Output_Notation'Access); Self.Result.Append (League.Strings.To_Universal_String ("]>" & LF)); end if; end End_DTD; ----------------- -- End_Element -- ----------------- overriding procedure End_Element (Self : in out Canonical_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean) is begin Self.Result.Append ("</" & Qualified_Name & ">"); end End_Element; ------------------ -- Error_String -- ------------------ overriding function Error_String (Self : Canonical_Writer) return League.Strings.Universal_String is begin return League.Strings.Empty_Universal_String; end Error_String; --------------------------- -- Escape_Character_Data -- --------------------------- function Escape_Character_Data (Item : League.Strings.Universal_String; Version : XML_Version) return League.Strings.Universal_String is Result : League.Strings.Universal_String := Item; C : Wide_Wide_Character; begin for J in reverse 1 .. Item.Length loop C := Result.Element (J).To_Wide_Wide_Character; if C = '&' then Result.Replace (J, J, "&amp;"); elsif C = '<' then Result.Replace (J, J, "&lt;"); elsif C = '>' then Result.Replace (J, J, "&gt;"); elsif C = '"' then Result.Replace (J, J, "&quot;"); else case Version is when Unspecified => raise Program_Error; when XML_1_0 => if C = Wide_Wide_Character'Val (9) then Result.Replace (J, J, "&#9;"); elsif C = Wide_Wide_Character'Val (10) then Result.Replace (J, J, "&#10;"); elsif C = Wide_Wide_Character'Val (13) then Result.Replace (J, J, "&#13;"); end if; when XML_1_1 => if C in Wide_Wide_Character'Val (16#01#) .. Wide_Wide_Character'Val (16#1F#) or C in Wide_Wide_Character'Val (16#7F#) .. Wide_Wide_Character'Val (16#9F#) then Result.Replace (J, J, "&#" & Ada.Strings.Wide_Wide_Fixed.Trim (Integer'Wide_Wide_Image (Wide_Wide_Character'Pos (C)), Ada.Strings.Both) & ";"); end if; end case; end if; end loop; return Result; end Escape_Character_Data; -------------------------- -- Ignorable_Whitespace -- -------------------------- overriding procedure Ignorable_Whitespace (Self : in out Canonical_Writer; Text : League.Strings.Universal_String; Success : in out Boolean) is begin Set_Version (Self); Self.Result.Append (Escape_Character_Data (Text, Self.Version)); end Ignorable_Whitespace; -------------------------- -- Notation_Declaration -- -------------------------- overriding procedure Notation_Declaration (Self : in out Canonical_Writer; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean) is begin Self.Notations.Insert (Name, (Name, Public_Id, System_Id)); end Notation_Declaration; ---------------------------- -- Processing_Instruction -- ---------------------------- overriding procedure Processing_Instruction (Self : in out Canonical_Writer; Target : League.Strings.Universal_String; Data : League.Strings.Universal_String; Success : in out Boolean) is begin Set_Version (Self); Self.Result.Append ("<?" & Target & " " & Data & "?>"); end Processing_Instruction; -------------------------- -- Set_Document_Locator -- -------------------------- overriding procedure Set_Document_Locator (Self : in out Canonical_Writer; Locator : XML.SAX.Locators.SAX_Locator) is begin Self.Locator := Locator; end Set_Document_Locator; ----------------- -- Set_Version -- ----------------- procedure Set_Version (Self : in out Canonical_Writer) is use League.Strings; begin if Self.Version = Unspecified then if Self.Locator.Version = To_Universal_String ("1.0") then Self.Version := XML_1_0; elsif Self.Locator.Version = To_Universal_String ("1.1") then -- Self.Result.Prepend ("<?xml version=""1.1""?>"); Self.Result := "<?xml version=""1.1""?>" & Self.Result; Self.Version := XML_1_1; else raise Program_Error; end if; end if; end Set_Version; --------------- -- Start_DTD -- --------------- overriding procedure Start_DTD (Self : in out Canonical_Writer; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean) is begin Set_Version (Self); Self.Name := Name; end Start_DTD; ------------------- -- Start_Element -- ------------------- overriding procedure Start_Element (Self : in out Canonical_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean) is use League.Strings; use Universal_String_Integer_Maps; Map : Universal_String_Integer_Maps.Map; Position : Universal_String_Integer_Maps.Cursor; Index : Positive; begin Set_Version (Self); Self.Result.Append ("<" & Qualified_Name); for J in 1 .. Attributes.Length loop Map.Insert (Attributes.Qualified_Name (J), J); end loop; Position := Map.First; while Has_Element (Position) loop Index := Element (Position); Self.Result.Append (" " & Attributes.Qualified_Name (Index) & "=""" & Escape_Character_Data (Attributes.Value (Index), Self.Version) & '"'); Next (Position); end loop; Self.Result.Append ('>'); end Start_Element; ---------- -- Text -- ---------- function Text (Self : Canonical_Writer) return League.Strings.Universal_String is begin return Self.Result; end Text; end XMLConf.Canonical_Writers;
with Ada.Text_IO; with Threadsafe_Containers; use Threadsafe_Containers; procedure Circbuf_Example is circbuf : Threadsafe_Circbuf (3); task ProducerTask; task ConsumerTask; task body ProducerTask is begin for idx in 1..5 loop Ada.Text_IO.Put_Line("Producing!"); circbuf.Insert(idx); end loop; end ProducerTask; task body ConsumerTask is Value : Integer; begin for idx in 1..5 loop Ada.Text_IO.Put_Line("Consuming!"); circbuf.Remove(Value); end loop; end ConsumerTask; begin null; end Circbuf_Example;
pragma Warnings (Off); pragma Style_Checks (Off); -- Space vehicle #002 3D model. Copyright (c) Gautier de Montmollin 1999 - 2000 -- CH - 2000 Neuchatel -- SWITZERLAND -- Permission granted to use the herein contained 3D model for any purpose, -- provided this copyright note remains attached and unmodified. with GL; with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; package body Vehic002 is procedure Create ( object : in out GLOBE_3D.p_Object_3D; scale : GLOBE_3D.Real; centre : GLOBE_3D.Point_3D; metal_door, metal_surface, bumped_blue : GLOBE_3D.Image_id ) is use GL, GLOBE_3D; po, fa : Natural := 0; c1, c2, c3, c4 : Positive; x, y, z : Real; p : Point_3D; rx, ry, fx : Real; nth : constant := 13; ntv : constant := 121; seed : Generator; face_0 : Face_type; -- takes defaults values point : constant p_Point_3D_array := new Point_3D_array (1 .. (nth + 1)*ntv*4); face : constant p_Face_array := new Face_array (1 .. nth*ntv*4 + 2*ntv*ntv); begin Reset (seed); for tv in 0 .. ntv loop rx := 2.0*Real (tv)/Real (ntv) - 1.0; x := scale*rx; fx := 0.15 + 0.002 * (3.0* (rx*1.55 + 0.2)**5 - 16.0* (rx**2) - 5.0* (rx**4) + 1.2*rx); z := scale*fx; for co in 1 .. 4 loop for th in 1 .. nth loop ry := 2.0*Real (th - 1)/Real (nth) - 1.0; ry := ry * fx; y := scale*ry; case co is when 1 => p := (x, - y, - z); when 2 => p := (x, - z, y); when 3 => p := (x, y, z); when 4 => p := (x, z, - y); end case; if tv>=1 then c1 := (co - 1)*nth + th; c2 := c1 mod (4*nth) + 1; c3 := c2 + 4*nth; c4 := c1 + 4*nth; c1 := c1 + 4*nth* (tv - 1); c2 := c2 + 4*nth* (tv - 1); c3 := c3 + 4*nth* (tv - 1); c4 := c4 + 4*nth* (tv - 1); fa := fa + 1; face_0.P := (c1, c4, c3, c2); if th in 2 .. nth - 1 then face_0.skin := colour_only; face_0.colour := (0.3, 0.3, 0.3 + 0.4*Real (Random (seed))); else face_0.skin := coloured_texture; face_0.colour := (0.2, 0.2, 0.2 + 0.2*Real (Random (seed))); face_0.texture := bumped_blue; face_0.repeat_U := 3; face_0.repeat_V := 3; end if; face (fa) := face_0; end if; po := po + 1; point (po) := p; end loop; end loop; end loop; fa := fa + 1; face_0.P := (1, 1 + nth, 1 + 2*nth, 1 + 3*nth); face_0.skin := texture_only; face_0.texture := metal_door; face_0.repeat_U := 1; face_0.repeat_V := 1; face (fa) := face_0; -- fa := fa + 1; c1 := 1 + ntv*4*nth; face_0.P := (c1, c1 + 3*nth, c1 + 2*nth, c1 + nth); face_0.skin := texture_only; face_0.texture := metal_surface; face_0.repeat_U := 5; face_0.repeat_V := 5; face (fa) := face_0; object := new Object_3D (po, fa); object.point := point (1 .. po); object.face := face (1 .. fa); object.centre := centre; Set_name (object.all, "vehicle_002"); end Create; end Vehic002;
------------------------------------------------------------------------------- -- package body Chi_Gaussian_CDF, CDF of Normal and Chi-square distributions -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ------------------------------------------------------------------------------- with Ada.Numerics.Generic_Elementary_Functions; with Gamma; package body Chi_Gaussian_CDF is package Math is new Ada.Numerics.Generic_Elementary_Functions(Real); use Math; package Gam is new Gamma(Real); use Gam; --provides log_gamma; for reals to 32 digits Real_Epsilon : constant Real := Real'Epsilon * 0.5; -- 4.4*e-16 for ieee Max_Log : constant Real := 666.0; --------------------- -- Chi_Squared_CDF -- --------------------- -- Cumulative distribution function for Chi^2 distribution. function Chi_Squared_CDF (True_Degrees_Freedom : Real; Chi_Squared : Real) return Real is a : constant Real := True_Degrees_Freedom * 0.5; x : constant Real := Chi_Squared * 0.5; begin if not x'Valid then raise Constraint_Error; end if; -- In some cases, input of (say) inf or NaN will make numeric programs -- hang rather than crash .. very difficult to diagnose, so this seems -- best policy for function calls that are rarely found in time-sensitive -- inner loops return Incomplete_Gamma (a, x); end Chi_Squared_CDF; function Normal_CDF_x (x : in Real) return Real; ----------------- -- Normal_CDF -- ----------------- -- Cumulative distribution function for Standard Normal Distribution. -- -- Normal (v) = exp(-v*v/2) / Sqrt(2 pi) -- -- Want to integrate this from -inf to x using the Incomplete Gamma function: -- -- Inc_Gamma(a, w) = Int{from 0 to w} [exp(-t) t**(a-1) dt] / Gamma(a) -- -- Set a = 0.5. Use Gamma(0.5) = Sqrt(pi) and let t = u*u/2: -- -- Inc_Gamma(0.5, w) = Int{from 0 to sqrt(2w)} [2 exp(-v*v/2) dv] / Sqrt(2 pi) -- -- Inc_Gamma(0.5, x*x/2) / 2 = Int{from 0 to x)} [exp(-v*v/2) dv] / Sqrt(2 pi) -- -- function Normal_CDF (x : Real) return Real is a : constant Real := 0.5; begin if not x'Valid then raise Constraint_Error; end if; -- In some cases, input of (say) inf or NaN will make numeric programs -- hang rather than crash .. very difficult to diagnose, so this seems -- best policy for function calls that are rarely found in time-sensitive -- inner loops. if x > 0.0 then return 0.5 * (1.0 + Incomplete_Gamma (a, x*x*0.5)); elsif x <= -4.5 then return Normal_CDF_x (x); -- get better accuracy here out on tail. else return 0.5 * (1.0 - Incomplete_Gamma (a, x*x*0.5)); end if; end Normal_CDF; ------------------------ -- Incomplete_Gamma_C -- ------------------------ -- This is the complemented Incomplete_Gamma function: -- -- Incomplete_Gamma_C (a,x) -- = Integral {t=x to inf} [exp(-t) * t**(a-1) * dt] / Gamma(a) -- -- Notice that because the integrals are nomalized by 1 / Gamma(a): -- -- Incomplete_Gamma (a,x) + Incomplete_Gamma_C (a,x) = 1.0 -- -- Uses Gauss' (c. 1813) continued fraction (see wikipedia for inc. gamma) -- function Incomplete_Gamma_C (a : Real; x : Real) return Real is Exagam, Arg : Real; C_Fraction, N, g_2, g_1 : Real; r, t : Real; P, P_1, P_2 : Real; Q, Q_1, Q_2 : Real; Max_Allowed_Val : constant Real := 2.0**48; Reciprocal_of_Max_Allowed_Val : constant Real := 2.0**(-48); Min_Allowed_Real : constant Real := 2.0**(Real'Machine_Emin / 2); begin if not x'Valid then raise Constraint_Error; end if; if (x <= 0.0) or (a <= 0.0) then return 1.0; end if; -- Use series solution for small x: if (x < 1.0) or (x < a) then return 1.0 - Incomplete_Gamma(a,x); end if; -- Exagam := x**a * Exp(-x) / Gamma(a): Arg := a * Log (x) - x - Log_Gamma (a); -- notice never gets big > 0 if x>0 if (Arg < -Max_Log) then return 0.0; else Exagam := Exp (Arg); end if; N := 0.0; g_1 := x - a + 2.0; P_2 := 1.0; --P(-2) Q_2 := x; --Q(-2) P_1 := x + 1.0; --P(-1) Q_1 := Q_2 * g_1; --Q(-1) C_Fraction := P_1 / Q_1; Continued_Fraction_Evaluation: loop N := N + 1.0; g_1 := g_1 + 2.0; g_2 := (N + 1.0 - a) * N; P := P_1 * g_1 - P_2 * g_2; Q := Q_1 * g_1 - Q_2 * g_2; if (Abs Q > Min_Allowed_Real) then r := P / Q; t := Abs ((C_Fraction - r) / r); C_Fraction := r; else t := 1.0; end if; -- scale P's and Q's identically with 2.0**n if P gets too large. -- Final answer is P/Q. P_2 := P_1; P_1 := P; Q_2 := Q_1; Q_1 := Q; if (Abs (P) > Max_Allowed_Val) then P_2 := P_2 * Reciprocal_of_Max_Allowed_Val; P_1 := P_1 * Reciprocal_of_Max_Allowed_Val; Q_2 := Q_2 * Reciprocal_of_Max_Allowed_Val; Q_1 := Q_1 * Reciprocal_of_Max_Allowed_Val; end if; if (t < Real_Epsilon) then exit Continued_Fraction_Evaluation; end if; end loop Continued_Fraction_Evaluation; return C_Fraction * Exagam; end Incomplete_Gamma_C; ---------------------- -- Incomplete_Gamma -- ---------------------- -- Incomplete_Gamma (a,x) = Integral {t=0 to x} [exp(-t) * t**(a-1) * dt] / Gamma(a) -- -- Notice as x -> inf, the Integral -> Gamma(a), and Incomplete_Gamma (a,x) -> 1.0 -- -- Abramowitz, Stegun 6.5.29: -- -- = Exp(-x) * x**a * Sum {k=0 to inf} [x**k / Gamma(a+k+1)] -- -- use Gamma(a+1) = a * Gamma(a): -- -- = Exp(-x) * x**a * Sum {k=0 to inf} [a! * (-x)**k / (a+k)!] / Gamma(a) -- -- = Exp(-x) * x**a * [1/a + x/(a(a+1)) + x^2/(a(a+1)(a+2)) + ...] / Gamma(a) -- function Incomplete_Gamma (a : Real; x : Real) return Real is Sum, Exagam, Arg, Next_Term, a_plus_n : Real; begin if not x'Valid then raise Constraint_Error; end if; if (x <= 0.0) or (a <= 0.0) then return 0.0; end if; if not ((x < 1.0) or (x < a)) then return (1.0 - Incomplete_Gamma_C (a,x)); end if; -- Exagam := x**a * Exp(-x) / Gamma(a): Arg := a * Log (x) - x - Log_Gamma (a); if Arg < -Max_Log then return 0.0; else Exagam := Exp (Arg); end if; -- -- (Exp(-x) * x**a / Gamma(a))* [1/a + x/(a(a+1)) + x^2/(a(a+1)(a+2)) + ...] -- -- factor out the 1/a: -- -- = (Exagam / a) * [1 + x/(a+1) + x^2/((a+1)(a+2)) + ...] -- a_plus_n := a; -- n = 0 Next_Term := 1.0; Sum := 1.0; -- max number of allowed iterations arbitrarily set at 2**12: Series_Summation: for Iteration_id in 1 .. 2**12 loop a_plus_n := a_plus_n + 1.0; Next_Term := Next_Term * x / a_plus_n; Sum := Sum + Next_Term; if (Next_Term/Sum < Real_Epsilon) then exit Series_Summation; end if; end loop Series_Summation; return Sum * Exagam / a; end Incomplete_Gamma; ------------------ -- Normal_CDF_x -- ------------------ -- Here just used for x out on tail, where it seems more accurate -- than the other method used above. -- -- Evaluates the cumulative distribution function of a gaussian. -- Finds area of the standardized normal distribution -- (normalized gaussian with unit width) from -inf to x. -- based on Algorithm AS66 Applied Statistics (1973) vol.22, no.3. -- Usually 7 digits accuracy; better on x<<0 tail. function Normal_CDF_x (x : in Real) return Real is z, y, Result : Real; con : constant Real := 1.28; ltone : constant Real := 7.0; utzero : constant Real := 40.0; p : constant Real := 0.398942280444; q : constant Real := 0.39990348504; r : constant Real := 0.398942280385; a1 : constant Real := 5.75885480458; a2 : constant Real := 2.62433121679; a3 : constant Real := 5.92885724438; b1 : constant Real :=-29.8213557807; b2 : constant Real := 48.6959930692; c1 : constant Real :=-3.8052E-8; c2 : constant Real := 3.98064794E-4; c3 : constant Real :=-0.151679116635; c4 : constant Real := 4.8385912808; c5 : constant Real := 0.742380924027; c6 : constant Real := 3.99019417011; d1 : constant Real := 1.00000615302; d2 : constant Real := 1.98615381364; d3 : constant Real := 5.29330324926; d4 : constant Real :=-15.1508972451; d5 : constant Real := 30.789933034; begin if not x'Valid then raise Constraint_Error; end if; z := Abs (x); if (z <= ltone OR (x < 0.0 AND (z <= utzero)) ) then y := 0.5*z*z; if (z > con) then Result := r*Exp(-y) / (z+c1+d1/(z+c2+d2/(z+c3+d3/(z+c4+d4/(z+c5+d5/(z+c6)))))); else Result := 0.5 - z*(p-q*y/(y+a1+b1/(y+a2+b2/(y+a3)))); end if; else Result := 0.0; end if; if (x >= 0.0) then Result := 1.0 - Result; end if; return Result; end Normal_CDF_x; -- rough test; more of working order than actual accuracy procedure Test_Normal_CDF (x_0 : in Real; Error : out Real) is Delta_x : constant Real := 2.0**(-6); -- 6 ok. type First_Deriv_Range_17 is range -8 .. 8; d_17 : constant array(First_Deriv_Range_17) of Real := (9.71250971250971250971250971250971250E-6 , -1.77600177600177600177600177600177600E-4 , 1.55400155400155400155400155400155400E-3 , -8.70240870240870240870240870240870240E-3 , 3.53535353535353535353535353535353535E-2 , -1.13131313131313131313131313131313131E-1 , 3.11111111111111111111111111111111111E-1 , -8.88888888888888888888888888888888888E-1 , 0.0, 8.88888888888888888888888888888888888E-1 , -3.11111111111111111111111111111111111E-1 , 1.13131313131313131313131313131313131E-1 , -3.53535353535353535353535353535353535E-2 , 8.70240870240870240870240870240870240E-3 , -1.55400155400155400155400155400155400E-3 , 1.77600177600177600177600177600177600E-4 , -9.71250971250971250971250971250971250E-6); One_over_sqrt_2_pi : constant := 0.398942280401432677939946; sum, x, Integral_of_Gaussian, Deriv : Real; begin sum := 0.0; for i in First_Deriv_Range_17 loop x := x_0 + Real(i)*Delta_x; Integral_of_Gaussian := Normal_CDF (x); sum := sum + d_17 (i) * Integral_of_Gaussian; end loop; Deriv := sum / Delta_x; -- relative --Error := (Deriv - Exp (-x_0**2 * 0.5) * One_over_sqrt_2_pi) / (Abs(Deriv)+1.0e-307); -- absolute Error := (Deriv - Exp (-x_0**2 * 0.5) * One_over_sqrt_2_pi); end Test_Normal_CDF; end Chi_Gaussian_CDF;
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl> -- -- 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.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Integer_Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Maps; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with System.Address_Image; with Tashy2; use Tashy2; with Tk.MainWindow; package body Tk.Widget is function Widgets_Array_Image(Widgets: Widgets_Array) return String is Widgets_Names: Unbounded_String := Null_Unbounded_String; begin Set_Widgets_Array_Loop : for Widgt of Widgets loop Append (Source => Widgets_Names, New_Item => Tk_Path_Name(Widgt => Widgt) & " "); end loop Set_Widgets_Array_Loop; return Trim(Source => To_String(Source => Widgets_Names), Side => Right); end Widgets_Array_Image; function Pixel_Data_Value(Value: String) return Pixel_Data is Result: Pixel_Data := Empty_Pixel_Data; begin if Value'Length = 0 then return Result; end if; if Is_Digit(Item => Value(Value'Last)) then Result.Value := Positive_Float'Value(Value); Result.Value_Unit := PIXEL; else Result.Value := Positive_Float'Value(Value(Value'First .. Value'Last - 1)); Result.Value_Unit := Pixel_Unit'Value("" & Value(Value'Last)); end if; return Result; end Pixel_Data_Value; function Pixel_Data_Image(Value: Pixel_Data) return String is Value_String: String(1 .. 255); begin Put (To => Value_String, Item => Float(Value.Value), Aft => Positive_Float'Digits, Exp => 0); if Value.Value_Unit /= PIXEL then return Trim(Source => Value_String, Side => Both) & To_Lower(Item => Pixel_Unit'Image(Value.Value_Unit)); end if; return Trim(Source => Value_String, Side => Both); end Pixel_Data_Image; function Get_Widget (Path_Name: Tk_Path_String; Interpreter: Tcl_Interpreter := Get_Interpreter) return Tk_Widget is use Tk.MainWindow; function Tk_Name_To_Window (Interp: Tcl_Interpreter; Path_Name_C: chars_ptr; Tk_Win: Tk_Widget) return Tk_Widget with Global => null, Import, Convention => C, External_Name => "Tk_NameToWindow"; begin return Tk_Name_To_Window (Interp => Interpreter, Path_Name_C => To_C_String(Str => Path_Name), Tk_Win => Get_Main_Window(Interpreter => Interpreter)); end Get_Widget; function Tk_Path_Name(Widgt: Tk_Widget) return Tk_Path_String is function Get_Path_Name(Tk_Win: Tk_Widget) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Get_PathName"; begin return From_C_String(Item => Get_Path_Name(Tk_Win => Widgt)); end Tk_Path_Name; procedure Option_Image (Name: String; Value: Tcl_String; Options_String: in out Unbounded_String) is begin if Length(Source => Value) > 0 then Append (Source => Options_String, New_Item => " -" & Name & " " & To_String(Source => Value)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Extended_Natural; Options_String: in out Unbounded_String) is begin if Value > -1 then Append (Source => Options_String, New_Item => " -" & Name & Extended_Natural'Image(Value)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Pixel_Data; Options_String: in out Unbounded_String) is begin if Value.Value > -1.0 then Append (Source => Options_String, New_Item => " -" & Name & " " & Pixel_Data_Image(Value => Value)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Relief_Type; Options_String: in out Unbounded_String) is begin if Value /= NONE then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => Relief_Type'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: State_Type; Options_String: in out Unbounded_String) is begin if Value /= NONE then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => State_Type'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: Directions_Type; Options_String: in out Unbounded_String) is begin if Value /= NONE then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => Directions_Type'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: Place_Type; Options_String: in out Unbounded_String) is begin if Value /= EMPTY then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => Place_Type'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: Justify_Type; Options_String: in out Unbounded_String) is begin if Value /= NONE then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => Justify_Type'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: Horizontal_Pad_Data; Options_String: in out Unbounded_String) is begin if Value.Left.Value > -1.0 then Append (Source => Options_String, New_Item => " -" & Name & " {" & Pixel_Data_Image(Value => Value.Left)); if Value.Right.Value > -1.0 then Append (Source => Options_String, New_Item => " " & Pixel_Data_Image(Value => Value.Right)); end if; Append(Source => Options_String, New_Item => "}"); end if; end Option_Image; procedure Option_Image (Name: String; Value: Vertical_Pad_Data; Options_String: in out Unbounded_String) is begin if Value.Top.Value > -1.0 then Append (Source => Options_String, New_Item => " -" & Name & " {" & Pixel_Data_Image(Value => Value.Top)); if Value.Bottom.Value > -1.0 then Append (Source => Options_String, New_Item => " " & Pixel_Data_Image(Value => Value.Bottom)); end if; Append(Source => Options_String, New_Item => "}"); end if; end Option_Image; procedure Option_Image (Name: String; Value: Tk_Widget; Options_String: in out Unbounded_String) is begin if Value /= Null_Widget then Append (Source => Options_String, New_Item => " -" & Name & " " & Tk_Path_Name(Widgt => Value)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Extended_Boolean; Options_String: in out Unbounded_String) is begin case Value is when FALSE => Append(Source => Options_String, New_Item => " -" & Name & " 0"); when TRUE => Append(Source => Options_String, New_Item => " -" & Name & " 1"); when NONE => null; end case; end Option_Image; procedure Option_Image (Name: String; Value: Tk_Window; Options_String: in out Unbounded_String) is use Ada.Strings.Maps; New_Value: constant String := System.Address_Image(A => System.Address(Value)); begin if Value /= Null_Window then Append (Source => Options_String, New_Item => " -" & Name & " 0x" & Trim (Source => To_Lower(Item => New_Value), Left => To_Set(Singleton => '0'), Right => Null_Set)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Integer; Options_String: in out Unbounded_String; Base: Positive := 10) is use Ada.Integer_Text_IO; Hex_Value: String(1 .. 32) := (others => ' '); New_Value: Unbounded_String := Null_Unbounded_String; begin if Value /= 0 then Append(Source => Options_String, New_Item => " -" & Name); if Value < 0 then Append(Source => Options_String, New_Item => " "); end if; case Base is when 10 => Append (Source => Options_String, New_Item => Integer'Image(Value)); when 16 => Put(To => Hex_Value, Item => Value, Base => 16); New_Value := To_Unbounded_String (Source => Trim(Source => Hex_Value, Side => Both)); Append (Source => Options_String, New_Item => " 0x" & Slice (Source => New_Value, Low => 4, High => Length(Source => New_Value) - 1)); when others => null; end case; end if; end Option_Image; procedure Option_Image (Name: String; Value: Anchor_Directions; Options_String: in out Unbounded_String) is begin if Value /= NONE then Append (Source => Options_String, New_Item => " -" & Name & " " & To_Lower(Item => Anchor_Directions'Image(Value))); end if; end Option_Image; procedure Option_Image (Name: String; Value: Positive_Float; Options_String: in out Unbounded_String) is Value_String: String(1 .. 255) := (others => ' '); begin if Value >= 0.0 then Put (To => Value_String, Item => Float(Value), Aft => Positive_Float'Digits, Exp => 0); Append (Source => Options_String, New_Item => " -" & Name & " " & Trim(Source => Value_String, Side => Both)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Point_Position; Options_String: in out Unbounded_String) is begin if Value /= Empty_Point_Position then Append (Source => Options_String, New_Item => " -" & Name & Extended_Natural'Image(Value.X) & Extended_Natural'Image(Value.Y)); end if; end Option_Image; procedure Option_Image (Name: String; Value: Boolean; Options_String: in out Unbounded_String) is begin if Value then Append(Source => Options_String, New_Item => " -" & Name); end if; end Option_Image; function Option_Value(Widgt: Tk_Widget; Name: String) return Tcl_String is begin return To_Tcl_String (Source => Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result); end Option_Value; function Option_Value (Widgt: Tk_Widget; Name: String) return Directions_Type is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length = 0 then return NONE; end if; return Directions_Type'Value(Result); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Pixel_Data is begin return Pixel_Data_Value (Value => Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Place_Type is begin return Place_Type'Value (Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return State_Type is begin return State_Type'Value (Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Justify_Type is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length = 0 then return NONE; end if; return Justify_Type'Value(Result); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Relief_Type is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length > 0 then return Relief_Type'Value(Result); end if; return NONE; end Option_Value; function Option_Value (Widgt: Tk_Widget; Name: String) return Extended_Natural is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length > 0 then return Extended_Natural'Value(Result); end if; return -1; end Option_Value; function Option_Value (Widgt: Tk_Widget; Name: String) return Extended_Boolean is begin Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name); if Tcl_Get_Result(Interpreter => Tk_Interp(Widgt => Widgt)) = "1" then return TRUE; else return FALSE; end if; end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Tk_Widget is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length = 0 then return Null_Widget; end if; return Get_Widget (Path_Name => Result, Interpreter => Tk_Interp(Widgt => Widgt)); end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Tk_Window is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length > 0 then return Tk_Window (System'To_Address (Integer'Value("16#" & Result(3 .. Result'Last) & "#"))); end if; return Null_Window; end Option_Value; function Option_Value(Widgt: Tk_Widget; Name: String) return Integer is Result: constant String := Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result; begin if Result'Length = 0 then return 0; end if; return Integer'Value(Result); end Option_Value; function Option_Value (Widgt: Tk_Widget; Name: String) return Anchor_Directions is begin return Anchor_Directions'Value (Execute_Widget_Command (Widgt => Widgt, Command_Name => "cget", Options => "-" & Name) .Result); end Option_Value; procedure Destroy(Widgt: in out Tk_Widget) is procedure Tk_Destroy_Window(Tk_Win: Tk_Widget) with Global => null, Import, Convention => C, External_Name => "Tk_DestroyWindow"; begin Tk_Destroy_Window(Tk_Win => Widgt); Widgt := Null_Widget; end Destroy; procedure Execute_Widget_Command (Widgt: Tk_Widget; Command_Name: String; Options: String := "") is begin Tcl_Eval (Tcl_Script => Tk_Path_Name(Widgt => Widgt) & " " & Command_Name & " " & Options, Interpreter => Tk_Interp(Widgt => Widgt)); end Execute_Widget_Command; function Execute_Widget_Command (Widgt: Tk_Widget; Command_Name: String; Options: String := "") return Tcl_String_Result is begin return Tcl_Eval (Tcl_Script => Tk_Path_Name(Widgt => Widgt) & " " & Command_Name & " " & Options, Interpreter => Tk_Interp(Widgt => Widgt)); end Execute_Widget_Command; function Execute_Widget_Command (Widgt: Tk_Widget; Command_Name: String; Options: String := "") return Tcl_Boolean_Result is begin return Tcl_Eval (Tcl_Script => Tk_Path_Name(Widgt => Widgt) & " " & Command_Name & " " & Options, Interpreter => Tk_Interp(Widgt => Widgt)); end Execute_Widget_Command; function Generic_Scalar_Execute_Widget_Command (Widgt: Tk_Widget; Command_Name: String; Options: String := "") return Result_Type is begin return Result_Type'Value (Execute_Widget_Command (Widgt => Widgt, Command_Name => Command_Name, Options => Options) .Result); end Generic_Scalar_Execute_Widget_Command; function Generic_Float_Execute_Widget_Command (Widgt: Tk_Widget; Command_Name: String; Options: String := "") return Result_Type is begin return Result_Type'Value (Execute_Widget_Command (Widgt => Widgt, Command_Name => Command_Name, Options => Options) .Result); end Generic_Float_Execute_Widget_Command; end Tk.Widget;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with XML.SAX.Attributes; with XML.SAX.Locators; package XML.SAX.Content_Handlers is pragma Preelaborate; type SAX_Content_Handler is limited interface; not overriding procedure Characters (Self : in out SAX_Content_Handler; Text : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram when it has parsed a chunk of character -- data (either normal character data or character data inside a CDATA -- section; if you need to distinguish between those two types you must use -- SAX_Lexical_Handler.Start_CDATA and SAX_Lexical_Handler.End_CDATA -- subprograms). The character data is reported in Text. -- -- Some readers report whitespace in element content using the -- Ignorable_Whitespace subprogram rather than using this one. -- -- A reader may return all contiguous character data in a single chunk, or -- may split it into several chunks; however, all of the characters in any -- single event must come from the same external entity so that the Locator -- provides useful information. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_Document (Self : in out SAX_Content_Handler; Success : in out Boolean) is null; -- The reader calls this subprogram after it has finished parsing. It is -- called just once, and is the last subprogram called. It is called after -- the reader has read all input or has abandoned parsing because of fatal -- error. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_Element (Self : in out SAX_Content_Handler; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this function when it has parsed an end element tag -- with the qualified name Qualified_Name, the local name Local_Name and -- the namespace URI Namespace_URI. It is called even when element is -- empty. -- -- Namespace_URI and Local_Name is provided only when namespace handling -- is enabled, otherwise they are an empty strings. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_Prefix_Mapping (Self : in out SAX_Content_Handler; Prefix : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to signal the end of a prefix mapping -- for the prefix Prefix. -- -- These events always occur immediately after the corresponding -- End_Element event, but the order of End_Prefix_Mapping events is not -- otherwise guaranteed. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding function Error_String (Self : SAX_Content_Handler) return League.Strings.Universal_String is abstract; -- The reader calls this function to get an error string, e.g. if any of -- the handler subprograms sets Success to False. not overriding procedure Ignorable_Whitespace (Self : in out SAX_Content_Handler; Text : League.Strings.Universal_String; Success : in out Boolean) is null; -- Validating readers must use this subprogram to report each chunk of -- whitespace in element content, non-validating readers may also use this -- subprogram if they are capable of parsing and using content model, The -- whitespace is reported in Text. -- -- SAX readers may return all contiguous whitespace in a single chunk, or -- they may split it into several chunks; however, all of the characters in -- any single event must come from the same external entity, so that the -- Locator provides useful information. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Processing_Instruction (Self : in out SAX_Content_Handler; Target : League.Strings.Universal_String; Data : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram when it has parsed a processing -- instruction. Target is the name of the processing instruction and Data -- is the data in the processing instruction. -- -- The reader must never report an XML declaration or a text declaration -- using this subprogram. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Set_Document_Locator (Self : in out SAX_Content_Handler; Locator : XML.SAX.Locators.SAX_Locator) is null; -- The reader calls this subprogram before is starts parsing the document. -- Argument Locator is object which allows the application to get the -- parsing position within the document. -- -- The locator allows the application to determine the end position of any -- document-related event, even if the parser is not reporting an error. -- Typically, the application will use this information for reporting its -- own errors (such as character content that does not match an -- application's business rules). The information returned by the locator -- is probably not sufficient for use with a search engine. -- -- Note that the locator will return correct information only during the -- invocation SAX event callbacks after Start_Document returns and before -- End_Document is called. The application should not attempt to use it at -- any other time. not overriding procedure Skipped_Entity (Self : in out SAX_Content_Handler; Name : League.Strings.Universal_String; Success : in out Boolean) is null; -- Some readers may skip entities if they have not seen the declaration. -- If they do so they report that they skipped the entity called Name by -- calling this subprogram. -- -- This is not called for entity references within markup constructs such -- as element start tags or markup declarations. (The XML recommendation -- requires reporting skipped external entities. SAX also reports internal -- entity expansion/non-expansion, except within markup constructs.) -- -- Non-validating processors may skip entities if they have not seen the -- declarations (because, for example, the entity was declared in an -- external DTD subset). All processors may skip external entities, -- depending on the values of the -- http://xml.org/sax/features/external-general-entities and the -- http://xml.org/sax/features/external-parameter-entities properties. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Start_Document (Self : in out SAX_Content_Handler; Success : in out Boolean) is null; -- The reader calls this subprogram when it starts parsing the document. -- The reader calls this subprogram just once, after the call to -- Set_Document_Locator, and before and other subprogram in this -- interface or in the SAX_DTD_Handler interface are called. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Start_Element (Self : in out SAX_Content_Handler; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean) is null; -- The reader calls this subprogram when it has parsed a start element tag. -- -- There is a corresponding End_Element call when the corresponding and -- element tag is read. The Start_Element and End_Element calls are always -- nested correctly. Empty element tags (e.g. <x/>) cause a Start_Element -- call to be immediately followed by and End_Element call. -- -- The attribute list provided only contains attributes with explicit -- values (specified or defaulted): #IMPLIED attributes will be omitted. -- The attribute list contains attributes used for namespace -- declaration (i.e. attributes starting with xmlns) only if the -- http://xml.org/sax/features/namespace-prefixes property of the reader is -- true. -- -- The argument Namespace_URI is the namespace URI, or an empty string if -- the element has no namespace URI or if no namespace processing is done. -- Local_Name is the local name (without prefix), or an empty string if no -- namespace processing is done, Qualified_Name is the qualified name (with -- prefix) and Attributes are the attributes attached to the element. If -- there are no attributes, Attributes is an empty attributes object. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Start_Prefix_Mapping (Self : in out SAX_Content_Handler; Prefix : League.Strings.Universal_String; Namespace_URI : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to signal the begin of a prefix-URI -- namespace mapping scope. This information is not necessary for normal -- namespace processing since the reader automatically replaces prefixes -- for element and attribute names. -- -- Note that Start_Prefix_Mapping and End_Prefix_Mapping calls are not -- guaranteed to be properly nested relative to each other: all -- Start_Prefix_Mapping events occur before the corresponding Start_Element -- event, and all End_Prefix_Mapping events occur after the corresponding -- End_Element event, but their order is not otherwise guaranteed. -- -- The argument Prefix is the namespace prefix being declared and the -- argument Namespace_URI is the namespace URI the prefix is mapped to. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. end XML.SAX.Content_Handlers;
-- ---------------------------------------------------------------- -- json_create.adb -- -- Jan/05/2014 -- -- ---------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams; with Ada.Command_Line; -- ---------------------------------------------------------------- procedure json_create is procedure record_out_proc (Outfile : File_Type; key: in String; name: in String; population: in String; date_mod: in String; tx: in String) is begin Ada.Text_IO.Put_Line("*** record_out_proc ***"); String'Write (Stream (Outfile), '"' & key & '"' & ":{" & '"' & "name" & '"' & ":" & '"' & name & '"' & "," & '"' & "population" & '"' & ":" & '"' & population & '"' & "," & '"' & "date_mod" & '"' & ":" & '"' & date_mod & '"' & "}" & tx & ASCII.LF); end record_out_proc; Outfile : File_Type; file_text : String := Ada.Command_Line.Argument (1); str_out : String := "<?xml version=" & '"' & "1.0" & '"' & " encoding=" & '"' & "utf-8" & '"' & "?>"; begin Ada.Text_IO.Put_Line("*** 開始 ***"); Create (File => Outfile, Mode => Out_File, Name => file_text); String'Write (Stream (Outfile),"{" & ASCII.LF); record_out_proc (Outfile,"t0921","宇都宮","43912","1943-6-28",","); record_out_proc (Outfile,"t0922","小山","82167","1943-3-15",","); record_out_proc (Outfile,"t0923","佐野","39254","1943-8-9",","); record_out_proc (Outfile,"t0924","足利","51792","1943-6-3",","); record_out_proc (Outfile,"t0925","日光","89327","1943-1-12",","); record_out_proc (Outfile,"t0926","下野","32198","1943-2-7",","); record_out_proc (Outfile,"t0927","さくら","54982","1943-10-21",","); record_out_proc (Outfile,"t0928","矢板","97123","1943-5-12",","); record_out_proc (Outfile,"t0929","真岡","47235","1943-4-24",","); record_out_proc (Outfile,"t0930","栃木","83592","1943-8-12",","); record_out_proc (Outfile,"t0931","大田原","51276","1943-5-15",","); record_out_proc (Outfile,"t0932","鹿沼","32917","1943-9-18",","); record_out_proc (Outfile,"t0933","那須塩原","27458","1943-3-24",","); record_out_proc (Outfile,"t0934","那須烏山","54832","1943-6-9","}"); Close (Outfile); Ada.Text_IO.Put_Line("*** 終了 ***"); end json_create; -- ----------------------------------------------------------------
----------------------------------------------------------------------- -- stemmer-stemmer-tests -- Tests for stemmer -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Util.Test_Caller; with Util.Files; with Util.Strings; package body Stemmer.Tests is use Stemmer.Factory; package Caller is new Util.Test_Caller (Test, "stemmer"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Stemmer.Stem (French)", Test_Stem_French'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (English)", Test_Stem_English'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Greek)", Test_Stem_Greek'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Spanish)", Test_Stem_Spanish'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Swedish)", Test_Stem_Swedish'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Russian)", Test_Stem_Russian'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Serbian)", Test_Stem_Serbian'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (French, Ref File)", Test_Stem_French_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Spanish, Ref File)", Test_Stem_Spanish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (English, Ref File)", Test_Stem_English_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Swedish, Ref File)", Test_Stem_Swedish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Russian, Ref File)", Test_Stem_Russian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Serbian, Ref File)", Test_Stem_Serbian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (German, Ref File)", Test_Stem_German_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Italian, Ref File)", Test_Stem_Italian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Greek, Ref File)", Test_Stem_Greek_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Danish, Ref File)", Test_Stem_Danish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Dutch, Ref File)", Test_Stem_Dutch_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Catalan, Ref File)", Test_Stem_Catalan_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Basque, Ref File)", Test_Stem_Basque_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Finnish, Ref File)", Test_Stem_Finnish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Hindi, Ref File)", Test_Stem_Hindi_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Hungarian, Ref File)", Test_Stem_Hungarian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Irish, Ref File)", Test_Stem_Irish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Indonesian, Ref File)", Test_Stem_Indonesian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Nepali, Ref File)", Test_Stem_Nepali_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Norwegian, Ref File)", Test_Stem_Norwegian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Portuguese, Ref File)", Test_Stem_Portuguese_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Romanian, Ref File)", Test_Stem_Romanian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Porter, Ref File)", Test_Stem_Porter_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Tamil, Ref File)", Test_Stem_Tamil_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Turkish, Ref File)", Test_Stem_Turkish_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Lithuanian, Ref File)", Test_Stem_Lithuanian_Reference_File'Access); Caller.Add_Test (Suite, "Test Stemmer.Stem (Arabic, Ref File)", Test_Stem_Arabic_Reference_File'Access); end Add_Tests; procedure Verify (T : in out Test; L : in Factory.Language_Type; Source : in String) is procedure Process (Line : in String); Error : Boolean := False; procedure Process (Line : in String) is Pos : constant Natural := Util.Strings.Index (Line, ASCII.HT); begin if Pos > 0 then declare Word : constant String := Line (Line'First .. Pos - 1); Expect : constant String := Line (Pos + 1 .. Line'Last); Result : constant String := Stemmer.Factory.Stem (L, Word); begin if Result /= Expect then Ada.Text_IO.Put_Line ("Bad [" & Word & "] -> [" & Result & "] <== " & Expect); Error := True; end if; end; end if; end Process; begin Util.Files.Read_File (Source, Process'Access); T.Assert (not Error, "Stemming error for " & Source); end Verify; procedure Verify (T : in out Test; L : in Factory.Language_Type; S : in String; R : in String) is Result : constant String := Stemmer.Factory.Stem (L, S); begin T.Assert_Equals (R, Result, S, "Invalid Stem for " & S); end Verify; -- Stem on French words. procedure Test_Stem_French (T : in out Test) is begin T.Verify (L_FRENCH, "bonjour", "bonjour"); T.Verify (L_FRENCH, "chienne", "chien"); T.Verify (L_FRENCH, "chevalier", "chevali"); T.Verify (L_FRENCH, "échographe", "échograph"); T.Verify (L_FRENCH, "abandonnait", "abandon"); T.Verify (L_FRENCH, "affectées", "affect"); Verify (T, L_FRENCH, "regtests/files/fr-test.txt"); T.Verify (L_FRENCH, "affectionné", "affection"); T.Verify (L_FRENCH, "affectionnait", "affection"); end Test_Stem_French; -- Stem on English words. procedure Test_Stem_English (T : in out Test) is begin T.Verify (L_ENGLISH, "zealously", "zealous"); T.Verify (L_ENGLISH, "caesars", "caesar"); T.Verify (L_ENGLISH, "about", "about"); T.Verify (L_ENGLISH, "acceding", "acced"); T.Verify (L_ENGLISH, "younger", "younger"); T.Verify (L_ENGLISH, "skis", "ski"); T.Verify (L_ENGLISH, "ugly", "ugli"); T.Verify (L_ENGLISH, "dying", "die"); T.Verify (L_ENGLISH, "cosmos", "cosmos"); T.Verify (L_ENGLISH, "transitional", "transit"); T.Verify (L_ENGLISH, "academies", "academi"); T.Verify (L_ENGLISH, "abolished", "abolish"); end Test_Stem_English; -- Stem on Greek words. procedure Test_Stem_Greek (T : in out Test) is begin T.Verify (L_GREEK, "ΠΟΣΟΤΗΤΑ", "ποσοτητ"); T.Verify (L_GREEK, "ΜΝΗΜΕΙΩΔΕΣ", "μνημειωδ"); T.Verify (L_GREEK, "ΩΣΤΙΚΟ", "ωστ"); T.Verify (L_GREEK, "ΩΦΕΛΕΙ", "ωφελ"); end Test_Stem_Greek; -- Stem on Spanish words. procedure Test_Stem_Spanish (T : in out Test) is begin T.Verify (L_SPANISH, "abarcaría", "abarc"); T.Verify (L_SPANISH, "abarroteros", "abarroter"); T.Verify (L_SPANISH, "aseguramiento", "asegur"); T.Verify (L_SPANISH, "zubillaga", "zubillag"); end Test_Stem_Spanish; -- Stem on Swedish words. procedure Test_Stem_Swedish (T : in out Test) is begin T.Verify (L_SWEDISH, "ackompanjerade", "ackompanjer"); T.Verify (L_SWEDISH, "abskons", "abskon"); T.Verify (L_SWEDISH, "afhölja", "afhölj"); T.Verify (L_SWEDISH, "överändakastade", "överändakast"); end Test_Stem_Swedish; -- Stem on Russian words. procedure Test_Stem_Russian (T : in out Test) is begin T.Verify (L_RUSSIAN, "авдотьей", "авдот"); T.Verify (L_RUSSIAN, "адом", "ад"); T.Verify (L_RUSSIAN, "ячменный", "ячмен"); end Test_Stem_Russian; -- Stem on Serbian words. procedure Test_Stem_Serbian (T : in out Test) is begin T.Verify (L_SERBIAN, "abecendom", "abecend"); T.Verify (L_SERBIAN, "ocenjujući", "ocenjuj"); T.Verify (L_SERBIAN, "padobranskim", "padobransk"); end Test_Stem_Serbian; -- Stem on French words using the reference file. procedure Test_Stem_French_Reference_File (T : in out Test) is begin Verify (T, L_FRENCH, "regtests/files/fr-test.txt"); end Test_Stem_French_Reference_File; -- Stem on Spanish words using the reference file. procedure Test_Stem_Spanish_Reference_File (T : in out Test) is begin Verify (T, L_SPANISH, "regtests/files/es-test.txt"); end Test_Stem_Spanish_Reference_File; -- Stem on English words using the reference file. procedure Test_Stem_English_Reference_File (T : in out Test) is begin Verify (T, L_ENGLISH, "regtests/files/en-test.txt"); end Test_Stem_English_Reference_File; -- Stem on Swedish words using the reference file. procedure Test_Stem_Swedish_Reference_File (T : in out Test) is begin Verify (T, L_SWEDISH, "regtests/files/sv-test.txt"); end Test_Stem_Swedish_Reference_File; -- Stem on Russian words using the reference file. procedure Test_Stem_Russian_Reference_File (T : in out Test) is begin Verify (T, L_RUSSIAN, "regtests/files/ru-test.txt"); end Test_Stem_Russian_Reference_File; -- Stem on Serbian words using the reference file. procedure Test_Stem_Serbian_Reference_File (T : in out Test) is begin Verify (T, L_SERBIAN, "regtests/files/sr-test.txt"); end Test_Stem_Serbian_Reference_File; -- Stem on German words using the reference file. procedure Test_Stem_German_Reference_File (T : in out Test) is begin Verify (T, L_GERMAN, "regtests/files/gr-test.txt"); end Test_Stem_German_Reference_File; -- Stem on Italian words using the reference file. procedure Test_Stem_Italian_Reference_File (T : in out Test) is begin Verify (T, L_ITALIAN, "regtests/files/it-test.txt"); end Test_Stem_Italian_Reference_File; -- Stem on Greek words using the reference file. procedure Test_Stem_Greek_Reference_File (T : in out Test) is begin Verify (T, L_GREEK, "regtests/files/el-test.txt"); end Test_Stem_Greek_Reference_File; -- Stem on Danish words using the reference file. procedure Test_Stem_Danish_Reference_File (T : in out Test) is begin Verify (T, L_DANISH, "regtests/files/da-test.txt"); end Test_Stem_Danish_Reference_File; -- Stem on Dutch words using the reference file. procedure Test_Stem_Dutch_Reference_File (T : in out Test) is begin Verify (T, L_DUTCH, "regtests/files/nl-test.txt"); end Test_Stem_Dutch_Reference_File; -- Stem on Dutch words using the reference file. procedure Test_Stem_Catalan_Reference_File (T : in out Test) is begin Verify (T, L_CATALAN, "regtests/files/ca-test.txt"); end Test_Stem_Catalan_Reference_File; -- Stem on Basque words using the reference file. procedure Test_Stem_Basque_Reference_File (T : in out Test) is begin Verify (T, L_BASQUE, "regtests/files/eu-test.txt"); end Test_Stem_Basque_Reference_File; -- Stem on Finnish words using the reference file. procedure Test_Stem_Finnish_Reference_File (T : in out Test) is begin Verify (T, L_FINNISH, "regtests/files/fi-test.txt"); end Test_Stem_Finnish_Reference_File; -- Stem on Hindi words using the reference file. procedure Test_Stem_Hindi_Reference_File (T : in out Test) is begin Verify (T, L_HINDI, "regtests/files/hi-test.txt"); end Test_Stem_Hindi_Reference_File; -- Stem on Hungarian words using the reference file. procedure Test_Stem_Hungarian_Reference_File (T : in out Test) is begin Verify (T, L_HUNGARIAN, "regtests/files/hu-test.txt"); end Test_Stem_Hungarian_Reference_File; -- Stem on Irish words using the reference file. procedure Test_Stem_Irish_Reference_File (T : in out Test) is begin Verify (T, L_IRISH, "regtests/files/gd-ie-test.txt"); end Test_Stem_Irish_Reference_File; -- Stem on Indonesian words using the reference file. procedure Test_Stem_Indonesian_Reference_File (T : in out Test) is begin Verify (T, L_INDONESIAN, "regtests/files/id-test.txt"); end Test_Stem_Indonesian_Reference_File; -- Stem on Nepali words using the reference file. procedure Test_Stem_Nepali_Reference_File (T : in out Test) is begin Verify (T, L_NEPALI, "regtests/files/ne-test.txt"); end Test_Stem_Nepali_Reference_File; -- Stem on Norwegian words using the reference file. procedure Test_Stem_Norwegian_Reference_File (T : in out Test) is begin Verify (T, L_NORWEGIAN, "regtests/files/no-test.txt"); end Test_Stem_Norwegian_Reference_File; -- Stem on Portuguese words using the reference file. procedure Test_Stem_Portuguese_Reference_File (T : in out Test) is begin Verify (T, L_PORTUGUESE, "regtests/files/pt-test.txt"); end Test_Stem_Portuguese_Reference_File; -- Stem on Romanian words using the reference file. procedure Test_Stem_Romanian_Reference_File (T : in out Test) is begin Verify (T, L_ROMANIAN, "regtests/files/ro-test.txt"); end Test_Stem_Romanian_Reference_File; -- Stem on English Porter words using the reference file. procedure Test_Stem_Porter_Reference_File (T : in out Test) is begin Verify (T, L_PORTER, "regtests/files/en-porter-test.txt"); end Test_Stem_Porter_Reference_File; -- Stem on Tamil words using the reference file. procedure Test_Stem_Tamil_Reference_File (T : in out Test) is begin Verify (T, L_TAMIL, "regtests/files/ta-test.txt"); end Test_Stem_Tamil_Reference_File; -- Stem on Turkish words using the reference file. procedure Test_Stem_Turkish_Reference_File (T : in out Test) is begin Verify (T, L_TURKISH, "regtests/files/tr-test.txt"); end Test_Stem_Turkish_Reference_File; -- Stem on Lithuanian words using the reference file. procedure Test_Stem_Lithuanian_Reference_File (T : in out Test) is begin Verify (T, L_LITHUANIAN, "regtests/files/lt-test.txt"); end Test_Stem_Lithuanian_Reference_File; -- Stem on Arabic words using the reference file. procedure Test_Stem_Arabic_Reference_File (T : in out Test) is begin Verify (T, L_ARABIC, "regtests/files/ar-test.txt"); end Test_Stem_Arabic_Reference_File; end Stemmer.Tests;
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt -- -- Some of these definitions originate from the Matresha Project -- http://forge.ada-ru.org/matreshka -- Used with permission from Vadim Godunko <vgodunko@gmail.com> with System; with Interfaces.C.Strings; package AdaBase.Bindings.MySQL is pragma Preelaborate; package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; ------------------------ -- Type Definitions -- ------------------------ type enum_field_types is (MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24, MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_ENUM, MYSQL_TYPE_SET, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_BLOB, MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_STRING, MYSQL_TYPE_GEOMETRY); pragma Convention (C, enum_field_types); for enum_field_types use (MYSQL_TYPE_DECIMAL => 0, MYSQL_TYPE_TINY => 1, MYSQL_TYPE_SHORT => 2, MYSQL_TYPE_LONG => 3, MYSQL_TYPE_FLOAT => 4, MYSQL_TYPE_DOUBLE => 5, MYSQL_TYPE_NULL => 6, MYSQL_TYPE_TIMESTAMP => 7, MYSQL_TYPE_LONGLONG => 8, MYSQL_TYPE_INT24 => 9, MYSQL_TYPE_DATE => 10, MYSQL_TYPE_TIME => 11, MYSQL_TYPE_DATETIME => 12, MYSQL_TYPE_YEAR => 13, MYSQL_TYPE_NEWDATE => 14, MYSQL_TYPE_VARCHAR => 15, MYSQL_TYPE_BIT => 16, MYSQL_TYPE_NEWDECIMAL => 246, MYSQL_TYPE_ENUM => 247, MYSQL_TYPE_SET => 248, MYSQL_TYPE_TINY_BLOB => 249, MYSQL_TYPE_MEDIUM_BLOB => 250, MYSQL_TYPE_LONG_BLOB => 251, MYSQL_TYPE_BLOB => 252, MYSQL_TYPE_VAR_STRING => 253, MYSQL_TYPE_STRING => 254, MYSQL_TYPE_GEOMETRY => 255); -- True at least as far back as MySQL 5.1 type MYSQL_FIELD is record name : ICS.chars_ptr; org_name : ICS.chars_ptr; table : ICS.chars_ptr; org_table : ICS.chars_ptr; db : ICS.chars_ptr; catalog : ICS.chars_ptr; def : ICS.chars_ptr; length : IC.unsigned_long; max_length : IC.unsigned_long; name_length : IC.unsigned; org_name_length : IC.unsigned; table_length : IC.unsigned; org_table_length : IC.unsigned; db_length : IC.unsigned; catalog_length : IC.unsigned; def_length : IC.unsigned; flags : IC.unsigned; decimals : IC.unsigned; charsetnr : IC.unsigned; field_type : enum_field_types; extension : System.Address; end record; pragma Convention (C, MYSQL_FIELD); type MY_CHARSET_INFO is record number : IC.unsigned; state : IC.unsigned; csname : ICS.chars_ptr; name : ICS.chars_ptr; comment : ICS.chars_ptr; dir : ICS.chars_ptr; mbminlen : IC.unsigned; mbmaxlen : IC.unsigned; end record; pragma Convention (C, MY_CHARSET_INFO); type mysql_option is (MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH); pragma Convention (C, mysql_option); type enum_mysql_set_option is (MYSQL_OPTION_MULTI_STATEMENTS_ON, MYSQL_OPTION_MULTI_STATEMENTS_OFF); pragma Convention (C, enum_mysql_set_option); type client_flag_order is (CLIENT_LONG_PASSWORD, CLIENT_FOUND_ROWS, CLIENT_LONG_FLAG, CLIENT_CONNECT_WITH_DB, CLIENT_NO_SCHEMA, CLIENT_COMPRESS, CLIENT_ODBC, CLIENT_LOCAL_FILES, CLIENT_IGNORE_SPACE, CLIENT_PROTOCOL_41, CLIENT_INTERACTIVE, CLIENT_SSL, CLIENT_IGNORE_SIGPIPE, CLIENT_TRANSACTIONS, CLIENT_RESERVED, CLIENT_SECURE_CONNECTION, CLIENT_MULTI_STATEMENTS, CLIENT_MULTI_RESULTS, CLIENT_PS_MULTI_RESULTS); type MYSQL is limited private; type MYSQL_RES is limited private; type MYSQL_STMT is limited private; type MYSQL_Access is access all MYSQL; pragma Convention (C, MYSQL_Access); type MYSQL_RES_Access is access all MYSQL_RES; pragma Convention (C, MYSQL_RES_Access); type MYSQL_STMT_Access is access all MYSQL_STMT; pragma Convention (C, MYSQL_STMT_Access); type MYSQL_FIELD_Access is access all MYSQL_FIELD; pragma Convention (C, MYSQL_FIELD_Access); type MY_CHARSET_INFO_Access is access all MY_CHARSET_INFO; pragma Convention (C, MY_CHARSET_INFO_Access); type my_bool is new IC.signed_char; type my_ulong is new IC.unsigned_long; type my_uint is new IC.unsigned; type my_int is new IC.int; type my_ulonglong is mod 2 ** 64; type my_ulong_access is access all my_ulong; type block_ulong is array (Natural range <>) of my_ulong; type block_char is array (Natural range <>) of ICS.chars_ptr; type MYSQL_LEN is limited record len : block_ulong (1 .. 1); -- number is arbitrary, unchecked conv end record; type MYSQL_LEN_Access is access all MYSQL_LEN; pragma Convention (C, MYSQL_LEN_Access); type MYSQL_ROW is limited record binary : block_char (1 .. 1); -- number is arbitrary, unchecked conv end record; type MYSQL_ROW_access is access all MYSQL_ROW; pragma Convention (C, MYSQL_ROW_access); type MYSQL_BIND is limited record length : access IC.unsigned_long := null; is_null : access my_bool := null; buffer : System.Address := System.Null_Address; error : access my_bool := null; row_ptr : access IC.unsigned_char := null; store_param_func : System.Address := System.Null_Address; fetch_result : System.Address := System.Null_Address; skip_result : System.Address := System.Null_Address; buffer_length : IC.unsigned_long := 0; offset : IC.unsigned_long := 0; length_value : IC.unsigned_long := 0; param_number : IC.unsigned := 0; pack_length : IC.unsigned := 0; buffer_type : enum_field_types := MYSQL_TYPE_NULL; error_value : my_bool := 0; is_unsigned : my_bool := 0; long_data_used : my_bool := 0; is_null_value : my_bool := 0; extension : System.Address := System.Null_Address; end record; pragma Convention (C, MYSQL_BIND); type MYSQL_BIND_Array is array (Positive range <>) of aliased MYSQL_BIND; pragma Convention (C, MYSQL_BIND_Array); type MYSQL_BIND_Array_Access is access all MYSQL_BIND_Array; type enum_mysql_timestamp_type is (MYSQL_TIMESTAMP_NONE, MYSQL_TIMESTAMP_ERROR, MYSQL_TIMESTAMP_DATE, MYSQL_TIMESTAMP_DATETIME, MYSQL_TIMESTAMP_TIME); for enum_mysql_timestamp_type use (MYSQL_TIMESTAMP_NONE => -2, MYSQL_TIMESTAMP_ERROR => -1, MYSQL_TIMESTAMP_DATE => 0, MYSQL_TIMESTAMP_DATETIME => 1, MYSQL_TIMESTAMP_TIME => 2); pragma Convention (C, enum_mysql_timestamp_type); type MYSQL_TIME is record year : IC.unsigned := 0; month : IC.unsigned := 0; day : IC.unsigned := 0; hour : IC.unsigned := 0; minute : IC.unsigned := 0; second : IC.unsigned := 0; second_part : IC.unsigned_long := 0; neg : my_bool := 0; time_type : enum_mysql_timestamp_type := MYSQL_TIMESTAMP_DATETIME; end record; pragma Convention (C, MYSQL_TIME); MYSQL_NO_DATA : constant := 100; MYSQL_DATA_TRUNCATED : constant := 101; --------------------- -- Library calls -- --------------------- procedure mysql_close (handle : not null access MYSQL); pragma Import (C, mysql_close, "mysql_close"); function mysql_commit (handle : not null access MYSQL) return my_bool; pragma Import (C, mysql_commit, "mysql_commit"); function mysql_rollback (handle : not null access MYSQL) return my_bool; pragma Import (C, mysql_rollback, "mysql_rollback"); function mysql_autocommit (handle : not null access MYSQL; mode : my_bool) return my_bool; pragma Import (C, mysql_autocommit, "mysql_autocommit"); function mysql_insert_id (handle : not null access MYSQL) return my_ulonglong; pragma Import (C, mysql_insert_id, "mysql_insert_id"); function mysql_get_client_version return my_ulong; pragma Import (C, mysql_get_client_version, "mysql_get_client_version"); function mysql_get_server_version (handle : not null access MYSQL) return my_ulong; pragma Import (C, mysql_get_server_version, "mysql_get_server_version"); function mysql_get_client_info return ICS.chars_ptr; pragma Import (C, mysql_get_client_info, "mysql_get_client_info"); function mysql_get_server_info (handle : not null access MYSQL) return ICS.chars_ptr; pragma Import (C, mysql_get_server_info, "mysql_get_server_info"); function mysql_error (handle : not null access MYSQL) return ICS.chars_ptr; pragma Import (C, mysql_error, "mysql_error"); function mysql_errno (handle : not null access MYSQL) return my_uint; pragma Import (C, mysql_errno, "mysql_errno"); function mysql_sqlstate (handle : not null access MYSQL) return ICS.chars_ptr; pragma Import (C, mysql_sqlstate, "mysql_sqlstate"); function mysql_query (handle : not null access MYSQL; stmt_str : ICS.chars_ptr) return my_int; pragma Import (C, mysql_query, "mysql_query"); function mysql_real_query (handle : not null access MYSQL; stmt_str : ICS.chars_ptr; length : my_ulong) return my_int; pragma Import (C, mysql_real_query, "mysql_real_query"); function mysql_init (handle : access MYSQL) return MYSQL_Access; pragma Import (C, mysql_init, "mysql_init"); function mysql_options (handle : not null access MYSQL; option : mysql_option; arg : IC.char_array) return my_int; pragma Import (C, mysql_options, "mysql_options"); function mysql_real_connect (handle : not null access MYSQL; host : ICS.chars_ptr; user : ICS.chars_ptr; passwd : ICS.chars_ptr; db : ICS.chars_ptr; port : my_uint; unix_socket : ICS.chars_ptr; client_flag : my_ulong) return MYSQL_Access; pragma Import (C, mysql_real_connect, "mysql_real_connect"); procedure mysql_free_result (handle : not null access MYSQL_RES); pragma Import (C, mysql_free_result, "mysql_free_result"); function mysql_use_result (handle : not null access MYSQL) return MYSQL_RES_Access; pragma Import (C, mysql_use_result, "mysql_use_result"); function mysql_store_result (handle : not null access MYSQL) return MYSQL_RES_Access; pragma Import (C, mysql_store_result, "mysql_store_result"); function mysql_field_count (handle : not null access MYSQL) return my_uint; pragma Import (C, mysql_field_count, "mysql_field_count"); function mysql_num_fields (handle : not null access MYSQL_RES) return my_uint; pragma Import (C, mysql_num_fields, "mysql_num_fields"); function mysql_num_rows (handle : not null access MYSQL_RES) return my_ulonglong; pragma Import (C, mysql_num_rows, "mysql_num_rows"); function mysql_affected_rows (handle : not null access MYSQL) return my_ulonglong; pragma Import (C, mysql_affected_rows, "mysql_affected_rows"); function mysql_fetch_field (handle : not null access MYSQL_RES) return MYSQL_FIELD_Access; pragma Import (C, mysql_fetch_field, "mysql_fetch_field"); function mysql_fetch_row (handle : not null access MYSQL_RES) return MYSQL_ROW_access; pragma Import (C, mysql_fetch_row, "mysql_fetch_row"); function mysql_fetch_lengths (result : not null access MYSQL_RES) return my_ulong_access; pragma Import (C, mysql_fetch_lengths, "mysql_fetch_lengths"); function mysql_next_result (handle : not null access MYSQL) return my_int; pragma Import (C, mysql_next_result, "mysql_next_result"); procedure mysql_get_character_set_info (handle : not null access MYSQL; cs : access MY_CHARSET_INFO); pragma Import (C, mysql_get_character_set_info, "mysql_get_character_set_info"); function mysql_character_set_name (handle : not null access MYSQL) return ICS.chars_ptr; pragma Import (C, mysql_character_set_name); function mysql_set_character_set (handle : not null access MYSQL; csname : ICS.chars_ptr) return my_int; pragma Import (C, mysql_set_character_set); function mysql_set_server_option (handle : not null access MYSQL; option : enum_mysql_set_option) return my_int; pragma Import (C, mysql_set_server_option, "mysql_set_server_option"); ------------------------------------ -- Prepared Statement functions -- ------------------------------------ function mysql_stmt_init (handle : not null access MYSQL) return MYSQL_STMT_Access; pragma Import (C, mysql_stmt_init, "mysql_stmt_init"); function mysql_stmt_close (handle : not null access MYSQL_STMT) return my_bool; pragma Import (C, mysql_stmt_close, "mysql_stmt_close"); function mysql_stmt_param_count (handle : not null access MYSQL_STMT) return my_ulong; pragma Import (C, mysql_stmt_param_count, "mysql_stmt_param_count"); function mysql_stmt_insert_id (handle : not null access MYSQL_STMT) return my_ulonglong; pragma Import (C, mysql_stmt_insert_id, "mysql_stmt_insert_id"); function mysql_stmt_sqlstate (handle : not null access MYSQL_STMT) return ICS.chars_ptr; pragma Import (C, mysql_stmt_sqlstate, "mysql_stmt_sqlstate"); function mysql_stmt_errno (handle : not null access MYSQL_STMT) return my_uint; pragma Import (C, mysql_stmt_errno, "mysql_stmt_errno"); function mysql_stmt_error (handle : not null access MYSQL_STMT) return ICS.chars_ptr; pragma Import (C, mysql_stmt_error, "mysql_stmt_error"); function mysql_stmt_free_result (handle : not null access MYSQL_STMT) return my_bool; pragma Import (C, mysql_stmt_free_result, "mysql_stmt_free_result"); function mysql_stmt_store_result (handle : not null access MYSQL_STMT) return my_int; pragma Import (C, mysql_stmt_store_result, "mysql_stmt_store_result"); function mysql_stmt_prepare (handle : not null access MYSQL_STMT; stmt_str : ICS.chars_ptr; length : my_ulong) return my_int; pragma Import (C, mysql_stmt_prepare, "mysql_stmt_prepare"); function mysql_stmt_result_metadata (handle : not null access MYSQL_STMT) return MYSQL_RES_Access; pragma Import (C, mysql_stmt_result_metadata, "mysql_stmt_result_metadata"); function mysql_stmt_bind_param (handle : not null access MYSQL_STMT; bind : access MYSQL_BIND) return my_bool; pragma Import (C, mysql_stmt_bind_param, "mysql_stmt_bind_param"); function mysql_stmt_bind_result (handle : not null access MYSQL_STMT; bind : access MYSQL_BIND) return my_bool; pragma Import (C, mysql_stmt_bind_result, "mysql_stmt_bind_result"); function mysql_stmt_execute (handle : not null access MYSQL_STMT) return IC.int; pragma Import (C, mysql_stmt_execute, "mysql_stmt_execute"); function mysql_stmt_num_rows (handle : not null access MYSQL_STMT) return my_ulonglong; pragma Import (C, mysql_stmt_num_rows, "mysql_stmt_num_rows"); function mysql_stmt_affected_rows (handle : not null access MYSQL_STMT) return my_ulonglong; pragma Import (C, mysql_stmt_affected_rows, "mysql_stmt_affected_rows"); function mysql_stmt_field_count (handle : not null access MYSQL_STMT) return my_uint; pragma Import (C, mysql_stmt_field_count, "mysql_stmt_field_count"); function mysql_stmt_fetch (handle : not null access MYSQL_STMT) return my_int; pragma Import (C, mysql_stmt_fetch, "mysql_stmt_fetch"); private type MYSQL is limited null record; type MYSQL_RES is limited null record; type MYSQL_STMT is limited null record; end AdaBase.Bindings.MySQL;
with Asynchronous_Fifo; with Ada.Text_Io; use Ada.Text_Io; procedure Asynchronous_Fifo_Test is package Int_Fifo is new Asynchronous_Fifo(Integer); use Int_Fifo; Buffer : Fifo; task Writer is entry Stop; end Writer; task body Writer is Val : Positive := 1; begin loop select accept Stop; exit; else Buffer.Push(Val); Val := Val + 1; end select; end loop; end Writer; task Reader is entry Stop; end Reader; task body Reader is Val : Positive; begin loop select accept Stop; exit; else Buffer.Pop(Val); Put_Line(Integer'Image(Val)); end select; end loop; end Reader; begin delay 0.1; Writer.Stop; Reader.Stop; end Asynchronous_Fifo_Test;
package Loop_Optimization8_Pkg2 is type Array_T is array (Natural range <>) of Integer; type Obj_T (Length : Natural) is record Elements : Array_T (1 .. Length); end record; type T is access Obj_T; function Length (Set : T) return Natural; function Index (Set : T; Position : Natural) return Integer; pragma Inline (Length, Index); end Loop_Optimization8_Pkg2;
package Giza.Bitmap_Fonts.FreeSerifBold12pt7b is Font : constant Giza.Font.Ref_Const; private FreeSerifBold12pt7bBitmaps : aliased constant Font_Bitmap := ( 16#7F#, 16#FF#, 16#77#, 16#66#, 16#22#, 16#00#, 16#6F#, 16#F7#, 16#E3#, 16#F1#, 16#F8#, 16#FC#, 16#7E#, 16#3A#, 16#09#, 16#04#, 16#0C#, 16#40#, 16#CC#, 16#0C#, 16#C0#, 16#8C#, 16#18#, 16#C7#, 16#FF#, 16#18#, 16#C1#, 16#88#, 16#19#, 16#81#, 16#18#, 16#FF#, 16#E3#, 16#18#, 16#31#, 16#83#, 16#18#, 16#33#, 16#03#, 16#30#, 16#08#, 16#01#, 16#00#, 16#FC#, 16#24#, 16#EC#, 16#8D#, 16#90#, 16#BA#, 16#07#, 16#C0#, 16#7E#, 16#07#, 16#F0#, 16#7F#, 16#07#, 16#F0#, 16#9F#, 16#11#, 16#E2#, 16#3E#, 16#46#, 16#E9#, 16#C7#, 16#C0#, 16#20#, 16#04#, 16#00#, 16#1E#, 16#0C#, 16#0E#, 16#7F#, 16#07#, 16#10#, 16#83#, 16#C4#, 16#40#, 16#E1#, 16#30#, 16#38#, 16#88#, 16#0E#, 16#26#, 16#03#, 16#91#, 16#1E#, 16#78#, 16#8E#, 16#40#, 16#27#, 16#10#, 16#11#, 16#C4#, 16#0C#, 16#E1#, 16#02#, 16#38#, 16#81#, 16#0E#, 16#20#, 16#43#, 16#90#, 16#20#, 16#78#, 16#03#, 16#E0#, 16#01#, 16#9E#, 16#00#, 16#E3#, 16#80#, 16#38#, 16#E0#, 16#0F#, 16#30#, 16#03#, 16#F0#, 16#00#, 16#78#, 16#7C#, 16#1F#, 16#06#, 16#1B#, 16#E1#, 16#1C#, 16#7C#, 16#8F#, 16#1F#, 16#23#, 16#C3#, 16#F0#, 16#F8#, 16#7C#, 16#3E#, 16#0F#, 16#97#, 16#C7#, 16#FC#, 16#FE#, 16#3E#, 16#FF#, 16#FE#, 16#90#, 16#00#, 16#31#, 16#0C#, 16#31#, 16#86#, 16#38#, 16#E3#, 16#8E#, 16#38#, 16#E3#, 16#86#, 16#18#, 16#60#, 16#C1#, 16#02#, 16#04#, 16#03#, 16#06#, 16#0C#, 16#30#, 16#61#, 16#87#, 16#1C#, 16#71#, 16#C7#, 16#1C#, 16#71#, 16#86#, 16#38#, 16#C2#, 16#10#, 16#80#, 16#1C#, 16#6E#, 16#FA#, 16#EF#, 16#F1#, 16#C7#, 16#FF#, 16#AF#, 16#BB#, 16#1C#, 16#04#, 16#00#, 16#06#, 16#00#, 16#60#, 16#06#, 16#00#, 16#60#, 16#06#, 16#0F#, 16#FF#, 16#FF#, 16#F0#, 16#60#, 16#06#, 16#00#, 16#60#, 16#06#, 16#00#, 16#60#, 16#6F#, 16#F7#, 16#11#, 16#24#, 16#FF#, 16#FF#, 16#C0#, 16#6F#, 16#F6#, 16#03#, 16#02#, 16#06#, 16#06#, 16#0C#, 16#0C#, 16#0C#, 16#18#, 16#18#, 16#18#, 16#30#, 16#30#, 16#30#, 16#60#, 16#60#, 16#60#, 16#C0#, 16#0E#, 16#07#, 16#71#, 16#C7#, 16#38#, 16#EF#, 16#1D#, 16#E3#, 16#FC#, 16#7F#, 16#8F#, 16#F1#, 16#FE#, 16#3F#, 16#C7#, 16#F8#, 16#F7#, 16#1C#, 16#E3#, 16#8E#, 16#E0#, 16#F8#, 16#06#, 16#0F#, 16#1F#, 16#83#, 16#C1#, 16#E0#, 16#F0#, 16#78#, 16#3C#, 16#1E#, 16#0F#, 16#07#, 16#83#, 16#C1#, 16#E0#, 16#F0#, 16#F9#, 16#FF#, 16#0F#, 16#03#, 16#FC#, 16#7F#, 16#C4#, 16#3E#, 16#01#, 16#E0#, 16#1E#, 16#01#, 16#E0#, 16#1C#, 16#03#, 16#80#, 16#30#, 16#06#, 16#00#, 16#C1#, 16#18#, 16#13#, 16#FE#, 16#7F#, 16#EF#, 16#FE#, 16#1F#, 16#0C#, 16#FA#, 16#0F#, 16#01#, 16#E0#, 16#38#, 16#0E#, 16#03#, 16#E0#, 16#3E#, 16#03#, 16#E0#, 16#3C#, 16#03#, 16#80#, 16#70#, 16#0D#, 16#C1#, 16#BC#, 16#43#, 16#F0#, 16#03#, 16#80#, 16#E0#, 16#78#, 16#3E#, 16#17#, 16#89#, 16#E2#, 16#79#, 16#1E#, 16#87#, 16#A1#, 16#EF#, 16#FF#, 16#FF#, 16#FF#, 16#C1#, 16#E0#, 16#78#, 16#1E#, 16#3F#, 16#E7#, 16#F8#, 16#FF#, 16#10#, 16#04#, 16#00#, 16#F8#, 16#1F#, 16#C7#, 16#FC#, 16#1F#, 16#C0#, 16#78#, 16#07#, 16#00#, 16#60#, 16#0D#, 16#C1#, 16#3C#, 16#43#, 16#F0#, 16#00#, 16#E0#, 16#F0#, 16#38#, 16#1E#, 16#07#, 16#80#, 16#F0#, 16#3F#, 16#E7#, 16#9E#, 16#F1#, 16#FE#, 16#3F#, 16#C7#, 16#F8#, 16#F7#, 16#1E#, 16#E3#, 16#8E#, 16#60#, 16#F8#, 16#7F#, 16#EF#, 16#FD#, 16#FF#, 16#A0#, 16#68#, 16#0C#, 16#01#, 16#00#, 16#60#, 16#0C#, 16#03#, 16#00#, 16#60#, 16#0C#, 16#03#, 16#00#, 16#60#, 16#1C#, 16#03#, 16#00#, 16#60#, 16#1F#, 16#0E#, 16#73#, 16#87#, 16#70#, 16#EF#, 16#1D#, 16#F3#, 16#1F#, 16#81#, 16#F8#, 16#1F#, 16#CC#, 16#FB#, 16#8F#, 16#F0#, 16#FE#, 16#1F#, 16#C3#, 16#9C#, 16#F1#, 16#F8#, 16#1F#, 16#06#, 16#71#, 16#C7#, 16#78#, 16#EF#, 16#1F#, 16#E3#, 16#FC#, 16#7F#, 16#8F#, 16#79#, 16#E7#, 16#FC#, 16#0F#, 16#01#, 16#C0#, 16#78#, 16#1C#, 16#0F#, 16#07#, 16#00#, 16#6F#, 16#F6#, 16#00#, 16#06#, 16#FF#, 16#60#, 16#6F#, 16#F6#, 16#00#, 16#06#, 16#FF#, 16#71#, 16#22#, 16#C0#, 16#00#, 16#04#, 16#00#, 16#70#, 16#07#, 16#C0#, 16#FC#, 16#0F#, 16#80#, 16#F8#, 16#0F#, 16#80#, 16#1F#, 16#00#, 16#1F#, 16#00#, 16#1F#, 16#00#, 16#1F#, 16#00#, 16#1F#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#FF#, 16#FF#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#FF#, 16#FF#, 16#00#, 16#03#, 16#80#, 16#0F#, 16#80#, 16#0F#, 16#80#, 16#0F#, 16#80#, 16#0F#, 16#80#, 16#0F#, 16#80#, 16#1F#, 16#01#, 16#F0#, 16#1F#, 16#03#, 16#F0#, 16#3E#, 16#00#, 16#E0#, 16#02#, 16#00#, 16#00#, 16#3E#, 16#11#, 16#EC#, 16#3F#, 16#8F#, 16#E3#, 16#C0#, 16#F0#, 16#78#, 16#18#, 16#08#, 16#02#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#07#, 16#81#, 16#E0#, 16#30#, 16#03#, 16#F0#, 16#0E#, 16#18#, 16#18#, 16#04#, 16#30#, 16#66#, 16#70#, 16#DB#, 16#61#, 16#99#, 16#E3#, 16#19#, 16#E3#, 16#31#, 16#E6#, 16#31#, 16#E6#, 16#31#, 16#E6#, 16#F2#, 16#66#, 16#B2#, 16#73#, 16#3C#, 16#38#, 16#00#, 16#1E#, 16#04#, 16#03#, 16#F8#, 16#00#, 16#80#, 16#00#, 16#60#, 16#00#, 16#70#, 16#00#, 16#38#, 16#00#, 16#3E#, 16#00#, 16#1F#, 16#00#, 16#1B#, 16#C0#, 16#09#, 16#E0#, 16#04#, 16#F8#, 16#04#, 16#3C#, 16#02#, 16#1F#, 16#03#, 16#FF#, 16#81#, 16#03#, 16#C1#, 16#80#, 16#F0#, 16#80#, 16#7D#, 16#F0#, 16#FF#, 16#FF#, 16#C0#, 16#F3#, 16#C3#, 16#C7#, 16#8F#, 16#1E#, 16#3C#, 16#78#, 16#F1#, 16#E3#, 16#CE#, 16#0F#, 16#F0#, 16#3C#, 16#70#, 16#F0#, 16#E3#, 16#C3#, 16#CF#, 16#0F#, 16#3C#, 16#3C#, 16#F0#, 16#E3#, 16#C7#, 16#BF#, 16#F8#, 16#07#, 16#E2#, 16#38#, 16#7C#, 16#E0#, 16#3B#, 16#C0#, 16#37#, 16#00#, 16#7E#, 16#00#, 16#7C#, 16#00#, 16#78#, 16#00#, 16#F0#, 16#01#, 16#E0#, 16#03#, 16#C0#, 16#03#, 16#80#, 16#07#, 16#80#, 16#27#, 16#00#, 16#C7#, 16#86#, 16#03#, 16#F0#, 16#FF#, 16#E0#, 16#1E#, 16#1E#, 16#0F#, 16#07#, 16#87#, 16#81#, 16#E3#, 16#C0#, 16#F1#, 16#E0#, 16#3C#, 16#F0#, 16#1E#, 16#78#, 16#0F#, 16#3C#, 16#07#, 16#9E#, 16#03#, 16#CF#, 16#01#, 16#E7#, 16#80#, 16#E3#, 16#C0#, 16#F1#, 16#E0#, 16#F0#, 16#F0#, 16#E1#, 16#FF#, 16#C0#, 16#FF#, 16#FC#, 16#78#, 16#38#, 16#F0#, 16#31#, 16#E0#, 16#23#, 16#C4#, 16#07#, 16#88#, 16#0F#, 16#30#, 16#1F#, 16#E0#, 16#3C#, 16#C0#, 16#78#, 16#80#, 16#F1#, 16#01#, 16#E0#, 16#23#, 16#C0#, 16#47#, 16#81#, 16#8F#, 16#07#, 16#7F#, 16#FE#, 16#FF#, 16#FC#, 16#F0#, 16#73#, 16#C0#, 16#CF#, 16#01#, 16#3C#, 16#40#, 16#F1#, 16#03#, 16#CC#, 16#0F#, 16#F0#, 16#3C#, 16#C0#, 16#F1#, 16#03#, 16#C4#, 16#0F#, 16#00#, 16#3C#, 16#00#, 16#F0#, 16#03#, 16#C0#, 16#3F#, 16#C0#, 16#07#, 16#E2#, 16#1C#, 16#3E#, 16#38#, 16#0E#, 16#78#, 16#06#, 16#70#, 16#06#, 16#F0#, 16#00#, 16#F0#, 16#00#, 16#F0#, 16#00#, 16#F0#, 16#00#, 16#F0#, 16#7F#, 16#F0#, 16#1E#, 16#70#, 16#1E#, 16#78#, 16#1E#, 16#38#, 16#1E#, 16#1E#, 16#1E#, 16#07#, 16#F0#, 16#FE#, 16#FF#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#7F#, 16#FC#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#78#, 16#3C#, 16#FE#, 16#FF#, 16#FF#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#FF#, 16#0F#, 16#F0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#03#, 16#C0#, 16#3C#, 16#E3#, 16#CE#, 16#38#, 16#E3#, 16#83#, 16#E0#, 16#FE#, 16#7F#, 16#3C#, 16#0E#, 16#1E#, 16#04#, 16#0F#, 16#04#, 16#07#, 16#84#, 16#03#, 16#CC#, 16#01#, 16#EE#, 16#00#, 16#FF#, 16#00#, 16#7F#, 16#C0#, 16#3D#, 16#F0#, 16#1E#, 16#7C#, 16#0F#, 16#1F#, 16#07#, 16#87#, 16#C3#, 16#C1#, 16#F1#, 16#E0#, 16#7D#, 16#FC#, 16#FF#, 16#FE#, 16#01#, 16#E0#, 16#07#, 16#80#, 16#1E#, 16#00#, 16#78#, 16#01#, 16#E0#, 16#07#, 16#80#, 16#1E#, 16#00#, 16#78#, 16#01#, 16#E0#, 16#07#, 16#80#, 16#1E#, 16#01#, 16#78#, 16#0D#, 16#E0#, 16#67#, 16#83#, 16#BF#, 16#FE#, 16#FC#, 16#01#, 16#F3#, 16#C0#, 16#3E#, 16#3E#, 16#03#, 16#E3#, 16#E0#, 16#5E#, 16#2F#, 16#05#, 16#E2#, 16#F0#, 16#5E#, 16#27#, 16#09#, 16#E2#, 16#78#, 16#9E#, 16#27#, 16#91#, 16#E2#, 16#3D#, 16#1E#, 16#23#, 16#E1#, 16#E2#, 16#1E#, 16#1E#, 16#21#, 16#E1#, 16#E2#, 16#0C#, 16#1E#, 16#20#, 16#C1#, 16#EF#, 16#88#, 16#3F#, 16#F8#, 16#1E#, 16#F8#, 16#18#, 16#F8#, 16#11#, 16#F8#, 16#22#, 16#F8#, 16#45#, 16#F0#, 16#89#, 16#F1#, 16#11#, 16#F2#, 16#21#, 16#F4#, 16#41#, 16#F8#, 16#81#, 16#F1#, 16#01#, 16#E2#, 16#03#, 16#C4#, 16#03#, 16#8C#, 16#03#, 16#7C#, 16#02#, 16#07#, 16#F0#, 16#0F#, 16#1E#, 16#0E#, 16#03#, 16#8F#, 16#01#, 16#E7#, 16#00#, 16#77#, 16#80#, 16#3F#, 16#C0#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#07#, 16#F8#, 16#03#, 16#FC#, 16#01#, 16#EE#, 16#00#, 16#E7#, 16#80#, 16#F1#, 16#C0#, 16#70#, 16#70#, 16#70#, 16#0F#, 16#E0#, 16#FF#, 16#87#, 16#9E#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#F7#, 16#9E#, 16#7F#, 16#87#, 16#80#, 16#78#, 16#07#, 16#80#, 16#78#, 16#07#, 16#80#, 16#78#, 16#0F#, 16#E0#, 16#07#, 16#F0#, 16#0F#, 16#1E#, 16#0E#, 16#07#, 16#8F#, 16#01#, 16#E7#, 16#00#, 16#F7#, 16#80#, 16#3F#, 16#C0#, 16#1F#, 16#E0#, 16#0F#, 16#F0#, 16#07#, 16#F8#, 16#03#, 16#FC#, 16#01#, 16#EE#, 16#00#, 16#E7#, 16#00#, 16#F1#, 16#C0#, 16#70#, 16#70#, 16#70#, 16#1C#, 16#F0#, 16#03#, 16#E0#, 16#01#, 16#F8#, 16#00#, 16#3E#, 16#00#, 16#07#, 16#E0#, 16#FF#, 16#E0#, 16#3C#, 16#78#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#3C#, 16#38#, 16#3C#, 16#70#, 16#3F#, 16#C0#, 16#3D#, 16#E0#, 16#3C#, 16#F0#, 16#3C#, 16#F8#, 16#3C#, 16#78#, 16#3C#, 16#3C#, 16#3C#, 16#3E#, 16#FF#, 16#1F#, 16#1F#, 16#27#, 16#0E#, 16#60#, 16#6E#, 16#06#, 16#F0#, 16#2F#, 16#80#, 16#7F#, 16#07#, 16#FC#, 16#1F#, 16#E0#, 16#7E#, 16#01#, 16#F8#, 16#07#, 16#C0#, 16#7C#, 16#06#, 16#F0#, 16#C9#, 16#F8#, 16#FF#, 16#FF#, 16#C7#, 16#9F#, 16#0F#, 16#1C#, 16#1E#, 16#10#, 16#3C#, 16#00#, 16#78#, 16#00#, 16#F0#, 16#01#, 16#E0#, 16#03#, 16#C0#, 16#07#, 16#80#, 16#0F#, 16#00#, 16#1E#, 16#00#, 16#3C#, 16#00#, 16#78#, 16#00#, 16#F0#, 16#07#, 16#F8#, 16#FE#, 16#1E#, 16#F0#, 16#09#, 16#E0#, 16#13#, 16#C0#, 16#27#, 16#80#, 16#4F#, 16#00#, 16#9E#, 16#01#, 16#3C#, 16#02#, 16#78#, 16#04#, 16#F0#, 16#09#, 16#E0#, 16#13#, 16#C0#, 16#27#, 16#80#, 16#47#, 16#81#, 16#07#, 16#84#, 16#07#, 16#F0#, 16#FF#, 16#0F#, 16#9E#, 16#03#, 16#0F#, 16#00#, 16#83#, 16#C0#, 16#81#, 16#E0#, 16#40#, 16#F8#, 16#20#, 16#3C#, 16#20#, 16#1E#, 16#10#, 16#07#, 16#90#, 16#03#, 16#C8#, 16#00#, 16#F4#, 16#00#, 16#7C#, 16#00#, 16#3E#, 16#00#, 16#0E#, 16#00#, 16#07#, 16#00#, 16#01#, 16#00#, 16#00#, 16#80#, 16#00#, 16#FE#, 16#7F#, 16#9E#, 16#F8#, 16#3C#, 16#08#, 16#F0#, 16#78#, 16#11#, 16#E0#, 16#F0#, 16#41#, 16#E0#, 16#F0#, 16#83#, 16#C3#, 16#E1#, 16#07#, 16#87#, 16#C4#, 16#07#, 16#93#, 16#C8#, 16#0F#, 16#27#, 16#B0#, 16#0E#, 16#47#, 16#40#, 16#1F#, 16#0F#, 16#80#, 16#3E#, 16#1F#, 16#00#, 16#38#, 16#1C#, 16#00#, 16#70#, 16#38#, 16#00#, 16#C0#, 16#30#, 16#00#, 16#80#, 16#40#, 16#FF#, 16#9F#, 16#9F#, 16#07#, 16#0F#, 16#83#, 16#03#, 16#E3#, 16#00#, 16#F9#, 16#00#, 16#3D#, 16#00#, 16#1F#, 16#00#, 16#07#, 16#C0#, 16#01#, 16#E0#, 16#00#, 16#F8#, 16#00#, 16#BE#, 16#00#, 16#8F#, 16#00#, 16#83#, 16#C0#, 16#C1#, 16#F0#, 16#E0#, 16#FD#, 16#F8#, 16#FF#, 16#FF#, 16#1F#, 16#7C#, 16#06#, 16#3C#, 16#04#, 16#3E#, 16#0C#, 16#1E#, 16#08#, 16#1F#, 16#10#, 16#0F#, 16#30#, 16#07#, 16#A0#, 16#07#, 16#C0#, 16#03#, 16#C0#, 16#03#, 16#C0#, 16#03#, 16#C0#, 16#03#, 16#C0#, 16#03#, 16#C0#, 16#03#, 16#C0#, 16#0F#, 16#F0#, 16#7F#, 16#FC#, 16#E0#, 16#F1#, 16#83#, 16#E2#, 16#07#, 16#84#, 16#1E#, 16#00#, 16#7C#, 16#00#, 16#F0#, 16#03#, 16#C0#, 16#0F#, 16#80#, 16#1E#, 16#00#, 16#7C#, 16#08#, 16#F0#, 16#13#, 16#C0#, 16#6F#, 16#81#, 16#9E#, 16#07#, 16#7F#, 16#FE#, 16#FF#, 16#39#, 16#CE#, 16#73#, 16#9C#, 16#E7#, 16#39#, 16#CE#, 16#73#, 16#9C#, 16#E7#, 16#39#, 16#F0#, 16#C0#, 16#E0#, 16#60#, 16#60#, 16#70#, 16#30#, 16#38#, 16#38#, 16#18#, 16#1C#, 16#1C#, 16#0C#, 16#0E#, 16#06#, 16#06#, 16#07#, 16#03#, 16#F9#, 16#CE#, 16#73#, 16#9C#, 16#E7#, 16#39#, 16#CE#, 16#73#, 16#9C#, 16#E7#, 16#39#, 16#CF#, 16#F0#, 16#0C#, 16#07#, 16#81#, 16#E0#, 16#CC#, 16#33#, 16#18#, 16#66#, 16#1B#, 16#87#, 16#C0#, 16#C0#, 16#FF#, 16#F0#, 16#C7#, 16#1C#, 16#30#, 16#1F#, 16#0E#, 16#71#, 16#CF#, 16#39#, 16#E0#, 16#3C#, 16#1F#, 16#8E#, 16#F3#, 16#9E#, 16#F3#, 16#DE#, 16#79#, 16#FF#, 16#80#, 16#F8#, 16#07#, 16#80#, 16#78#, 16#07#, 16#80#, 16#78#, 16#07#, 16#B8#, 16#7D#, 16#E7#, 16#8E#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#F7#, 16#8E#, 16#79#, 16#C4#, 16#78#, 16#1F#, 16#1D#, 16#DC#, 16#FE#, 16#7F#, 16#07#, 16#83#, 16#C1#, 16#E0#, 16#78#, 16#3C#, 16#47#, 16#C0#, 16#03#, 16#E0#, 16#1E#, 16#01#, 16#E0#, 16#1E#, 16#01#, 16#E1#, 16#DE#, 16#7B#, 16#E7#, 16#1E#, 16#F1#, 16#EF#, 16#1E#, 16#F1#, 16#EF#, 16#1E#, 16#F1#, 16#E7#, 16#1E#, 16#7B#, 16#E1#, 16#DF#, 16#1F#, 16#0C#, 16#67#, 16#1B#, 16#C7#, 16#FF#, 16#FC#, 16#0F#, 16#03#, 16#C0#, 16#78#, 16#4E#, 16#21#, 16#F0#, 16#1E#, 16#3B#, 16#7B#, 16#78#, 16#78#, 16#FC#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#FC#, 16#3E#, 16#0E#, 16#7F#, 16#CE#, 16#79#, 16#EF#, 16#3C#, 16#E7#, 16#0F#, 16#C1#, 16#00#, 16#60#, 16#1C#, 16#03#, 16#FE#, 16#7F#, 16#E3#, 16#FF#, 16#80#, 16#F0#, 16#33#, 16#FC#, 16#F8#, 16#07#, 16#80#, 16#78#, 16#07#, 16#80#, 16#78#, 16#07#, 16#B8#, 16#7D#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#EF#, 16#FF#, 16#31#, 16#E7#, 16#8C#, 16#03#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#BF#, 16#06#, 16#0F#, 16#0F#, 16#06#, 16#00#, 16#1F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#0F#, 16#CF#, 16#CE#, 16#7C#, 16#F8#, 16#03#, 16#C0#, 16#1E#, 16#00#, 16#F0#, 16#07#, 16#80#, 16#3C#, 16#F9#, 16#E1#, 16#8F#, 16#10#, 16#79#, 16#03#, 16#D8#, 16#1F#, 16#E0#, 16#F7#, 16#87#, 16#9E#, 16#3C#, 16#71#, 16#E3#, 16#DF#, 16#BF#, 16#F9#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#BF#, 16#FB#, 16#CF#, 16#0F#, 16#BE#, 16#79#, 16#E7#, 16#8F#, 16#3C#, 16#F1#, 16#E7#, 16#9E#, 16#3C#, 16#F3#, 16#C7#, 16#9E#, 16#78#, 16#F3#, 16#CF#, 16#1E#, 16#79#, 16#E3#, 16#CF#, 16#3C#, 16#7B#, 16#FF#, 16#DF#, 16#80#, 16#FB#, 16#87#, 16#DE#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#FF#, 16#F0#, 16#1F#, 16#07#, 16#71#, 16#C7#, 16#78#, 16#FF#, 16#1F#, 16#E3#, 16#FC#, 16#7F#, 16#8F#, 16#71#, 16#C7#, 16#70#, 16#7C#, 16#00#, 16#FB#, 16#87#, 16#DE#, 16#78#, 16#E7#, 16#8F#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#F7#, 16#8F#, 16#78#, 16#E7#, 16#9E#, 16#7F#, 16#87#, 16#80#, 16#78#, 16#07#, 16#80#, 16#78#, 16#0F#, 16#C0#, 16#1E#, 16#23#, 16#9E#, 16#71#, 16#EF#, 16#1E#, 16#F1#, 16#EF#, 16#1E#, 16#F1#, 16#EF#, 16#1E#, 16#71#, 16#E7#, 16#9E#, 16#1F#, 16#E0#, 16#1E#, 16#01#, 16#E0#, 16#1E#, 16#01#, 16#E0#, 16#3F#, 16#F9#, 16#DF#, 16#F7#, 16#DD#, 16#E0#, 16#78#, 16#1E#, 16#07#, 16#81#, 16#E0#, 16#78#, 16#1E#, 16#0F#, 16#C0#, 16#3D#, 16#43#, 16#C3#, 16#E0#, 16#FC#, 16#7E#, 16#1F#, 16#87#, 16#83#, 16#C2#, 16#BC#, 16#08#, 16#18#, 16#38#, 16#78#, 16#FC#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#78#, 16#79#, 16#3E#, 16#FB#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#79#, 16#E7#, 16#9E#, 16#3F#, 16#F0#, 16#FC#, 16#EF#, 16#08#, 16#E1#, 16#1E#, 16#41#, 16#C8#, 16#3E#, 16#03#, 16#C0#, 16#78#, 16#0E#, 16#00#, 16#C0#, 16#10#, 16#00#, 16#FD#, 16#F7#, 16#BC#, 16#71#, 16#9E#, 16#38#, 16#87#, 16#1E#, 16#43#, 16#CF#, 16#40#, 16#EB#, 16#A0#, 16#7C#, 16#F0#, 16#1C#, 16#70#, 16#0E#, 16#38#, 16#06#, 16#08#, 16#01#, 16#04#, 16#00#, 16#FC#, 16#F7#, 16#84#, 16#3C#, 16#81#, 16#F0#, 16#0F#, 16#00#, 16#F0#, 16#0F#, 16#80#, 16#BC#, 16#13#, 16#C2#, 16#1E#, 16#FB#, 16#F0#, 16#FC#, 16#EF#, 16#08#, 16#E1#, 16#1E#, 16#43#, 16#C8#, 16#3A#, 16#07#, 16#C0#, 16#78#, 16#0E#, 16#01#, 16#C0#, 16#18#, 16#02#, 16#00#, 16#41#, 16#C8#, 16#3A#, 16#03#, 16#80#, 16#FF#, 16#B1#, 16#E8#, 16#70#, 16#3C#, 16#1E#, 16#07#, 16#83#, 16#C1#, 16#E0#, 16#78#, 16#BC#, 16#2F#, 16#F8#, 16#07#, 16#0E#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#E0#, 16#18#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1C#, 16#1E#, 16#07#, 16#FF#, 16#FF#, 16#FF#, 16#FF#, 16#C0#, 16#E0#, 16#70#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#18#, 16#07#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#38#, 16#70#, 16#E0#, 16#70#, 16#1F#, 16#8B#, 16#3F#, 16#01#, 16#C0#); FreeSerifBold12pt7bGlyphs : aliased constant Glyph_Array := ( (0, 0, 0, 6, 0, 1), -- 0x20 ' ' (0, 4, 16, 8, 2, -15), -- 0x21 '!' (8, 9, 7, 13, 2, -15), -- 0x22 '"' (16, 12, 16, 12, 0, -15), -- 0x23 '#' (40, 11, 20, 12, 1, -17), -- 0x24 '$' (68, 18, 16, 24, 3, -15), -- 0x25 '%' (104, 18, 16, 20, 1, -15), -- 0x26 '&' (140, 3, 7, 7, 2, -15), -- 0x27 ''' (143, 6, 21, 8, 1, -16), -- 0x28 '(' (159, 6, 21, 8, 1, -16), -- 0x29 ')' (175, 9, 10, 12, 2, -15), -- 0x2A '*' (187, 12, 12, 16, 2, -11), -- 0x2B '+' (205, 4, 8, 6, 1, -3), -- 0x2C ',' (209, 6, 3, 8, 1, -6), -- 0x2D '-' (212, 4, 4, 6, 1, -3), -- 0x2E '.' (214, 8, 17, 7, -1, -15), -- 0x2F '/' (231, 11, 16, 12, 1, -15), -- 0x30 '0' (253, 9, 16, 12, 1, -15), -- 0x31 '1' (271, 12, 16, 12, 0, -15), -- 0x32 '2' (295, 11, 16, 12, 1, -15), -- 0x33 '3' (317, 10, 16, 12, 1, -15), -- 0x34 '4' (337, 11, 16, 12, 1, -15), -- 0x35 '5' (359, 11, 16, 12, 1, -15), -- 0x36 '6' (381, 11, 16, 12, 0, -15), -- 0x37 '7' (403, 11, 16, 12, 1, -15), -- 0x38 '8' (425, 11, 16, 12, 1, -15), -- 0x39 '9' (447, 4, 11, 8, 2, -10), -- 0x3A ':' (453, 4, 15, 8, 2, -10), -- 0x3B ';' (461, 14, 14, 16, 1, -12), -- 0x3C '<' (486, 14, 8, 16, 1, -9), -- 0x3D '=' (500, 14, 14, 16, 1, -12), -- 0x3E '>' (525, 10, 16, 12, 1, -15), -- 0x3F '?' (545, 16, 16, 22, 3, -15), -- 0x40 '@' (577, 17, 16, 17, 0, -15), -- 0x41 'A' (611, 14, 16, 16, 1, -15), -- 0x42 'B' (639, 15, 16, 17, 1, -15), -- 0x43 'C' (669, 17, 16, 18, 0, -15), -- 0x44 'D' (703, 15, 16, 16, 1, -15), -- 0x45 'E' (733, 14, 16, 15, 1, -15), -- 0x46 'F' (761, 16, 16, 19, 1, -15), -- 0x47 'G' (793, 16, 16, 19, 2, -15), -- 0x48 'H' (825, 8, 16, 9, 1, -15), -- 0x49 'I' (841, 12, 18, 12, 0, -15), -- 0x4A 'J' (868, 17, 16, 19, 2, -15), -- 0x4B 'K' (902, 14, 16, 16, 2, -15), -- 0x4C 'L' (930, 20, 16, 23, 1, -15), -- 0x4D 'M' (970, 15, 16, 17, 1, -15), -- 0x4E 'N' (1000, 17, 16, 19, 1, -15), -- 0x4F 'O' (1034, 12, 16, 15, 2, -15), -- 0x50 'P' (1058, 17, 20, 19, 1, -15), -- 0x51 'Q' (1101, 16, 16, 17, 1, -15), -- 0x52 'R' (1133, 12, 16, 14, 1, -15), -- 0x53 'S' (1157, 15, 16, 15, 0, -15), -- 0x54 'T' (1187, 15, 16, 17, 1, -15), -- 0x55 'U' (1217, 17, 17, 17, 0, -15), -- 0x56 'V' (1254, 23, 16, 24, 0, -15), -- 0x57 'W' (1300, 17, 16, 17, 0, -15), -- 0x58 'X' (1334, 16, 16, 17, 1, -15), -- 0x59 'Y' (1366, 15, 16, 16, 0, -15), -- 0x5A 'Z' (1396, 5, 20, 8, 2, -15), -- 0x5B '[' (1409, 8, 17, 7, -1, -15), -- 0x5C '\' (1426, 5, 20, 8, 2, -15), -- 0x5D ']' (1439, 10, 9, 14, 2, -15), -- 0x5E '^' (1451, 12, 1, 12, 0, 4), -- 0x5F '_' (1453, 5, 4, 8, 0, -16), -- 0x60 '`' (1456, 11, 11, 12, 1, -10), -- 0x61 'a' (1472, 12, 16, 13, 1, -15), -- 0x62 'b' (1496, 9, 11, 10, 1, -10), -- 0x63 'c' (1509, 12, 16, 13, 1, -15), -- 0x64 'd' (1533, 10, 11, 11, 1, -10), -- 0x65 'e' (1547, 8, 16, 9, 1, -15), -- 0x66 'f' (1563, 11, 16, 12, 1, -10), -- 0x67 'g' (1585, 12, 16, 13, 1, -15), -- 0x68 'h' (1609, 6, 16, 7, 1, -15), -- 0x69 'i' (1621, 8, 21, 10, 0, -15), -- 0x6A 'j' (1642, 13, 16, 13, 1, -15), -- 0x6B 'k' (1668, 6, 16, 7, 1, -15), -- 0x6C 'l' (1680, 19, 11, 20, 1, -10), -- 0x6D 'm' (1707, 12, 11, 13, 1, -10), -- 0x6E 'n' (1724, 11, 11, 12, 1, -10), -- 0x6F 'o' (1740, 12, 16, 13, 1, -10), -- 0x70 'p' (1764, 12, 16, 13, 1, -10), -- 0x71 'q' (1788, 10, 11, 10, 1, -10), -- 0x72 'r' (1802, 8, 11, 10, 1, -10), -- 0x73 's' (1813, 8, 15, 8, 1, -14), -- 0x74 't' (1828, 12, 11, 14, 1, -10), -- 0x75 'u' (1845, 11, 11, 12, 0, -10), -- 0x76 'v' (1861, 17, 11, 17, 0, -10), -- 0x77 'w' (1885, 12, 11, 12, 0, -10), -- 0x78 'x' (1902, 11, 16, 12, 0, -10), -- 0x79 'y' (1924, 10, 11, 11, 1, -10), -- 0x7A 'z' (1938, 8, 21, 9, 0, -16), -- 0x7B '{' (1959, 2, 17, 5, 2, -15), -- 0x7C '|' (1964, 8, 21, 9, 2, -16), -- 0x7D '}' (1985, 11, 4, 12, 1, -7)); -- 0x7E '~' Font_D : aliased constant Bitmap_Font := (FreeSerifBold12pt7bBitmaps'Access, FreeSerifBold12pt7bGlyphs'Access, 28); Font : constant Giza.Font.Ref_Const := Font_D'Access; end Giza.Bitmap_Fonts.FreeSerifBold12pt7b;
with Numerics, Ada.Text_IO, Auto_Differentiation.Integrator, Chebyshev; use Numerics, Ada.Text_IO, Auto_Differentiation.Integrator, Chebyshev; procedure Auto_Differentiation.Pendulum is use Real_IO, Real_Functions; -- Set Up Parameters ----------------- Control : Control_Type := (N => 1, Dt => 0.1, Eps => 1.0e-10, Err => 1.0, K => 7); N : Nat renames Control.N; ------------------------------- function Lagrangian (X : in Real_Vector; N : in Nat) return AD_Type is θ : AD_Type := Var (X => X (1), I => 1, N => 2); ω : AD_Type := Var (X => X (2), I => 2, N => 2); M : Real := 2.0; L : Real := 1.0; G : Real := 10.0; begin return (0.5 * M * L**2) * (ω ** 2) - M * G * (1.0 - Sin (θ)); end Lagrangian; ------------------------------- -- Initial Conditions ---- Var : Variable := (N2 => 2 * N, X => (1.0e-10, 0.0), T => 0.0); θ : Real renames Var.X (1); ω : Real renames Var.X (2); T : Real renames Var.T; ------------------------------- Y : Real_Vector (1 .. 2 * N * Control.K); A, B : Real_Vector (1 .. N * Control.K); File : File_Type; Dt : constant Real := 0.05; Time : Real := T - Dt; Okay : Boolean; begin Create (File, Name => "pendulum.csv"); Put_Line (File, "time, x, u, y, v"); Setup (N, Control.K); Okay := Is_Setup; while T < 100.0 loop Y := Collocation (Lagrangian'Access, Var, Control); for I in 1 .. Control.K loop A (I) := Y (2 * I - 1); B (I) := Y (2 * I); end loop; A := CGL_Transform (A); B := CGL_Transform (B); while Time <= T + Control.Dt loop Time := Time + Dt; θ := Interpolate (A => A, X => Time, L => T, R => T + Control.Dt); ω := Interpolate (A => B, X => Time, L => T, R => T + Control.Dt); Put (File, Time); Put (File, ", "); Put (File, Cos (θ)); Put (File, ", "); Put (File, -ω * Sin (θ)); Put (File, ", "); Put (File, 1.0 - Sin (θ)); Put (File, ", "); Put (File, -ω * Cos (θ)); New_Line (File); end loop; θ := Y (Y'Last - 1); ω := Y (Y'Last); T := T + Control.Dt; end loop; Close (File); end Auto_Differentiation.Pendulum;
with Interfaces.C.Strings; package body STB.Image is ---------- -- Load -- ---------- function Load (Filename : String; X, Y, Channels_In_File : out Interfaces.C.int; Desired_Channels : Interfaces.C.int) return System.Address is function C_Load (Filename : Interfaces.C.Strings.chars_ptr; X, Y, Comp : access Interfaces.C.int; Req_Comp : Interfaces.C.int) return System.Address; pragma Import (C, C_Load, "stbi_load"); Filename_C : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (Filename); Result : System.Address; X_A, Y_A, Comp_A : aliased Interfaces.C.int; begin Result := C_Load (Filename_C, X_A'Access, Y_A'Access, Comp_A 'Access, Desired_Channels); Interfaces.C.Strings.Free (Filename_C); X := X_A; Y := Y_A; Channels_In_File := Comp_A; return Result; end Load; --------------- -- Write_PNG -- --------------- function Write_PNG (Filename : String; W, H, Channels : Interfaces.C.int; Data : System.Address; Len : Interfaces.C.int) return Interfaces.C.int is function C_Write (Filename : Interfaces.C.Strings.chars_ptr; W, H, Comp : Interfaces.C.int; Data : System.Address; Len : Interfaces.C.int) return Interfaces.C.int; pragma Import (C, C_Write, "stbi_write_png"); Filename_C : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (Filename); Result : Interfaces.C.int; begin Result := C_Write (Filename_C, W, H, Channels, Data, Len); Interfaces.C.Strings.Free (Filename_C); return Result; end Write_PNG; end STB.Image;
--- gnatvsn.adb.orig 2013-07-16 03:35:21.000000000 +0000 +++ gnatvsn.adb @@ -53,32 +53,13 @@ package body Gnatvsn is " FOR A PARTICULAR PURPOSE."; end Gnat_Free_Software; - type char_array is array (Natural range <>) of aliased Character; - Version_String : char_array (0 .. Ver_Len_Max - 1); - -- Import the C string defined in the (language-independent) source file - -- version.c using the zero-based convention of the C language. - -- The size is not the real one, which does not matter since we will - -- check for the nul character in Gnat_Version_String. - pragma Import (C, Version_String, "version_string"); - ------------------------- -- Gnat_Version_String -- ------------------------- function Gnat_Version_String return String is - S : String (1 .. Ver_Len_Max); - Pos : Natural := 0; begin - loop - exit when Version_String (Pos) = ASCII.NUL; - - S (Pos + 1) := Version_String (Pos); - Pos := Pos + 1; - - exit when Pos = Ver_Len_Max; - end loop; - - return S (1 .. Pos); + Return Gnat_Static_Version_String; end Gnat_Version_String; end Gnatvsn;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Command_Line; with League.Application; with XML.SAX.File_Input_Sources; with XML.SAX.Simple_Readers; with WSDL.Analyzer; with WSDL.AST.Descriptions; pragma Unreferenced (WSDL.AST.Descriptions); -- GNAT Pro 7.2.0w (20130423): package is needed to access to type's -- components. with WSDL.Debug; with WSDL.Generator; with WSDL.Iterators.Containment; with WSDL.Parsers; with WSDL.Name_Resolvers; procedure WSDL.Driver is Source : aliased XML.SAX.File_Input_Sources.File_Input_Source; Handler : aliased WSDL.Parsers.WSDL_Parser; Reader : aliased XML.SAX.Simple_Readers.Simple_Reader; begin -- Load document. Reader.Set_Content_Handler (Handler'Unchecked_Access); Source.Open_By_File_Name (League.Application.Arguments.Element (1)); Reader.Parse (Source'Unchecked_Access); -- Resolve names. declare Resolver : WSDL.Name_Resolvers.Name_Resolver; Iterator : WSDL.Iterators.Containment.Containment_Iterator; Control : WSDL.Iterators.Traverse_Control := WSDL.Iterators.Continue; begin Resolver.Set_Root (Handler.Get_Description); Iterator.Visit (Resolver, WSDL.AST.Node_Access (Handler.Get_Description), Control); end; -- Analyze. declare Analyzer : WSDL.Analyzer.Analyzer; Iterator : WSDL.Iterators.Containment.Containment_Iterator; Control : WSDL.Iterators.Traverse_Control := WSDL.Iterators.Continue; begin Analyzer.Set_Root (Handler.Get_Description); Iterator.Visit (Analyzer, WSDL.AST.Node_Access (Handler.Get_Description), Control); end; -- WSDL.Debug.Dump (Handler.Get_Description); -- Generate code. WSDL.Generator.Generate (Handler.Get_Description); exception when WSDL.WSDL_Error => -- It means that detedted error was reported and processing was -- terminated. Set exit status to report presence of some error. Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end WSDL.Driver;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2011, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides persistent platform-independent application settings. -- -- When Settings object is initialized implicitly, it provides access to -- settings of the application and organization set previously with a call to -- League.Application.Set_Organization_Name, -- League.Application.Set_Organization_Domain and -- League.Application.Set_Application_Name. Fallback mechanism allows to -- retrieve settings from several locations: -- -- - a user-specific location for the application -- -- - a user-specific location for all applications by organization -- -- - a system-wide location for the application -- -- - a system-wide location for all applications by organization -- ------------------------------------------------------------------------------ private with Ada.Finalization; with League.Holders; with League.Strings; private with Matreshka.Internals.Settings; package League.Settings is type Formats is (Native, Ini); -- type Scopes is (User, System); -- -- type Statuses is (No_Error, Access_Error, Format_Error); type Settings is tagged limited private; function Create (File_Name : League.Strings.Universal_String; Format : Formats := Native) return Settings; -- Constructs a Settings object for accessing the settings stored in the -- file called File_Name. If the file doesn't already exist, it is created. function Create (Organization_Name : League.Strings.Universal_String; Organization_Domain : League.Strings.Universal_String; Application_Name : League.Strings.Universal_String := League.Strings.Empty_Universal_String; Format : Formats := Native) return Settings; -- Constructs a Settings object for accessing settings of the application -- called Application from the organization called Organization. -- function All_Keys -- (Self : Settings) return League.String_Vectors.Universal_String_Vector; -- -- function Application_Name -- (Self : Settings) return League.Strings.Universal_String; -- -- procedure Begin_Group -- (Self : in out Settings; -- Prefix : League.Strings.Universal_String); -- -- function Child_Groups -- (Self : Settings) return League.String_Vectors.Universal_String_Vector; -- -- function Child_Keys -- (Self : Settings) return League.String_Vectors.Universal_String_Vector; -- -- procedure Clear (Self : in out Settings); function Contains (Self : Settings; Key : League.Strings.Universal_String) return Boolean; -- Returns True if there exists a setting called key; returns False -- otherwise. -- -- If a group is set using Begin_Group, key is taken to be relative to that -- group. -- procedure End_Group (Self : in out Settings); -- -- function Fallbacks_Enabled (Self : Settings) return Boolean; -- -- function File_Name (Self : Settings) return League.Strings.Universal_String; -- -- function Format (Self : Settings) return Formats; -- -- function Group (Self : Settings) return League.Strings.Universal_String; -- -- function Is_Writeable (Self : Settings) return Boolean; -- -- function Organization_Name -- (Self : Settings) return League.Strings.Universal_String; procedure Remove (Self : in out Settings; Key : League.Strings.Universal_String); -- Removes the setting key and any sub-settings of key. -- -- If a group is set using Begin_Group, key is taken to be relative to that -- group. -- -- If Key is an empty string, all keys in the current Group are removed. -- -- Be aware that if one of the fallback locations contains a setting with -- the same key, that setting will be visible after calling Remove. -- function Scope (Self : Settings) return Scopes; -- -- procedure Set_Fallbacks_Enables (Self : in out Settings; Enabled : Boolean); procedure Set_Value (Self : in out Settings'Class; Key : League.Strings.Universal_String; Value : League.Holders.Holder); -- Sets the value of setting key to value. If the key already exists, the -- previous value is overwritten. -- -- If a group is set using Begin_Group, key is taken to be relative to that -- group. -- function Status (Self : Settings) return Statuses; procedure Sync (Self : in out Settings); -- Writes any unsaved changes to permanent storage, and reloads any -- settings that have been changed in the meantime by another application. function Value (Self : Settings'Class; Key : League.Strings.Universal_String) return League.Holders.Holder; -- Returns the value for setting key. If the setting doesn't exist, returns -- Default_Value. -- -- If no default value is specified, an Empty_Value is returned. -- -- If a group is set using Begin_Group, key is taken to be relative to that -- group. private type Settings is new Ada.Finalization.Limited_Controlled with record Data : Matreshka.Internals.Settings.Settings_Access; end record; overriding procedure Initialize (Self : in out Settings); overriding procedure Finalize (Self : in out Settings); end League.Settings;
package GMP -- -- -- is end GMP;
with Aof.Core.Signals; with Derived_Objects; package Slots is procedure Xaa; procedure Xab; procedure Xac; Chained_Signal : aliased Aof.Core.Signals.Empty.Signal; Obj_1 : aliased Derived_Objects.Derived_Object; Obj_2 : aliased Derived_Objects.Derived_Object; end Slots;
pragma License (Unrestricted); -- BSD 3-Clause -- translated unit from dSFMT (dSFMT-params19937.h) with Ada.Numerics.dSFMT; package Ada.Numerics.dSFMT_19937 is new dSFMT ( MEXP => 19937, POS1 => 117, SL1 => 19, MSK1 => 16#000ffafffffffb3f#, MSK2 => 16#000ffdfffc90fffd#, FIX1 => 16#90014964b32f4329#, FIX2 => 16#3b8d12ac548a7c7a#, PCV1 => 16#3d84e1ac0dc82880#, PCV2 => 16#0000000000000001#); -- For normal use. pragma Preelaborate (Ada.Numerics.dSFMT_19937);
with Interfaces.C.Strings, System.Address_To_Access_Conversions, FLTK.Widgets.Groups.Windows, FLTK.Images; use type Interfaces.C.int, Interfaces.C.unsigned, Interfaces.C.Strings.chars_ptr, System.Address; package body FLTK.Widgets is function "+" (Left, Right : in Callback_Flag) return Callback_Flag is begin return Left or Right; end "+"; package Group_Convert is new System.Address_To_Access_Conversions (FLTK.Widgets.Groups.Group'Class); package Window_Convert is new System.Address_To_Access_Conversions (FLTK.Widgets.Groups.Windows.Window'Class); procedure widget_set_draw_hook (W, D : in System.Address); pragma Import (C, widget_set_draw_hook, "widget_set_draw_hook"); pragma Inline (widget_set_draw_hook); procedure widget_set_handle_hook (W, H : in System.Address); pragma Import (C, widget_set_handle_hook, "widget_set_handle_hook"); pragma Inline (widget_set_handle_hook); function new_fl_widget (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_widget, "new_fl_widget"); pragma Inline (new_fl_widget); procedure free_fl_widget (F : in System.Address); pragma Import (C, free_fl_widget, "free_fl_widget"); pragma Inline (free_fl_widget); procedure fl_widget_activate (W : in System.Address); pragma Import (C, fl_widget_activate, "fl_widget_activate"); pragma Inline (fl_widget_activate); procedure fl_widget_deactivate (W : in System.Address); pragma Import (C, fl_widget_deactivate, "fl_widget_deactivate"); pragma Inline (fl_widget_deactivate); function fl_widget_active (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_active, "fl_widget_active"); pragma Inline (fl_widget_active); function fl_widget_active_r (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_active_r, "fl_widget_active_r"); pragma Inline (fl_widget_active_r); procedure fl_widget_set_active (W : in System.Address); pragma Import (C, fl_widget_set_active, "fl_widget_set_active"); pragma Inline (fl_widget_set_active); procedure fl_widget_clear_active (W : in System.Address); pragma Import (C, fl_widget_clear_active, "fl_widget_clear_active"); pragma Inline (fl_widget_clear_active); function fl_widget_changed (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_changed, "fl_widget_changed"); pragma Inline (fl_widget_changed); procedure fl_widget_set_changed (W : in System.Address); pragma Import (C, fl_widget_set_changed, "fl_widget_set_changed"); pragma Inline (fl_widget_set_changed); procedure fl_widget_clear_changed (W : in System.Address); pragma Import (C, fl_widget_clear_changed, "fl_widget_clear_changed"); pragma Inline (fl_widget_clear_changed); function fl_widget_output (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_output, "fl_widget_output"); pragma Inline (fl_widget_output); procedure fl_widget_set_output (W : in System.Address); pragma Import (C, fl_widget_set_output, "fl_widget_set_output"); pragma Inline (fl_widget_set_output); procedure fl_widget_clear_output (W : in System.Address); pragma Import (C, fl_widget_clear_output, "fl_widget_clear_output"); pragma Inline (fl_widget_clear_output); function fl_widget_visible (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_visible, "fl_widget_visible"); pragma Inline (fl_widget_visible); function fl_widget_visible_r (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_visible_r, "fl_widget_visible_r"); pragma Inline (fl_widget_visible_r); procedure fl_widget_set_visible (W : in System.Address); pragma Import (C, fl_widget_set_visible, "fl_widget_set_visible"); pragma Inline (fl_widget_set_visible); procedure fl_widget_clear_visible (W : in System.Address); pragma Import (C, fl_widget_clear_visible, "fl_widget_clear_visible"); pragma Inline (fl_widget_clear_visible); function fl_widget_get_visible_focus (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_visible_focus, "fl_widget_get_visible_focus"); pragma Inline (fl_widget_get_visible_focus); procedure fl_widget_set_visible_focus (W : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_widget_set_visible_focus, "fl_widget_set_visible_focus"); pragma Inline (fl_widget_set_visible_focus); function fl_widget_take_focus (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_take_focus, "fl_widget_take_focus"); pragma Inline (fl_widget_take_focus); function fl_widget_takesevents (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_takesevents, "fl_widget_takesevents"); pragma Inline (fl_widget_takesevents); function fl_widget_get_color (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_get_color, "fl_widget_get_color"); pragma Inline (fl_widget_get_color); procedure fl_widget_set_color (W : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_widget_set_color, "fl_widget_set_color"); pragma Inline (fl_widget_set_color); function fl_widget_get_selection_color (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_get_selection_color, "fl_widget_get_selection_color"); pragma Inline (fl_widget_get_selection_color); procedure fl_widget_set_selection_color (W : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_widget_set_selection_color, "fl_widget_set_selection_color"); pragma Inline (fl_widget_set_selection_color); function fl_widget_get_parent (W : in System.Address) return System.Address; pragma Import (C, fl_widget_get_parent, "fl_widget_get_parent"); pragma Inline (fl_widget_get_parent); function fl_widget_contains (W, I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_contains, "fl_widget_contains"); pragma Inline (fl_widget_contains); function fl_widget_inside (W, P : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_inside, "fl_widget_inside"); pragma Inline (fl_widget_inside); function fl_widget_window (W : in System.Address) return System.Address; pragma Import (C, fl_widget_window, "fl_widget_window"); pragma Inline (fl_widget_window); function fl_widget_top_window (W : in System.Address) return System.Address; pragma Import (C, fl_widget_top_window, "fl_widget_top_window"); pragma Inline (fl_widget_top_window); function fl_widget_top_window_offset (W : in System.Address; X, Y : out Interfaces.C.int) return System.Address; pragma Import (C, fl_widget_top_window_offset, "fl_widget_top_window_offset"); pragma Inline (fl_widget_top_window_offset); function fl_widget_get_align (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_get_align, "fl_widget_get_align"); pragma Inline (fl_widget_get_align); procedure fl_widget_set_align (W : in System.Address; A : in Interfaces.C.unsigned); pragma Import (C, fl_widget_set_align, "fl_widget_set_align"); pragma Inline (fl_widget_set_align); function fl_widget_get_box (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_box, "fl_widget_get_box"); pragma Inline (fl_widget_get_box); procedure fl_widget_set_box (W : in System.Address; B : in Interfaces.C.int); pragma Import (C, fl_widget_set_box, "fl_widget_set_box"); pragma Inline (fl_widget_set_box); function fl_widget_tooltip (W : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_widget_tooltip, "fl_widget_tooltip"); pragma Inline (fl_widget_tooltip); procedure fl_widget_copy_tooltip (W : in System.Address; T : in Interfaces.C.char_array); pragma Import (C, fl_widget_copy_tooltip, "fl_widget_copy_tooltip"); pragma Inline (fl_widget_copy_tooltip); function fl_widget_get_label (W : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_widget_get_label, "fl_widget_get_label"); pragma Inline (fl_widget_get_label); procedure fl_widget_set_label (W : in System.Address; T : in Interfaces.C.char_array); pragma Import (C, fl_widget_set_label, "fl_widget_set_label"); pragma Inline (fl_widget_set_label); function fl_widget_get_labelcolor (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_get_labelcolor, "fl_widget_get_labelcolor"); pragma Inline (fl_widget_get_labelcolor); procedure fl_widget_set_labelcolor (W : in System.Address; V : in Interfaces.C.unsigned); pragma Import (C, fl_widget_set_labelcolor, "fl_widget_set_labelcolor"); pragma Inline (fl_widget_set_labelcolor); function fl_widget_get_labelfont (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_labelfont, "fl_widget_get_labelfont"); pragma Inline (fl_widget_get_labelfont); procedure fl_widget_set_labelfont (W : in System.Address; F : in Interfaces.C.int); pragma Import (C, fl_widget_set_labelfont, "fl_widget_set_labelfont"); pragma Inline (fl_widget_set_labelfont); function fl_widget_get_labelsize (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_labelsize, "fl_widget_get_labelsize"); pragma Inline (fl_widget_get_labelsize); procedure fl_widget_set_labelsize (W : in System.Address; S : in Interfaces.C.int); pragma Import (C, fl_widget_set_labelsize, "fl_widget_set_labelsize"); pragma Inline (fl_widget_set_labelsize); function fl_widget_get_labeltype (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_labeltype, "fl_widget_get_labeltype"); pragma Inline (fl_widget_get_labeltype); procedure fl_widget_set_labeltype (W : in System.Address; L : in Interfaces.C.int); pragma Import (C, fl_widget_set_labeltype, "fl_widget_set_labeltype"); pragma Inline (fl_widget_set_labeltype); procedure fl_widget_measure_label (W : in System.Address; D, H : out Interfaces.C.int); pragma Import (C, fl_widget_measure_label, "fl_widget_measure_label"); pragma Inline (fl_widget_measure_label); procedure fl_widget_set_callback (W, C : in System.Address); pragma Import (C, fl_widget_set_callback, "fl_widget_set_callback"); pragma Inline (fl_widget_set_callback); function fl_widget_get_when (W : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_widget_get_when, "fl_widget_get_when"); pragma Inline (fl_widget_get_when); procedure fl_widget_set_when (W : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_widget_set_when, "fl_widget_set_when"); pragma Inline (fl_widget_set_when); function fl_widget_get_x (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_x, "fl_widget_get_x"); pragma Inline (fl_widget_get_x); function fl_widget_get_y (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_y, "fl_widget_get_y"); pragma Inline (fl_widget_get_y); function fl_widget_get_w (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_w, "fl_widget_get_w"); pragma Inline (fl_widget_get_w); function fl_widget_get_h (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_get_h, "fl_widget_get_h"); pragma Inline (fl_widget_get_h); procedure fl_widget_size (W : in System.Address; D, H : in Interfaces.C.int); pragma Import (C, fl_widget_size, "fl_widget_size"); pragma Inline (fl_widget_size); procedure fl_widget_position (W : in System.Address; X, Y : in Interfaces.C.int); pragma Import (C, fl_widget_position, "fl_widget_position"); pragma Inline (fl_widget_position); procedure fl_widget_set_image (W, I : in System.Address); pragma Import (C, fl_widget_set_image, "fl_widget_set_image"); pragma Inline (fl_widget_set_image); procedure fl_widget_set_deimage (W, I : in System.Address); pragma Import (C, fl_widget_set_deimage, "fl_widget_set_deimage"); pragma Inline (fl_widget_set_deimage); function fl_widget_damage (W : in System.Address) return Interfaces.C.int; pragma Import (C, fl_widget_damage, "fl_widget_damage"); pragma Inline (fl_widget_damage); procedure fl_widget_set_damage (W : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_widget_set_damage, "fl_widget_set_damage"); pragma Inline (fl_widget_set_damage); procedure fl_widget_set_damage2 (W : in System.Address; T : in Interfaces.C.int; X, Y, D, H : in Interfaces.C.int); pragma Import (C, fl_widget_set_damage2, "fl_widget_set_damage2"); pragma Inline (fl_widget_set_damage2); procedure fl_widget_draw_label (W : in System.Address; X, Y, D, H : in Interfaces.C.int; A : in Interfaces.C.unsigned); pragma Import (C, fl_widget_draw_label, "fl_widget_draw_label"); pragma Inline (fl_widget_draw_label); procedure fl_widget_redraw (W : in System.Address); pragma Import (C, fl_widget_redraw, "fl_widget_redraw"); pragma Inline (fl_widget_redraw); procedure fl_widget_redraw_label (W : in System.Address); pragma Import (C, fl_widget_redraw_label, "fl_widget_redraw_label"); pragma Inline (fl_widget_redraw_label); procedure Callback_Hook (W, U : in System.Address) is Ada_Widget : access Widget'Class := Widget_Convert.To_Pointer (U); begin Ada_Widget.Callback.all (Ada_Widget.all); end Callback_Hook; procedure Draw_Hook (U : in System.Address) is Ada_Widget : access Widget'Class := Widget_Convert.To_Pointer (U); begin Ada_Widget.Draw; end Draw_Hook; function Handle_Hook (U : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int is Ada_Widget : access Widget'Class := Widget_Convert.To_Pointer (U); begin return Event_Outcome'Pos (Ada_Widget.Handle (Event_Kind'Val (E))); end Handle_Hook; procedure Finalize (This : in out Widget) is begin if This.Void_Ptr /= System.Null_Address and then This in Widget'Class then free_fl_widget (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; end Finalize; package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Widget is begin return This : Widget do This.Void_Ptr := new_fl_widget (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); widget_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); widget_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; end Forge; procedure Activate (This : in out Widget) is begin fl_widget_activate (This.Void_Ptr); end Activate; procedure Deactivate (This : in out Widget) is begin fl_widget_deactivate (This.Void_Ptr); end Deactivate; function Is_Active (This : in Widget) return Boolean is begin return fl_widget_active (This.Void_Ptr) /= 0; end Is_Active; function Is_Tree_Active (This : in Widget) return Boolean is begin return fl_widget_active_r (This.Void_Ptr) /= 0; end Is_Tree_Active; procedure Set_Active (This : in out Widget; To : in Boolean) is begin if To then fl_widget_set_active (This.Void_Ptr); else fl_widget_clear_active (This.Void_Ptr); end if; end Set_Active; function Has_Changed (This : in Widget) return Boolean is begin return fl_widget_changed (This.Void_Ptr) /= 0; end Has_Changed; procedure Set_Changed (This : in out Widget; To : in Boolean) is begin if To then fl_widget_set_changed (This.Void_Ptr); else fl_widget_clear_changed (This.Void_Ptr); end if; end Set_Changed; function Is_Output_Only (This : in Widget) return Boolean is begin return fl_widget_output (This.Void_Ptr) /= 0; end Is_Output_Only; procedure Set_Output_Only (This : in out Widget; To : in Boolean) is begin if To then fl_widget_set_output (This.Void_Ptr); else fl_widget_clear_output (This.Void_Ptr); end if; end Set_Output_Only; function Is_Visible (This : in Widget) return Boolean is begin return fl_widget_visible (This.Void_Ptr) /= 0; end Is_Visible; function Is_Tree_Visible (This : in Widget) return Boolean is begin return fl_widget_visible_r (This.Void_Ptr) /= 0; end Is_Tree_Visible; procedure Set_Visible (This : in out Widget; To : in Boolean) is begin if To then fl_widget_set_visible (This.Void_Ptr); else fl_widget_clear_visible (This.Void_Ptr); end if; end Set_Visible; function Has_Visible_Focus (This : in Widget) return Boolean is begin return fl_widget_get_visible_focus (This.Void_Ptr) /= 0; end Has_Visible_Focus; procedure Set_Visible_Focus (This : in out Widget; To : in Boolean) is begin fl_widget_set_visible_focus (This.Void_Ptr, Boolean'Pos (To)); end Set_Visible_Focus; function Take_Focus (This : in out Widget) return Boolean is begin return fl_widget_take_focus (This.Void_Ptr) /= 0; end Take_Focus; function Takes_Events (This : in Widget) return Boolean is begin return fl_widget_takesevents (This.Void_Ptr) /= 0; end Takes_Events; function Get_Background_Color (This : in Widget) return Color is begin return Color (fl_widget_get_color (This.Void_Ptr)); end Get_Background_Color; procedure Set_Background_Color (This : in out Widget; To : in Color) is begin fl_widget_set_color (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_Background_Color; function Get_Selection_Color (This : in Widget) return Color is begin return Color (fl_widget_get_selection_color (This.Void_Ptr)); end Get_Selection_Color; procedure Set_Selection_Color (This : in out Widget; To : in Color) is begin fl_widget_set_selection_color (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_Selection_Color; function Parent (This : in Widget) return access FLTK.Widgets.Groups.Group'Class is Parent_Ptr : System.Address; Actual_Parent : access FLTK.Widgets.Groups.Group'Class; begin Parent_Ptr := fl_widget_get_parent (This.Void_Ptr); if Parent_Ptr /= System.Null_Address then Actual_Parent := Group_Convert.To_Pointer (fl_widget_get_user_data (Parent_Ptr)); end if; return Actual_Parent; end Parent; function Contains (This : in Widget; Item : in Widget'Class) return Boolean is begin return fl_widget_contains (This.Void_Ptr, Item.Void_Ptr) /= 0; end Contains; function Inside (This : in Widget; Parent : in Widget'Class) return Boolean is begin return fl_widget_inside (This.Void_Ptr, Parent.Void_Ptr) /= 0; end Inside; function Nearest_Window (This : in Widget) return access FLTK.Widgets.Groups.Windows.Window'Class is Window_Ptr : System.Address; Actual_Window : access FLTK.Widgets.Groups.Windows.Window'Class; begin Window_Ptr := fl_widget_window (This.Void_Ptr); if Window_Ptr /= System.Null_Address then Actual_Window := Window_Convert.To_Pointer (fl_widget_get_user_data (Window_Ptr)); end if; return Actual_Window; end Nearest_Window; function Top_Window (This : in Widget) return access FLTK.Widgets.Groups.Windows.Window'Class is Window_Ptr : System.Address; Actual_Window : access FLTK.Widgets.Groups.Windows.Window'Class; begin Window_Ptr := fl_widget_top_window (This.Void_Ptr); if Window_Ptr /= System.Null_Address then Actual_Window := Window_Convert.To_Pointer (fl_widget_get_user_data (Window_Ptr)); end if; return Actual_Window; end Top_Window; function Top_Window_Offset (This : in Widget; Offset_X, Offset_Y : out Integer) return access FLTK.Widgets.Groups.Windows.Window'Class is Window_Ptr : System.Address; Actual_Window : access FLTK.Widgets.Groups.Windows.Window'Class; begin Window_Ptr := fl_widget_top_window_offset (This.Void_Ptr, Interfaces.C.int (Offset_X), Interfaces.C.int (Offset_Y)); if Window_Ptr /= System.Null_Address then Actual_Window := Window_Convert.To_Pointer (fl_widget_get_user_data (Window_Ptr)); end if; return Actual_Window; end Top_Window_Offset; function Get_Alignment (This : in Widget) return Alignment is begin return Alignment (fl_widget_get_align (This.Void_Ptr)); end Get_Alignment; procedure Set_Alignment (This : in out Widget; New_Align : in Alignment) is begin fl_widget_set_align (This.Void_Ptr, Interfaces.C.unsigned (New_Align)); end Set_Alignment; function Get_Box (This : in Widget) return Box_Kind is begin return Box_Kind'Val (fl_widget_get_box (This.Void_Ptr)); end Get_Box; procedure Set_Box (This : in out Widget; Box : in Box_Kind) is begin fl_widget_set_box (This.Void_Ptr, Box_Kind'Pos (Box)); end Set_Box; function Get_Tooltip (This : in Widget) return String is Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_tooltip (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; else -- no need for dealloc return Interfaces.C.Strings.Value (Ptr); end if; end Get_Tooltip; procedure Set_Tooltip (This : in out Widget; Text : in String) is begin fl_widget_copy_tooltip (This.Void_Ptr, Interfaces.C.To_C (Text)); end Set_Tooltip; function Get_Label (This : in Widget) return String is Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_get_label (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; else return Interfaces.C.Strings.Value (Ptr); end if; end Get_Label; procedure Set_Label (This : in out Widget; Text : in String) is begin fl_widget_set_label (This.Void_Ptr, Interfaces.C.To_C (Text)); end Set_Label; function Get_Label_Color (This : in Widget) return Color is begin return Color (fl_widget_get_labelcolor (This.Void_Ptr)); end Get_Label_Color; procedure Set_Label_Color (This : in out Widget; Value : in Color) is begin fl_widget_set_labelcolor (This.Void_Ptr, Interfaces.C.unsigned (Value)); end Set_Label_Color; function Get_Label_Font (This : in Widget) return Font_Kind is begin return Font_Kind'Val (fl_widget_get_labelfont (This.Void_Ptr)); end Get_Label_Font; procedure Set_Label_Font (This : in out Widget; Font : in Font_Kind) is begin fl_widget_set_labelfont (This.Void_Ptr, Font_Kind'Pos (Font)); end Set_Label_Font; function Get_Label_Size (This : in Widget) return Font_Size is begin return Font_Size (fl_widget_get_labelsize (This.Void_Ptr)); end Get_Label_Size; procedure Set_Label_Size (This : in out Widget; Size : in Font_Size) is begin fl_widget_set_labelsize (This.Void_Ptr, Interfaces.C.int (Size)); end Set_Label_Size; function Get_Label_Type (This : in Widget) return Label_Kind is begin return Label_Kind'Val (fl_widget_get_labeltype (This.Void_Ptr)); end Get_Label_Type; procedure Set_Label_Type (This : in out Widget; Label : in Label_Kind) is begin fl_widget_set_labeltype (This.Void_Ptr, Label_Kind'Pos (Label)); end Set_Label_Type; procedure Measure_Label (This : in Widget; W, H : out Integer) is begin fl_widget_measure_label (This.Void_Ptr, Interfaces.C.int (W), Interfaces.C.int (H)); end Measure_Label; function Get_Callback (This : in Widget) return Widget_Callback is begin return This.Callback; end Get_Callback; procedure Set_Callback (This : in out Widget; Func : in Widget_Callback) is begin if Func /= null then This.Callback := Func; fl_widget_set_callback (This.Void_Ptr, Callback_Hook'Address); end if; end Set_Callback; procedure Do_Callback (This : in out Widget) is begin if This.Callback /= null then This.Callback.all (This); end if; end Do_Callback; function Get_When (This : in Widget) return Callback_Flag is begin return Callback_Flag (fl_widget_get_when (This.Void_Ptr)); end Get_When; procedure Set_When (This : in out Widget; To : in Callback_Flag) is begin fl_widget_set_when (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_When; function Get_X (This : in Widget) return Integer is begin return Integer (fl_widget_get_x (This.Void_Ptr)); end Get_X; function Get_Y (This : in Widget) return Integer is begin return Integer (fl_widget_get_y (This.Void_Ptr)); end Get_Y; function Get_W (This : in Widget) return Integer is begin return Integer (fl_widget_get_w (This.Void_Ptr)); end Get_W; function Get_H (This : in Widget) return Integer is begin return Integer (fl_widget_get_h (This.Void_Ptr)); end Get_H; procedure Resize (This : in out Widget; W, H : in Integer) is begin fl_widget_size (This.Void_Ptr, Interfaces.C.int (W), Interfaces.C.int (H)); end Resize; procedure Reposition (This : in out Widget; X, Y : in Integer) is begin fl_widget_position (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)); end Reposition; function Get_Image (This : in Widget) return access FLTK.Images.Image'Class is begin return This.Current_Image; end Get_Image; procedure Set_Image (This : in out Widget; Pic : in out FLTK.Images.Image'Class) is begin This.Current_Image := Pic'Unchecked_Access; fl_widget_set_image (This.Void_Ptr, Wrapper (Pic).Void_Ptr); end Set_Image; function Get_Inactive_Image (This : in Widget) return access FLTK.Images.Image'Class is begin return This.Inactive_Image; end Get_Inactive_Image; procedure Set_Inactive_Image (This : in out Widget; Pic : in out FLTK.Images.Image'Class) is begin This.Inactive_Image := Pic'Unchecked_Access; fl_widget_set_deimage (This.Void_Ptr, Wrapper (Pic).Void_Ptr); end Set_Inactive_Image; function Is_Damaged (This : in Widget) return Boolean is begin return fl_widget_damage (This.Void_Ptr) /= 0; end Is_Damaged; procedure Set_Damaged (This : in out Widget; To : in Boolean) is begin fl_widget_set_damage (This.Void_Ptr, Boolean'Pos (To)); end Set_Damaged; procedure Set_Damaged (This : in out Widget; To : in Boolean; X, Y, W, H : in Integer) is begin fl_widget_set_damage2 (This.Void_Ptr, Boolean'Pos (To), Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H)); end Set_Damaged; procedure Draw_Label (This : in Widget; X, Y, W, H : in Integer; Align : in Alignment) is begin fl_widget_draw_label (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.unsigned (Align)); end Draw_Label; procedure Redraw (This : in out Widget) is begin fl_widget_redraw (This.Void_Ptr); end Redraw; procedure Redraw_Label (This : in out Widget) is begin fl_widget_redraw_label (This.Void_Ptr); end Redraw_Label; function Handle (This : in out Widget; Event : in Event_Kind) return Event_Outcome is begin return Not_Handled; end Handle; end FLTK.Widgets;
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with STM32F4.RCC; use STM32F4.RCC; package body STM32F429_Discovery is -------- -- On -- -------- procedure On (This : User_LED) is begin Set (GPIO_G, This); end On; --------- -- Off -- --------- procedure Off (This : User_LED) is begin Clear (GPIO_G, This); end Off; ------------ -- Toggle -- ------------ procedure Toggle (This : User_LED) is begin Toggle (GPIO_G, This); end Toggle; All_LEDs : constant GPIO_Pins := Green & Red; ------------------ -- All_LEDs_Off -- ------------------ procedure All_LEDs_Off is begin Clear (GPIO_G, ALL_LEDs); end All_LEDs_Off; ----------------- -- All_LEDs_On -- ----------------- procedure All_LEDs_On is begin Set (GPIO_G, ALL_LEDs); end All_LEDs_On; --------------------- -- Initialize_LEDs -- --------------------- procedure Initialize_LEDs is Conf : GPIO_Port_Configuration; begin Enable_Clock (GPIO_G); Conf.Mode := Mode_Out; Conf.Output_Type := Push_Pull; Conf.Speed := Speed_100MHz; Conf.Resistors := Floating; Configure_IO (GPIO_G, All_LEDs, Conf); end Initialize_LEDs; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out GPIO_Port) is begin if This'Address = System'To_Address (GPIOA_Base) then GPIOA_Clock_Enable; elsif This'Address = System'To_Address (GPIOB_Base) then GPIOB_Clock_Enable; elsif This'Address = System'To_Address (GPIOC_Base) then GPIOC_Clock_Enable; elsif This'Address = System'To_Address (GPIOD_Base) then GPIOD_Clock_Enable; elsif This'Address = System'To_Address (GPIOE_Base) then GPIOE_Clock_Enable; elsif This'Address = System'To_Address (GPIOF_Base) then GPIOF_Clock_Enable; elsif This'Address = System'To_Address (GPIOG_Base) then GPIOG_Clock_Enable; elsif This'Address = System'To_Address (GPIOH_Base) then GPIOH_Clock_Enable; elsif This'Address = System'To_Address (GPIOI_Base) then GPIOI_Clock_Enable; elsif This'Address = System'To_Address (GPIOJ_Base) then GPIOJ_Clock_Enable; elsif This'Address = System'To_Address (GPIOK_Base) then GPIOK_Clock_Enable; else raise Program_Error; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out USART) is begin if This'Address = System'To_Address (USART1_Base) then USART1_Clock_Enable; elsif This'Address = System'To_Address (USART2_Base) then USART2_Clock_Enable; elsif This'Address = System'To_Address (USART3_Base) then USART3_Clock_Enable; elsif This'Address = System'To_Address (USART6_Base) then USART6_Clock_Enable; else raise Program_Error; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out DMA_Controller) is begin if This'Address = System'To_Address (STM32F4.DMA1_BASE) then DMA1_Clock_Enable; elsif This'Address = System'To_Address (STM32F4.DMA2_BASE) then DMA2_Clock_Enable; else raise Program_Error; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out I2C_Port) is begin if This'Address = System'To_Address (I2C1_Base) then I2C1_Clock_Enable; elsif This'Address = System'To_Address (I2C2_Base) then I2C2_Clock_Enable; elsif This'Address = System'To_Address (I2C3_Base) then I2C3_Clock_Enable; else raise Program_Error; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out I2C_Port) is begin if This'Address = System'To_Address (I2C1_Base) then I2C1_Force_Reset; I2C1_Release_Reset; elsif This'Address = System'To_Address (I2C2_Base) then I2C2_Force_Reset; I2C2_Release_Reset; elsif This'Address = System'To_Address (I2C3_Base) then I2C3_Force_Reset; I2C3_Release_Reset; else raise Program_Error; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out SPI_Port) is begin if This'Address = System'To_Address (SPI1_Base) then SPI1_Force_Reset; SPI1_Release_Reset; elsif This'Address = System'To_Address (SPI2_Base) then SPI2_Force_Reset; SPI2_Release_Reset; elsif This'Address = System'To_Address (SPI3_Base) then SPI3_Force_Reset; SPI3_Release_Reset; elsif This'Address = System'To_Address (SPI4_Base) then SPI4_Force_Reset; SPI4_Release_Reset; elsif This'Address = System'To_Address (SPI5_Base) then SPI5_Force_Reset; SPI5_Release_Reset; elsif This'Address = System'To_Address (SPI6_Base) then SPI6_Force_Reset; SPI6_Release_Reset; else raise Program_Error; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out SPI_Port) is begin if This'Address = System'To_Address (SPI1_Base) then SPI1_Clock_Enable; elsif This'Address = System'To_Address (SPI2_Base) then SPI2_Clock_Enable; elsif This'Address = System'To_Address (SPI3_Base) then SPI3_Clock_Enable; elsif This'Address = System'To_Address (SPI4_Base) then SPI4_Clock_Enable; elsif This'Address = System'To_Address (SPI5_Base) then SPI5_Clock_Enable; elsif This'Address = System'To_Address (SPI6_Base) then SPI6_Clock_Enable; else raise Program_Error; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : in out Timer) is begin if This'Address = System'To_Address (TIM1_Base) then TIM1_Clock_Enable; elsif This'Address = System'To_Address (TIM2_Base) then TIM2_Clock_Enable; elsif This'Address = System'To_Address (TIM3_Base) then TIM3_Clock_Enable; elsif This'Address = System'To_Address (TIM4_Base) then TIM4_Clock_Enable; elsif This'Address = System'To_Address (TIM5_Base) then TIM5_Clock_Enable; elsif This'Address = System'To_Address (TIM6_Base) then TIM6_Clock_Enable; elsif This'Address = System'To_Address (TIM7_Base) then TIM7_Clock_Enable; elsif This'Address = System'To_Address (TIM8_Base) then TIM8_Clock_Enable; elsif This'Address = System'To_Address (TIM9_Base) then TIM9_Clock_Enable; elsif This'Address = System'To_Address (TIM10_Base) then TIM10_Clock_Enable; elsif This'Address = System'To_Address (TIM11_Base) then TIM11_Clock_Enable; elsif This'Address = System'To_Address (TIM12_Base) then TIM12_Clock_Enable; elsif This'Address = System'To_Address (TIM13_Base) then TIM13_Clock_Enable; elsif This'Address = System'To_Address (TIM14_Base) then TIM14_Clock_Enable; else raise Program_Error; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out Timer) is begin if This'Address = System'To_Address (TIM1_Base) then TIM1_Force_Reset; TIM1_Release_Reset; elsif This'Address = System'To_Address (TIM2_Base) then TIM2_Force_Reset; TIM2_Release_Reset; elsif This'Address = System'To_Address (TIM3_Base) then TIM3_Force_Reset; TIM3_Release_Reset; elsif This'Address = System'To_Address (TIM4_Base) then TIM4_Force_Reset; TIM4_Release_Reset; elsif This'Address = System'To_Address (TIM5_Base) then TIM5_Force_Reset; TIM5_Release_Reset; elsif This'Address = System'To_Address (TIM6_Base) then TIM6_Force_Reset; TIM6_Release_Reset; elsif This'Address = System'To_Address (TIM7_Base) then TIM7_Force_Reset; TIM7_Release_Reset; elsif This'Address = System'To_Address (TIM8_Base) then TIM8_Force_Reset; TIM8_Release_Reset; elsif This'Address = System'To_Address (TIM9_Base) then TIM9_Force_Reset; TIM9_Release_Reset; elsif This'Address = System'To_Address (TIM10_Base) then TIM10_Force_Reset; TIM10_Release_Reset; elsif This'Address = System'To_Address (TIM11_Base) then TIM11_Force_Reset; TIM11_Release_Reset; elsif This'Address = System'To_Address (TIM12_Base) then TIM12_Force_Reset; TIM12_Release_Reset; elsif This'Address = System'To_Address (TIM13_Base) then TIM13_Force_Reset; TIM13_Release_Reset; elsif This'Address = System'To_Address (TIM14_Base) then TIM14_Force_Reset; TIM14_Release_Reset; else raise Program_Error; end if; end Reset; end STM32F429_Discovery;
package body GNAT.Dynamic_HTables is package body Simple_HTable is function R (Position : Maps.Cursor) return Element; function R (Position : Maps.Cursor) return Element is begin if Maps.Has_Element (Position) then return Maps.Element (Position); else return No_Element; end if; end R; procedure Set (T : in out Instance; K : Key; E : Element) is begin Maps.Include (T.Map, K, E); end Set; procedure Reset (T : in out Instance) is begin Maps.Clear (T.Map); end Reset; function Get (T : Instance; K : Key) return Element is begin return R (Maps.Find (T.Map, K)); end Get; function Get_First (T : in out Instance) return Element is begin T.Position := Maps.First (T.Map); return R (T.Position); end Get_First; function Get_Next (T : in out Instance) return Element is begin if Maps.Has_Element (T.Position) then T.Position := Maps.Next (T.Position); end if; return R (T.Position); end Get_Next; function Hash (Item : Key) return Ada.Containers.Hash_Type is begin return Ada.Containers.Hash_Type'Mod (Header_Num'(Hash (Item))); end Hash; end Simple_HTable; end GNAT.Dynamic_HTables;
package Simple_Expression_Range is type Constrained_Type is new Integer range 1..10; end Simple_Expression_Range;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S I N P U T . L -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, 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, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Alloc; with Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; with Errout; use Errout; with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; with Output; use Output; with Prep; use Prep; with Prepcomp; use Prepcomp; with Scans; use Scans; with Scn; use Scn; with Sinfo; use Sinfo; with System; use System; with Unchecked_Conversion; package body Sinput.L is Prep_Buffer : Text_Buffer_Ptr := null; -- A buffer to temporarily stored the result of preprocessing a source. -- It is only allocated if there is at least one source to preprocess. Prep_Buffer_Last : Text_Ptr := 0; -- Index of the last significant character in Prep_Buffer Initial_Size_Of_Prep_Buffer : constant := 10_000; -- Size of Prep_Buffer when it is first allocated -- When a file is to be preprocessed and the options to list symbols -- has been selected (switch -s), Prep.List_Symbols is called with a -- "foreword", a single line indicationg what source the symbols apply to. -- The following two constant String are the start and the end of this -- foreword. Foreword_Start : constant String := "Preprocessing Symbols for source """; Foreword_End : constant String := """"; ----------------- -- Subprograms -- ----------------- procedure Put_Char_In_Prep_Buffer (C : Character); -- Add one character in Prep_Buffer, extending Prep_Buffer if need be. -- Used to initialize the preprocessor. procedure New_EOL_In_Prep_Buffer; -- Add an LF to Prep_Buffer. -- Used to initialize the preprocessor. function Load_File (N : File_Name_Type; T : Osint.File_Type) return Source_File_Index; -- Load a source file, a configuration pragmas file or a definition file -- Coding also allows preprocessing file, but not a library file ??? ------------------------------- -- Adjust_Instantiation_Sloc -- ------------------------------- procedure Adjust_Instantiation_Sloc (N : Node_Id; A : Sloc_Adjustment) is Loc : constant Source_Ptr := Sloc (N); begin -- We only do the adjustment if the value is between the appropriate -- low and high values. It is not clear that this should ever not be -- the case, but in practice there seem to be some nodes that get -- copied twice, and this is a defence against that happening. if A.Lo <= Loc and then Loc <= A.Hi then Set_Sloc (N, Loc + A.Adjust); end if; end Adjust_Instantiation_Sloc; -------------------------------- -- Complete_Source_File_Entry -- -------------------------------- procedure Complete_Source_File_Entry is CSF : constant Source_File_Index := Current_Source_File; begin Trim_Lines_Table (CSF); Source_File.Table (CSF).Source_Checksum := Checksum; end Complete_Source_File_Entry; --------------------------------- -- Create_Instantiation_Source -- --------------------------------- procedure Create_Instantiation_Source (Inst_Node : Entity_Id; Template_Id : Entity_Id; Inlined_Body : Boolean; A : out Sloc_Adjustment) is Dnod : constant Node_Id := Declaration_Node (Template_Id); Xold : Source_File_Index; Xnew : Source_File_Index; begin Xold := Get_Source_File_Index (Sloc (Template_Id)); A.Lo := Source_File.Table (Xold).Source_First; A.Hi := Source_File.Table (Xold).Source_Last; Source_File.Increment_Last; Xnew := Source_File.Last; Source_File.Table (Xnew) := Source_File.Table (Xold); Source_File.Table (Xnew).Inlined_Body := Inlined_Body; Source_File.Table (Xnew).Instantiation := Sloc (Inst_Node); Source_File.Table (Xnew).Template := Xold; -- Now we need to compute the new values of Source_First, Source_Last -- and adjust the source file pointer to have the correct virtual -- origin for the new range of values. Source_File.Table (Xnew).Source_First := Source_File.Table (Xnew - 1).Source_Last + 1; A.Adjust := Source_File.Table (Xnew).Source_First - A.Lo; Source_File.Table (Xnew).Source_Last := A.Hi + A.Adjust; Set_Source_File_Index_Table (Xnew); Source_File.Table (Xnew).Sloc_Adjust := Source_File.Table (Xold).Sloc_Adjust - A.Adjust; if Debug_Flag_L then Write_Eol; Write_Str ("*** Create instantiation source for "); if Nkind (Dnod) in N_Proper_Body and then Was_Originally_Stub (Dnod) then Write_Str ("subunit "); elsif Ekind (Template_Id) = E_Generic_Package then if Nkind (Dnod) = N_Package_Body then Write_Str ("body of package "); else Write_Str ("spec of package "); end if; elsif Ekind (Template_Id) = E_Function then Write_Str ("body of function "); elsif Ekind (Template_Id) = E_Procedure then Write_Str ("body of procedure "); elsif Ekind (Template_Id) = E_Generic_Function then Write_Str ("spec of function "); elsif Ekind (Template_Id) = E_Generic_Procedure then Write_Str ("spec of procedure "); elsif Ekind (Template_Id) = E_Package_Body then Write_Str ("body of package "); else pragma Assert (Ekind (Template_Id) = E_Subprogram_Body); if Nkind (Dnod) = N_Procedure_Specification then Write_Str ("body of procedure "); else Write_Str ("body of function "); end if; end if; Write_Name (Chars (Template_Id)); Write_Eol; Write_Str (" new source index = "); Write_Int (Int (Xnew)); Write_Eol; Write_Str (" copying from file name = "); Write_Name (File_Name (Xold)); Write_Eol; Write_Str (" old source index = "); Write_Int (Int (Xold)); Write_Eol; Write_Str (" old lo = "); Write_Int (Int (A.Lo)); Write_Eol; Write_Str (" old hi = "); Write_Int (Int (A.Hi)); Write_Eol; Write_Str (" new lo = "); Write_Int (Int (Source_File.Table (Xnew).Source_First)); Write_Eol; Write_Str (" new hi = "); Write_Int (Int (Source_File.Table (Xnew).Source_Last)); Write_Eol; Write_Str (" adjustment factor = "); Write_Int (Int (A.Adjust)); Write_Eol; Write_Str (" instantiation location: "); Write_Location (Sloc (Inst_Node)); Write_Eol; end if; -- For a given character in the source, a higher subscript will be -- used to access the instantiation, which means that the virtual -- origin must have a corresponding lower value. We compute this -- new origin by taking the address of the appropriate adjusted -- element in the old array. Since this adjusted element will be -- at a negative subscript, we must suppress checks. declare pragma Suppress (All_Checks); pragma Warnings (Off); -- This unchecked conversion is aliasing safe, since it is never -- used to create improperly aliased pointer values. function To_Source_Buffer_Ptr is new Unchecked_Conversion (Address, Source_Buffer_Ptr); pragma Warnings (On); begin Source_File.Table (Xnew).Source_Text := To_Source_Buffer_Ptr (Source_File.Table (Xold).Source_Text (-A.Adjust)'Address); end; end Create_Instantiation_Source; ---------------------- -- Load_Config_File -- ---------------------- function Load_Config_File (N : File_Name_Type) return Source_File_Index is begin return Load_File (N, Osint.Config); end Load_Config_File; -------------------------- -- Load_Definition_File -- -------------------------- function Load_Definition_File (N : File_Name_Type) return Source_File_Index is begin return Load_File (N, Osint.Definition); end Load_Definition_File; --------------- -- Load_File -- --------------- function Load_File (N : File_Name_Type; T : Osint.File_Type) return Source_File_Index is Src : Source_Buffer_Ptr; X : Source_File_Index; Lo : Source_Ptr; Hi : Source_Ptr; Preprocessing_Needed : Boolean := False; begin -- If already there, don't need to reload file. An exception occurs -- in multiple unit per file mode. It would be nice in this case to -- share the same source file for each unit, but this leads to many -- difficulties with assumptions (e.g. in the body of lib), that a -- unit can be found by locating its source file index. Since we do -- not expect much use of this mode, it's no big deal to waste a bit -- of space and time by reading and storing the source multiple times. if Multiple_Unit_Index = 0 then for J in 1 .. Source_File.Last loop if Source_File.Table (J).File_Name = N then return J; end if; end loop; end if; -- Here we must build a new entry in the file table -- But first, we must check if a source needs to be preprocessed, -- because we may have to load and parse a definition file, and we want -- to do that before we load the source, so that the buffer of the -- source will be the last created, and we will be able to replace it -- and modify Hi without stepping on another buffer. if T = Osint.Source then Prepare_To_Preprocess (Source => N, Preprocessing_Needed => Preprocessing_Needed); end if; Source_File.Increment_Last; X := Source_File.Last; if X = Source_File.First then Lo := First_Source_Ptr; else Lo := Source_File.Table (X - 1).Source_Last + 1; end if; Osint.Read_Source_File (N, Lo, Hi, Src, T); if Src = null then Source_File.Decrement_Last; return No_Source_File; else if Debug_Flag_L then Write_Eol; Write_Str ("*** Build source file table entry, Index = "); Write_Int (Int (X)); Write_Str (", file name = "); Write_Name (N); Write_Eol; Write_Str (" lo = "); Write_Int (Int (Lo)); Write_Eol; Write_Str (" hi = "); Write_Int (Int (Hi)); Write_Eol; Write_Str (" first 10 chars -->"); declare procedure Wchar (C : Character); -- Writes character or ? for control character procedure Wchar (C : Character) is begin if C < ' ' or C in ASCII.DEL .. Character'Val (16#9F#) then Write_Char ('?'); else Write_Char (C); end if; end Wchar; begin for J in Lo .. Lo + 9 loop Wchar (Src (J)); end loop; Write_Str ("<--"); Write_Eol; Write_Str (" last 10 chars -->"); for J in Hi - 10 .. Hi - 1 loop Wchar (Src (J)); end loop; Write_Str ("<--"); Write_Eol; if Src (Hi) /= EOF then Write_Str (" error: no EOF at end"); Write_Eol; end if; end; end if; declare S : Source_File_Record renames Source_File.Table (X); File_Type : Type_Of_File; begin case T is when Osint.Source => File_Type := Sinput.Src; when Osint.Library => raise Program_Error; when Osint.Config => File_Type := Sinput.Config; when Osint.Definition => File_Type := Def; when Osint.Preprocessing_Data => File_Type := Preproc; end case; S := (Debug_Source_Name => N, File_Name => N, File_Type => File_Type, First_Mapped_Line => No_Line_Number, Full_Debug_Name => Osint.Full_Source_Name, Full_File_Name => Osint.Full_Source_Name, Full_Ref_Name => Osint.Full_Source_Name, Identifier_Casing => Unknown, Inlined_Body => False, Instantiation => No_Location, Keyword_Casing => Unknown, Last_Source_Line => 1, License => Unknown, Lines_Table => null, Lines_Table_Max => 1, Logical_Lines_Table => null, Num_SRef_Pragmas => 0, Reference_Name => N, Sloc_Adjust => 0, Source_Checksum => 0, Source_First => Lo, Source_Last => Hi, Source_Text => Src, Template => No_Source_File, Unit => No_Unit, Time_Stamp => Osint.Current_Source_File_Stamp); Alloc_Line_Tables (S, Opt.Table_Factor * Alloc.Lines_Initial); S.Lines_Table (1) := Lo; end; -- Preprocess the source if it needs to be preprocessed if Preprocessing_Needed then if Opt.List_Preprocessing_Symbols then Get_Name_String (N); declare Foreword : String (1 .. Foreword_Start'Length + Name_Len + Foreword_End'Length); begin Foreword (1 .. Foreword_Start'Length) := Foreword_Start; Foreword (Foreword_Start'Length + 1 .. Foreword_Start'Length + Name_Len) := Name_Buffer (1 .. Name_Len); Foreword (Foreword'Last - Foreword_End'Length + 1 .. Foreword'Last) := Foreword_End; Prep.List_Symbols (Foreword); end; end if; declare T : constant Nat := Total_Errors_Detected; -- Used to check if there were errors during preprocessing begin -- If this is the first time we preprocess a source, allocate -- the preprocessing buffer. if Prep_Buffer = null then Prep_Buffer := new Text_Buffer (1 .. Initial_Size_Of_Prep_Buffer); end if; -- Make sure the preprocessing buffer is empty Prep_Buffer_Last := 0; -- Initialize the preprocessor Prep.Initialize (Error_Msg => Errout.Error_Msg'Access, Scan => Scn.Scanner.Scan'Access, Set_Ignore_Errors => Errout.Set_Ignore_Errors'Access, Put_Char => Put_Char_In_Prep_Buffer'Access, New_EOL => New_EOL_In_Prep_Buffer'Access); -- Initialize the scanner and set its behavior for -- preprocessing, then preprocess. Scn.Scanner.Initialize_Scanner (X); Scn.Scanner.Set_Special_Character ('#'); Scn.Scanner.Set_Special_Character ('$'); Scn.Scanner.Set_End_Of_Line_As_Token (True); Preprocess; -- Reset the scanner to its standard behavior Scn.Scanner.Reset_Special_Characters; Scn.Scanner.Set_End_Of_Line_As_Token (False); -- If there were errors during preprocessing, record an -- error at the start of the file, and do not change the -- source buffer. if T /= Total_Errors_Detected then Errout.Error_Msg ("file could not be successfully preprocessed", Lo); return No_Source_File; else -- Set the new value of Hi Hi := Lo + Source_Ptr (Prep_Buffer_Last); -- Create the new source buffer declare subtype Actual_Source_Buffer is Source_Buffer (Lo .. Hi); -- Physical buffer allocated type Actual_Source_Ptr is access Actual_Source_Buffer; -- This is the pointer type for the physical buffer -- allocated. Actual_Ptr : constant Actual_Source_Ptr := new Actual_Source_Buffer; -- And this is the actual physical buffer begin Actual_Ptr (Lo .. Hi - 1) := Prep_Buffer (1 .. Prep_Buffer_Last); Actual_Ptr (Hi) := EOF; -- Now we need to work out the proper virtual origin -- pointer to return. This is exactly -- Actual_Ptr (0)'Address, but we have to be careful to -- suppress checks to compute this address. declare pragma Suppress (All_Checks); pragma Warnings (Off); -- This unchecked conversion is aliasing safe, since -- it is never used to create improperly aliased -- pointer values. function To_Source_Buffer_Ptr is new Unchecked_Conversion (Address, Source_Buffer_Ptr); pragma Warnings (On); begin Src := To_Source_Buffer_Ptr (Actual_Ptr (0)'Address); -- Record in the table the new source buffer and the -- new value of Hi. Source_File.Table (X).Source_Text := Src; Source_File.Table (X).Source_Last := Hi; -- Reset Last_Line to 1, because the lines do not -- have neccessarily the same starts and lengths. Source_File.Table (X).Last_Source_Line := 1; end; end; end if; end; end if; Set_Source_File_Index_Table (X); return X; end if; end Load_File; ---------------------------------- -- Load_Preprocessing_Data_File -- ---------------------------------- function Load_Preprocessing_Data_File (N : File_Name_Type) return Source_File_Index is begin return Load_File (N, Osint.Preprocessing_Data); end Load_Preprocessing_Data_File; ---------------------- -- Load_Source_File -- ---------------------- function Load_Source_File (N : File_Name_Type) return Source_File_Index is begin return Load_File (N, Osint.Source); end Load_Source_File; ---------------------------- -- New_EOL_In_Prep_Buffer -- ---------------------------- procedure New_EOL_In_Prep_Buffer is begin Put_Char_In_Prep_Buffer (ASCII.LF); end New_EOL_In_Prep_Buffer; ----------------------------- -- Put_Char_In_Prep_Buffer -- ----------------------------- procedure Put_Char_In_Prep_Buffer (C : Character) is begin -- If preprocessing buffer is not large enough, double it if Prep_Buffer_Last = Prep_Buffer'Last then declare New_Prep_Buffer : constant Text_Buffer_Ptr := new Text_Buffer (1 .. 2 * Prep_Buffer_Last); begin New_Prep_Buffer (Prep_Buffer'Range) := Prep_Buffer.all; Free (Prep_Buffer); Prep_Buffer := New_Prep_Buffer; end; end if; Prep_Buffer_Last := Prep_Buffer_Last + 1; Prep_Buffer (Prep_Buffer_Last) := C; end Put_Char_In_Prep_Buffer; ---------------------------- -- Source_File_Is_Subunit -- ---------------------------- function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is begin Initialize_Scanner (No_Unit, X); -- We scan past junk to the first interesting compilation unit -- token, to see if it is SEPARATE. We ignore WITH keywords during -- this and also PRIVATE. The reason for ignoring PRIVATE is that -- it handles some error situations, and also it is possible that -- a PRIVATE WITH feature might be approved some time in the future. while Token = Tok_With or else Token = Tok_Private or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF) loop Scan; end loop; return Token = Tok_Separate; end Source_File_Is_Subunit; end Sinput.L;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package contains declarations of constants used in several places of -- SOAP implementation. ------------------------------------------------------------------------------ with Ada.Streams; with League.Strings; with League.Stream_Element_Vectors; package Web_Services.SOAP.Constants is -- Namespace URI and local name of 'xml:lang' attribute. XML_URI : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("http://www.w3.org/XML/1998/namespace"); XML_Lang_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("lang"); -- XML langauge codes. XML_EN_US_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("en-US"); -- SOAP Envelope namespace URI, names of elements and attributes in this -- namespace. SOAP_Encoding_Style_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("encodingStyle"); SOAP_Envelope_URI : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("http://www.w3.org/2003/05/soap-envelope"); SOAP_Envelope_Prefix : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("env"); SOAP_Body_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Body"); SOAP_Code_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Code"); SOAP_Detail_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Detail"); SOAP_Envelope_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Envelope"); SOAP_Fault_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Fault"); SOAP_Header_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Header"); SOAP_Reason_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Reason"); SOAP_Subcode_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Subcode"); SOAP_Text_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Text"); SOAP_Value_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Value"); SOAP_Must_Understand_Name : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("mustUnderstand"); -- SOAP RPC namespace URI and prefix. SOAP_RPC_URI : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("http://www.w3.org/2003/05/soap-rpc"); SOAP_RPC_Prefix : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("rpc"); -- Codes of SOAP faults. SOAP_Version_Mismatch_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("VersionMismatch"); SOAP_Must_Understand_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("MustUnderstand"); SOAP_Data_Encoding_Unknown_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("DataEncodingUnknown"); SOAP_Sender_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Sender"); SOAP_Receiver_Code : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Receiver"); -- Subcodes of SOAP RPC faults. SOAP_Procedure_Not_Present_Subcode : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("ProcedureNotPresent"); -- Some literals for values of attributes. SOAP_True_Literal : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("true"); -- "text/plain" Stream_Element_Array Text_Plain_Array : constant Ada.Streams.Stream_Element_Array := (Character'Pos ('t'), Character'Pos ('e'), Character'Pos ('x'), Character'Pos ('t'), Character'Pos ('/'), Character'Pos ('p'), Character'Pos ('l'), Character'Pos ('a'), Character'Pos ('i'), Character'Pos ('n')); -- "application/soap+xml" Stream_Element_Array Application_SOAP_XML_Array : constant Ada.Streams.Stream_Element_Array := (Character'Pos ('a'), Character'Pos ('p'), Character'Pos ('p'), Character'Pos ('l'), Character'Pos ('i'), Character'Pos ('c'), Character'Pos ('a'), Character'Pos ('t'), Character'Pos ('i'), Character'Pos ('o'), Character'Pos ('n'), Character'Pos ('/'), Character'Pos ('s'), Character'Pos ('o'), Character'Pos ('a'), Character'Pos ('p'), Character'Pos ('+'), Character'Pos ('x'), Character'Pos ('m'), Character'Pos ('l')); MIME_Text_Plain : constant League.Stream_Element_Vectors.Stream_Element_Vector := League.Stream_Element_Vectors.To_Stream_Element_Vector (Text_Plain_Array); MIME_Application_SOAP_XML : constant League.Stream_Element_Vectors.Stream_Element_Vector := League.Stream_Element_Vectors.To_Stream_Element_Vector (Application_SOAP_XML_Array); end Web_Services.SOAP.Constants;
--logic for exponents to work correctly package body Integer_Exponentiation is -- int^int procedure Exponentiate (Argument : in Integer; Exponent : in Natural; Result : out Integer) is begin Result := 1; for Counter in 1 .. Exponent loop Result := Result * Argument; end loop; end Exponentiate; function "**" (Left : Integer; Right : Natural) return Integer is Result : Integer; begin Exponentiate (Argument => Left, Exponent => Right, Result => Result); return Result; end "**"; -- real^int procedure Exponentiate (Argument : in Float; Exponent : in Integer; Result : out Float) is begin Result := 1.0; if Exponent < 0 then for Counter in Exponent .. -1 loop Result := Result / Argument; end loop; else for Counter in 1 .. Exponent loop Result := Result * Argument; end loop; end if; end Exponentiate; function "**" (Left : Float; Right : Integer) return Float is Result : Float; begin Exponentiate (Argument => Left, Exponent => Right, Result => Result); return Result; end "**"; end Integer_Exponentiation;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M E M O R Y -- -- -- -- B o d y -- -- -- -- Copyright (C) 2013-2021, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Simple implementation for use with Ravenscar Minimal. This implementation -- is based on a simple static buffer (whose bounds are defined in the linker -- script), and allocation is performed through a protected object to -- protect against concurrency. pragma Restrictions (No_Elaboration_Code); -- This unit may be linked without being with'ed, so we need to ensure -- there is no elaboration code (since this code might not be executed). with System.Storage_Elements; package body System.Memory is use System.Storage_Elements; Heap_Start : Character; for Heap_Start'Alignment use Standard'Maximum_Alignment; pragma Import (C, Heap_Start, "__heap_start"); -- The address of the variable is the start of the heap Heap_End : Character; pragma Import (C, Heap_End, "__heap_end"); -- The address of the variable is the end of the heap Top : aliased Address := Heap_Start'Address; -- First not used address (always aligned to the maximum alignment). ---------------- -- For C code -- ---------------- function Malloc (Size : size_t) return System.Address; pragma Export (C, Malloc, "malloc"); function Calloc (N_Elem : size_t; Elem_Size : size_t) return System.Address; pragma Export (C, Calloc, "calloc"); procedure Free (Ptr : System.Address); pragma Export (C, Free, "free"); ----------- -- Alloc -- ----------- function Alloc (Size : size_t) return System.Address is function Compare_And_Swap (Ptr : access Address; Old_Val : Integer_Address; New_Val : Integer_Address) return Boolean; pragma Import (Intrinsic, Compare_And_Swap, "__sync_bool_compare_and_swap_" & (case System.Word_Size is when 32 => "4", when 64 => "8", when others => "unexpected")); Max_Align : constant := Standard'Maximum_Alignment; Max_Size : Storage_Count; Res : Address; begin if Size = 0 then -- Change size from zero to non-zero. We still want a proper pointer -- for the zero case because pointers to zero length objects have to -- be distinct. Max_Size := Max_Align; else -- Detect overflow in the addition below. Note that we know that -- upper bound of size_t is bigger than the upper bound of -- Storage_Count. if Size > size_t (Storage_Count'Last - Max_Align) then raise Storage_Error; end if; -- Compute aligned size Max_Size := ((Storage_Count (Size) + Max_Align - 1) / Max_Align) * Max_Align; end if; loop Res := Top; -- Detect too large allocation if Max_Size >= Storage_Count (Heap_End'Address - Res) then raise Storage_Error; end if; -- Atomically update the top of the heap. Restart in case of -- failure (concurrent allocation). exit when Compare_And_Swap (Top'Access, Integer_Address (Res), Integer_Address (Res + Max_Size)); end loop; return Res; end Alloc; ------------ -- Malloc -- ------------ function Malloc (Size : size_t) return System.Address is begin return Alloc (Size); end Malloc; ------------ -- Calloc -- ------------ function Calloc (N_Elem : size_t; Elem_Size : size_t) return System.Address is begin return Malloc (N_Elem * Elem_Size); end Calloc; ---------- -- Free -- ---------- procedure Free (Ptr : System.Address) is pragma Unreferenced (Ptr); begin null; end Free; end System.Memory;
package Ada_Module is procedure Say_Hello; pragma Export (C, Say_Hello, "say_hello"); end Ada_Module;
------------------------------------------------------------------------------- -- Copyright 2021, The Trendy Terminal Developers (see AUTHORS file) -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; with Interfaces.C.Strings; --------------------------------------------------------------------------- -- Win32 API functions -- -- https://docs.microsoft.com/en-us/windows/console/classic-vs-vt --------------------------------------------------------------------------- package Trendy_Terminal.Windows is type LONG is new Interfaces.C.long; type DWORD is new Interfaces.C.unsigned_long; type HANDLE is new Interfaces.C.ptrdiff_t; type LPDWORD is access all DWORD; type BOOL is new Interfaces.C.int; type UINT is new Interfaces.C.unsigned; function To_DWORD is new Ada.Unchecked_Conversion (LONG, DWORD); INVALID_HANDLE_VALUE : constant := -1; STD_INPUT_HANDLE : constant DWORD := To_DWORD (-10); STD_OUTPUT_HANDLE : constant DWORD := To_DWORD (-11); STD_ERROR_HANDLE : constant DWORD := To_DWORD (-12); function GetStdHandle (Std_Handle : DWORD) return HANDLE; function GetConsoleMode (H : HANDLE; Mode : LPDWORD) return BOOL; function SetConsoleMode (H : HANDLE; dwMode : DWORD) return BOOL; function GetLastError return DWORD; CP_UTF8 : constant := 65_001; function GetConsoleCP return UINT; function GetConsoleOutputCP return UINT; function SetConsoleCP (wCodePageID : UINT) return BOOL; function SetConsoleOutputCP (wCodePageID : UINT) return BOOL; pragma Import (Stdcall, GetStdHandle, "GetStdHandle"); pragma Import (Stdcall, GetConsoleMode, "GetConsoleMode"); pragma Import (Stdcall, SetConsoleMode, "SetConsoleMode"); pragma Import (Stdcall, GetLastError, "GetLastError"); pragma Import (Stdcall, GetConsoleCP, "GetConsoleCP"); pragma Import (Stdcall, SetConsoleCP, "SetConsoleCP"); pragma Import (Stdcall, GetConsoleOutputCP, "GetConsoleOutputCP"); pragma Import (Stdcall, SetConsoleOutputCP, "SetConsoleOutputCP"); type Console_Input_Flags is ( ENABLE_PROCESSED_INPUT, ENABLE_LINE_INPUT, ENABLE_ECHO_INPUT, ENABLE_WINDOW_INPUT, ENABLE_MOUSE_INPUT, ENABLE_INSERT_MODE, ENABLE_QUICK_EDIT_MODE, ENABLE_EXTENDED_FLAGS, ENABLE_AUTO_POSITION, ENABLE_VIRTUAL_TERMINAL_INPUT); for Console_Input_Flags use ( ENABLE_PROCESSED_INPUT => 16#0001#, ENABLE_LINE_INPUT => 16#0002#, ENABLE_ECHO_INPUT => 16#0004#, ENABLE_WINDOW_INPUT => 16#0008#, ENABLE_MOUSE_INPUT => 16#0010#, ENABLE_INSERT_MODE => 16#0020#, ENABLE_QUICK_EDIT_MODE => 16#0040#, ENABLE_EXTENDED_FLAGS => 16#0080#, ENABLE_AUTO_POSITION => 16#0100#, ENABLE_VIRTUAL_TERMINAL_INPUT => 16#0200#); type Console_Output_Flags is ( ENABLE_PROCESSED_OUTPUT, ENABLE_WRAP_AT_EOL_OUTPUT, ENABLE_VIRTUAL_TERMINAL_PROCESSING, DISABLE_NEWLINE_AUTO_RETURN, ENABLE_LVB_GRID_WORLDWIDE); for Console_Output_Flags use ( ENABLE_PROCESSED_OUTPUT => 16#0001#, ENABLE_WRAP_AT_EOL_OUTPUT => 16#0002#, ENABLE_VIRTUAL_TERMINAL_PROCESSING => 16#0004#, DISABLE_NEWLINE_AUTO_RETURN => 16#0008#, ENABLE_LVB_GRID_WORLDWIDE => 16#0010#); pragma Warnings (Off, "bits of *unused"); type Console_Input_Mode is array (Console_Input_Flags) of Boolean with Pack, Size => 32; type Console_Output_Mode is array (Console_Output_Flags) of Boolean with Pack, Size => 32; pragma Warnings (On, "bits of *unused"); function To_Console_Input_Mode is new Ada.Unchecked_Conversion (DWORD, Console_Input_Mode); function To_Console_Output_Mode is new Ada.Unchecked_Conversion (DWORD, Console_Output_Mode); function To_DWORD is new Ada.Unchecked_Conversion (Console_Input_Mode, DWORD); function To_DWORD is new Ada.Unchecked_Conversion (Console_Output_Mode, DWORD); type LPVOID is new Interfaces.C.Strings.chars_ptr; type LPCVOID is new Interfaces.C.Strings.chars_ptr; type LPOVERLAPPED is new Interfaces.C.ptrdiff_t; function WriteFile(hFile : HANDLE; lpBuffer : LPCVOID; BytesToWrite : DWORD; NumBytesWritten : LPDWORD; Overlapped : LPOVERLAPPED) return BOOL; pragma Import (Stdcall, WriteFile, "WriteFile"); function ReadConsoleA (I : HANDLE; Buffer : LPVOID; Buffer_Size : DWORD; Characters_Read : LPDWORD; Console_Control : Interfaces.C.ptrdiff_t) return BOOL; pragma Import (Stdcall, ReadConsoleA, "ReadConsoleA"); end Trendy_Terminal.Windows;
with ada.text_io, ada.integer_text_io; use ada.text_io, ada.integer_text_io; procedure sacar_ficha is begin put("Ficha sale"); end sacar_ficha;
private with Ada.Finalization; private with Ada.Streams; package GMP.Z is pragma Preelaborate; type MP_Integer is private; -- conversions function To_MP_Integer (X : Long_Long_Integer) return MP_Integer; -- formatting function Image (Value : MP_Integer; Base : Number_Base := 10) return String; function Value (Image : String; Base : Number_Base := 10) return MP_Integer; -- relational operators function "=" (Left, Right : MP_Integer) return Boolean; function "<" (Left, Right : MP_Integer) return Boolean; function ">" (Left, Right : MP_Integer) return Boolean; function "<=" (Left, Right : MP_Integer) return Boolean; function ">=" (Left, Right : MP_Integer) return Boolean; -- unary adding operators function "+" (Right : MP_Integer) return MP_Integer; function "-" (Right : MP_Integer) return MP_Integer; -- binary adding operators function "+" (Left, Right : MP_Integer) return MP_Integer; function "-" (Left, Right : MP_Integer) return MP_Integer; -- multiplying operators function "*" (Left, Right : MP_Integer) return MP_Integer; function "/" (Left, Right : MP_Integer) return MP_Integer; -- highest precedence operators function "**" (Left : MP_Integer; Right : Natural) return MP_Integer; -- subprograms of a scalar type function Copy_Sign (Value, Sign : MP_Integer) return MP_Integer; function Copy_Sign (Value : MP_Integer; Sign : Integer) return MP_Integer; function Copy_Sign (Value : Integer; Sign : MP_Integer) return Integer; private package Controlled is type MP_Integer is private; function Reference (Item : in out Z.MP_Integer) return not null access C.gmp.mpz_struct; function Constant_Reference (Item : Z.MP_Integer) return not null access constant C.gmp.mpz_struct; pragma Inline (Reference); pragma Inline (Constant_Reference); private type MP_Integer is new Ada.Finalization.Controlled with record Raw : aliased C.gmp.mpz_t := (others => (others => <>)); end record; overriding procedure Initialize (Object : in out MP_Integer); overriding procedure Adjust (Object : in out MP_Integer); overriding procedure Finalize (Object : in out MP_Integer); end Controlled; type MP_Integer is new Controlled.MP_Integer; procedure Read ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out MP_Integer); procedure Write ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in MP_Integer); for MP_Integer'Read use Read; for MP_Integer'Write use Write; procedure Read ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : not null access C.gmp.mpz_struct); procedure Write ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : not null access constant C.gmp.mpz_struct); end GMP.Z;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S C N -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Csets; use Csets; with Errout; use Errout; with Hostparm; use Hostparm; with Namet; use Namet; with Opt; use Opt; with Scans; use Scans; with Sinput; use Sinput; with Sinfo; use Sinfo; with Snames; use Snames; with Style; with Widechar; use Widechar; with System.CRC32; with System.WCh_Con; use System.WCh_Con; package body Scn is use ASCII; -- Make control characters visible Used_As_Identifier : array (Token_Type) of Boolean; -- Flags set True if a given keyword is used as an identifier (used to -- make sure that we only post an error message for incorrect use of a -- keyword as an identifier once for a given keyword). ----------------------- -- Local Subprograms -- ----------------------- procedure Accumulate_Checksum (C : Character); pragma Inline (Accumulate_Checksum); -- This routine accumulates the checksum given character C. During the -- scanning of a source file, this routine is called with every character -- in the source, excluding blanks, and all control characters (except -- that ESC is included in the checksum). Upper case letters not in string -- literals are folded by the caller. See Sinput spec for the documentation -- of the checksum algorithm. Note: checksum values are only used if we -- generate code, so it is not necessary to worry about making the right -- sequence of calls in any error situation. procedure Accumulate_Checksum (C : Char_Code); pragma Inline (Accumulate_Checksum); -- This version is identical, except that the argument, C, is a character -- code value instead of a character. This is used when wide characters -- are scanned. We use the character code rather than the ASCII characters -- so that the checksum is independent of wide character encoding method. procedure Initialize_Checksum; pragma Inline (Initialize_Checksum); -- Initialize checksum value procedure Check_End_Of_Line; -- Called when end of line encountered. Checks that line is not -- too long, and that other style checks for the end of line are met. function Determine_License return License_Type; -- Scan header of file and check that it has an appropriate GNAT-style -- header with a proper license statement. Returns GPL, Unrestricted, -- or Modified_GPL depending on header. If none of these, returns Unknown. function Double_Char_Token (C : Character) return Boolean; -- This function is used for double character tokens like := or <>. It -- checks if the character following Source (Scan_Ptr) is C, and if so -- bumps Scan_Ptr past the pair of characters and returns True. A space -- between the two characters is also recognized with an appropriate -- error message being issued. If C is not present, False is returned. -- Note that Double_Char_Token can only be used for tokens defined in -- the Ada syntax (it's use for error cases like && is not appropriate -- since we do not want a junk message for a case like &-space-&). procedure Error_Illegal_Character; -- Give illegal character error, Scan_Ptr points to character. On return, -- Scan_Ptr is bumped past the illegal character. procedure Error_Illegal_Wide_Character; -- Give illegal wide character message. On return, Scan_Ptr is bumped -- past the illegal character, which may still leave us pointing to -- junk, not much we can do if the escape sequence is messed up! procedure Error_Long_Line; -- Signal error of excessively long line procedure Error_No_Double_Underline; -- Signal error of double underline character procedure Nlit; -- This is the procedure for scanning out numeric literals. On entry, -- Scan_Ptr points to the digit that starts the numeric literal (the -- checksum for this character has not been accumulated yet). On return -- Scan_Ptr points past the last character of the numeric literal, Token -- and Token_Node are set appropriately, and the checksum is updated. function Set_Start_Column return Column_Number; -- This routine is called with Scan_Ptr pointing to the first character -- of a line. On exit, Scan_Ptr is advanced to the first non-blank -- character of this line (or to the terminating format effector if the -- line contains no non-blank characters), and the returned result is the -- column number of this non-blank character (zero origin), which is the -- value to be stored in the Start_Column scan variable. procedure Slit; -- This is the procedure for scanning out string literals. On entry, -- Scan_Ptr points to the opening string quote (the checksum for this -- character has not been accumulated yet). On return Scan_Ptr points -- past the closing quote of the string literal, Token and Token_Node -- are set appropriately, and the checksum is upated. ------------------------- -- Accumulate_Checksum -- ------------------------- procedure Accumulate_Checksum (C : Character) is begin System.CRC32.Update (System.CRC32.CRC32 (Checksum), C); end Accumulate_Checksum; procedure Accumulate_Checksum (C : Char_Code) is begin Accumulate_Checksum (Character'Val (C / 256)); Accumulate_Checksum (Character'Val (C mod 256)); end Accumulate_Checksum; ----------------------- -- Check_End_Of_Line -- ----------------------- procedure Check_End_Of_Line is Len : constant Int := Int (Scan_Ptr) - Int (Current_Line_Start); begin if Len > Hostparm.Max_Line_Length then Error_Long_Line; elsif Style_Check then Style.Check_Line_Terminator (Len); end if; end Check_End_Of_Line; ----------------------- -- Determine_License -- ----------------------- function Determine_License return License_Type is GPL_Found : Boolean := False; function Contains (S : String) return Boolean; -- See if current comment contains successive non-blank characters -- matching the contents of S. If so leave Scan_Ptr unchanged and -- return True, otherwise leave Scan_Ptr unchanged and return False. procedure Skip_EOL; -- Skip to line terminator character -------------- -- Contains -- -------------- function Contains (S : String) return Boolean is CP : Natural; SP : Source_Ptr; SS : Source_Ptr; begin SP := Scan_Ptr; while Source (SP) /= CR and then Source (SP) /= LF loop if Source (SP) = S (S'First) then SS := SP; CP := S'First; loop SS := SS + 1; CP := CP + 1; if CP > S'Last then return True; end if; while Source (SS) = ' ' loop SS := SS + 1; end loop; exit when Source (SS) /= S (CP); end loop; end if; SP := SP + 1; end loop; return False; end Contains; -------------- -- Skip_EOL -- -------------- procedure Skip_EOL is begin while Source (Scan_Ptr) /= CR and then Source (Scan_Ptr) /= LF loop Scan_Ptr := Scan_Ptr + 1; end loop; end Skip_EOL; -- Start of processing for Determine_License begin loop if Source (Scan_Ptr) /= '-' or else Source (Scan_Ptr + 1) /= '-' then if GPL_Found then return GPL; else return Unknown; end if; elsif Contains ("Asaspecialexception") then if GPL_Found then return Modified_GPL; end if; elsif Contains ("GNUGeneralPublicLicense") then GPL_Found := True; elsif Contains ("ThisspecificationisadaptedfromtheAdaSemanticInterface") or else Contains ("ThisspecificationisderivedfromtheAdaReferenceManual") then return Unrestricted; end if; Skip_EOL; Check_End_Of_Line; declare Physical : Boolean; begin Skip_Line_Terminators (Scan_Ptr, Physical); -- If we are at start of physical line, update scan pointers -- to reflect the start of the new line. if Physical then Current_Line_Start := Scan_Ptr; Start_Column := Set_Start_Column; First_Non_Blank_Location := Scan_Ptr; end if; end; end loop; end Determine_License; ---------------------------- -- Determine_Token_Casing -- ---------------------------- function Determine_Token_Casing return Casing_Type is begin return Determine_Casing (Source (Token_Ptr .. Scan_Ptr - 1)); end Determine_Token_Casing; ----------------------- -- Double_Char_Token -- ----------------------- function Double_Char_Token (C : Character) return Boolean is begin if Source (Scan_Ptr + 1) = C then Accumulate_Checksum (C); Scan_Ptr := Scan_Ptr + 2; return True; elsif Source (Scan_Ptr + 1) = ' ' and then Source (Scan_Ptr + 2) = C then Scan_Ptr := Scan_Ptr + 1; Error_Msg_S ("no space allowed here"); Scan_Ptr := Scan_Ptr + 2; return True; else return False; end if; end Double_Char_Token; ----------------------------- -- Error_Illegal_Character -- ----------------------------- procedure Error_Illegal_Character is begin Error_Msg_S ("illegal character"); Scan_Ptr := Scan_Ptr + 1; end Error_Illegal_Character; ---------------------------------- -- Error_Illegal_Wide_Character -- ---------------------------------- procedure Error_Illegal_Wide_Character is begin if OpenVMS then Error_Msg_S ("illegal wide character, check " & "'/'W'I'D'E'_'C'H'A'R'A'C'T'E'R'_'E'N'C'O'D'I'N'G qualifer"); else Error_Msg_S ("illegal wide character, check -gnatW switch"); end if; Scan_Ptr := Scan_Ptr + 1; end Error_Illegal_Wide_Character; --------------------- -- Error_Long_Line -- --------------------- procedure Error_Long_Line is begin Error_Msg ("this line is too long", Current_Line_Start + Hostparm.Max_Line_Length); end Error_Long_Line; ------------------------------- -- Error_No_Double_Underline -- ------------------------------- procedure Error_No_Double_Underline is begin Error_Msg_S ("two consecutive underlines not permitted"); end Error_No_Double_Underline; ------------------------- -- Initialize_Checksum -- ------------------------- procedure Initialize_Checksum is begin System.CRC32.Initialize (System.CRC32.CRC32 (Checksum)); end Initialize_Checksum; ------------------------ -- Initialize_Scanner -- ------------------------ procedure Initialize_Scanner (Unit : Unit_Number_Type; Index : Source_File_Index) is GNAT_Hedr : constant Text_Buffer (1 .. 78) := (others => '-'); begin -- Set up Token_Type values in Names Table entries for reserved keywords -- We use the Pos value of the Token_Type value. Note we are relying on -- the fact that Token_Type'Val (0) is not a reserved word! Set_Name_Table_Byte (Name_Abort, Token_Type'Pos (Tok_Abort)); Set_Name_Table_Byte (Name_Abs, Token_Type'Pos (Tok_Abs)); Set_Name_Table_Byte (Name_Abstract, Token_Type'Pos (Tok_Abstract)); Set_Name_Table_Byte (Name_Accept, Token_Type'Pos (Tok_Accept)); Set_Name_Table_Byte (Name_Access, Token_Type'Pos (Tok_Access)); Set_Name_Table_Byte (Name_And, Token_Type'Pos (Tok_And)); Set_Name_Table_Byte (Name_Aliased, Token_Type'Pos (Tok_Aliased)); Set_Name_Table_Byte (Name_All, Token_Type'Pos (Tok_All)); Set_Name_Table_Byte (Name_Array, Token_Type'Pos (Tok_Array)); Set_Name_Table_Byte (Name_At, Token_Type'Pos (Tok_At)); Set_Name_Table_Byte (Name_Begin, Token_Type'Pos (Tok_Begin)); Set_Name_Table_Byte (Name_Body, Token_Type'Pos (Tok_Body)); Set_Name_Table_Byte (Name_Case, Token_Type'Pos (Tok_Case)); Set_Name_Table_Byte (Name_Constant, Token_Type'Pos (Tok_Constant)); Set_Name_Table_Byte (Name_Declare, Token_Type'Pos (Tok_Declare)); Set_Name_Table_Byte (Name_Delay, Token_Type'Pos (Tok_Delay)); Set_Name_Table_Byte (Name_Delta, Token_Type'Pos (Tok_Delta)); Set_Name_Table_Byte (Name_Digits, Token_Type'Pos (Tok_Digits)); Set_Name_Table_Byte (Name_Do, Token_Type'Pos (Tok_Do)); Set_Name_Table_Byte (Name_Else, Token_Type'Pos (Tok_Else)); Set_Name_Table_Byte (Name_Elsif, Token_Type'Pos (Tok_Elsif)); Set_Name_Table_Byte (Name_End, Token_Type'Pos (Tok_End)); Set_Name_Table_Byte (Name_Entry, Token_Type'Pos (Tok_Entry)); Set_Name_Table_Byte (Name_Exception, Token_Type'Pos (Tok_Exception)); Set_Name_Table_Byte (Name_Exit, Token_Type'Pos (Tok_Exit)); Set_Name_Table_Byte (Name_For, Token_Type'Pos (Tok_For)); Set_Name_Table_Byte (Name_Function, Token_Type'Pos (Tok_Function)); Set_Name_Table_Byte (Name_Generic, Token_Type'Pos (Tok_Generic)); Set_Name_Table_Byte (Name_Goto, Token_Type'Pos (Tok_Goto)); Set_Name_Table_Byte (Name_If, Token_Type'Pos (Tok_If)); Set_Name_Table_Byte (Name_In, Token_Type'Pos (Tok_In)); Set_Name_Table_Byte (Name_Is, Token_Type'Pos (Tok_Is)); Set_Name_Table_Byte (Name_Limited, Token_Type'Pos (Tok_Limited)); Set_Name_Table_Byte (Name_Loop, Token_Type'Pos (Tok_Loop)); Set_Name_Table_Byte (Name_Mod, Token_Type'Pos (Tok_Mod)); Set_Name_Table_Byte (Name_New, Token_Type'Pos (Tok_New)); Set_Name_Table_Byte (Name_Not, Token_Type'Pos (Tok_Not)); Set_Name_Table_Byte (Name_Null, Token_Type'Pos (Tok_Null)); Set_Name_Table_Byte (Name_Of, Token_Type'Pos (Tok_Of)); Set_Name_Table_Byte (Name_Or, Token_Type'Pos (Tok_Or)); Set_Name_Table_Byte (Name_Others, Token_Type'Pos (Tok_Others)); Set_Name_Table_Byte (Name_Out, Token_Type'Pos (Tok_Out)); Set_Name_Table_Byte (Name_Package, Token_Type'Pos (Tok_Package)); Set_Name_Table_Byte (Name_Pragma, Token_Type'Pos (Tok_Pragma)); Set_Name_Table_Byte (Name_Private, Token_Type'Pos (Tok_Private)); Set_Name_Table_Byte (Name_Procedure, Token_Type'Pos (Tok_Procedure)); Set_Name_Table_Byte (Name_Protected, Token_Type'Pos (Tok_Protected)); Set_Name_Table_Byte (Name_Raise, Token_Type'Pos (Tok_Raise)); Set_Name_Table_Byte (Name_Range, Token_Type'Pos (Tok_Range)); Set_Name_Table_Byte (Name_Record, Token_Type'Pos (Tok_Record)); Set_Name_Table_Byte (Name_Rem, Token_Type'Pos (Tok_Rem)); Set_Name_Table_Byte (Name_Renames, Token_Type'Pos (Tok_Renames)); Set_Name_Table_Byte (Name_Requeue, Token_Type'Pos (Tok_Requeue)); Set_Name_Table_Byte (Name_Return, Token_Type'Pos (Tok_Return)); Set_Name_Table_Byte (Name_Reverse, Token_Type'Pos (Tok_Reverse)); Set_Name_Table_Byte (Name_Select, Token_Type'Pos (Tok_Select)); Set_Name_Table_Byte (Name_Separate, Token_Type'Pos (Tok_Separate)); Set_Name_Table_Byte (Name_Subtype, Token_Type'Pos (Tok_Subtype)); Set_Name_Table_Byte (Name_Tagged, Token_Type'Pos (Tok_Tagged)); Set_Name_Table_Byte (Name_Task, Token_Type'Pos (Tok_Task)); Set_Name_Table_Byte (Name_Terminate, Token_Type'Pos (Tok_Terminate)); Set_Name_Table_Byte (Name_Then, Token_Type'Pos (Tok_Then)); Set_Name_Table_Byte (Name_Type, Token_Type'Pos (Tok_Type)); Set_Name_Table_Byte (Name_Until, Token_Type'Pos (Tok_Until)); Set_Name_Table_Byte (Name_Use, Token_Type'Pos (Tok_Use)); Set_Name_Table_Byte (Name_When, Token_Type'Pos (Tok_When)); Set_Name_Table_Byte (Name_While, Token_Type'Pos (Tok_While)); Set_Name_Table_Byte (Name_With, Token_Type'Pos (Tok_With)); Set_Name_Table_Byte (Name_Xor, Token_Type'Pos (Tok_Xor)); -- Initialize scan control variables Current_Source_File := Index; Source := Source_Text (Current_Source_File); Current_Source_Unit := Unit; Scan_Ptr := Source_First (Current_Source_File); Token := No_Token; Token_Ptr := Scan_Ptr; Current_Line_Start := Scan_Ptr; Token_Node := Empty; Token_Name := No_Name; Start_Column := Set_Start_Column; First_Non_Blank_Location := Scan_Ptr; Initialize_Checksum; -- Set default for Comes_From_Source. All nodes built now until we -- reenter the analyzer will have Comes_From_Source set to True Set_Comes_From_Source_Default (True); -- Check license if GNAT type header possibly present if Source_Last (Index) - Scan_Ptr > 80 and then Source (Scan_Ptr .. Scan_Ptr + 77) = GNAT_Hedr then Set_License (Current_Source_File, Determine_License); end if; -- Scan initial token (note this initializes Prev_Token, Prev_Token_Ptr) Scan; -- Clear flags for reserved words used as identifiers for J in Token_Type loop Used_As_Identifier (J) := False; end loop; end Initialize_Scanner; ---------- -- Nlit -- ---------- procedure Nlit is separate; ---------- -- Scan -- ---------- procedure Scan is begin Prev_Token := Token; Prev_Token_Ptr := Token_Ptr; Token_Name := Error_Name; -- The following loop runs more than once only if a format effector -- (tab, vertical tab, form feed, line feed, carriage return) is -- encountered and skipped, or some error situation, such as an -- illegal character, is encountered. loop -- Skip past blanks, loop is opened up for speed while Source (Scan_Ptr) = ' ' loop if Source (Scan_Ptr + 1) /= ' ' then Scan_Ptr := Scan_Ptr + 1; exit; end if; if Source (Scan_Ptr + 2) /= ' ' then Scan_Ptr := Scan_Ptr + 2; exit; end if; if Source (Scan_Ptr + 3) /= ' ' then Scan_Ptr := Scan_Ptr + 3; exit; end if; if Source (Scan_Ptr + 4) /= ' ' then Scan_Ptr := Scan_Ptr + 4; exit; end if; if Source (Scan_Ptr + 5) /= ' ' then Scan_Ptr := Scan_Ptr + 5; exit; end if; if Source (Scan_Ptr + 6) /= ' ' then Scan_Ptr := Scan_Ptr + 6; exit; end if; if Source (Scan_Ptr + 7) /= ' ' then Scan_Ptr := Scan_Ptr + 7; exit; end if; Scan_Ptr := Scan_Ptr + 8; end loop; -- We are now at a non-blank character, which is the first character -- of the token we will scan, and hence the value of Token_Ptr. Token_Ptr := Scan_Ptr; -- Here begins the main case statement which transfers control on -- the basis of the non-blank character we have encountered. case Source (Scan_Ptr) is -- Line terminator characters when CR | LF | FF | VT => Line_Terminator_Case : begin -- Check line too long Check_End_Of_Line; declare Physical : Boolean; begin Skip_Line_Terminators (Scan_Ptr, Physical); -- If we are at start of physical line, update scan pointers -- to reflect the start of the new line. if Physical then Current_Line_Start := Scan_Ptr; Start_Column := Set_Start_Column; First_Non_Blank_Location := Scan_Ptr; end if; end; end Line_Terminator_Case; -- Horizontal tab, just skip past it when HT => if Style_Check then Style.Check_HT; end if; Scan_Ptr := Scan_Ptr + 1; -- End of file character, treated as an end of file only if it -- is the last character in the buffer, otherwise it is ignored. when EOF => if Scan_Ptr = Source_Last (Current_Source_File) then Check_End_Of_Line; Token := Tok_EOF; return; else Scan_Ptr := Scan_Ptr + 1; end if; -- Ampersand when '&' => Accumulate_Checksum ('&'); if Source (Scan_Ptr + 1) = '&' then Error_Msg_S ("'&'& should be `AND THEN`"); Scan_Ptr := Scan_Ptr + 2; Token := Tok_And; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Ampersand; return; end if; -- Asterisk (can be multiplication operator or double asterisk -- which is the exponentiation compound delimtier). when '*' => Accumulate_Checksum ('*'); if Source (Scan_Ptr + 1) = '*' then Accumulate_Checksum ('*'); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Double_Asterisk; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Asterisk; return; end if; -- Colon, which can either be an isolated colon, or part of an -- assignment compound delimiter. when ':' => Accumulate_Checksum (':'); if Double_Char_Token ('=') then Token := Tok_Colon_Equal; if Style_Check then Style.Check_Colon_Equal; end if; return; elsif Source (Scan_Ptr + 1) = '-' and then Source (Scan_Ptr + 2) /= '-' then Token := Tok_Colon_Equal; Error_Msg (":- should be :=", Scan_Ptr); Scan_Ptr := Scan_Ptr + 2; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Colon; if Style_Check then Style.Check_Colon; end if; return; end if; -- Left parenthesis when '(' => Accumulate_Checksum ('('); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Left_Paren; if Style_Check then Style.Check_Left_Paren; end if; return; -- Left bracket when '[' => if Source (Scan_Ptr + 1) = '"' then Name_Len := 0; goto Scan_Identifier; else Error_Msg_S ("illegal character, replaced by ""("""); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Left_Paren; return; end if; -- Left brace when '{' => Error_Msg_S ("illegal character, replaced by ""("""); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Left_Paren; return; -- Comma when ',' => Accumulate_Checksum (','); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Comma; if Style_Check then Style.Check_Comma; end if; return; -- Dot, which is either an isolated period, or part of a double -- dot compound delimiter sequence. We also check for the case of -- a digit following the period, to give a better error message. when '.' => Accumulate_Checksum ('.'); if Double_Char_Token ('.') then Token := Tok_Dot_Dot; if Style_Check then Style.Check_Dot_Dot; end if; return; elsif Source (Scan_Ptr + 1) in '0' .. '9' then Error_Msg_S ("numeric literal cannot start with point"); Scan_Ptr := Scan_Ptr + 1; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Dot; return; end if; -- Equal, which can either be an equality operator, or part of the -- arrow (=>) compound delimiter. when '=' => Accumulate_Checksum ('='); if Double_Char_Token ('>') then Token := Tok_Arrow; if Style_Check then Style.Check_Arrow; end if; return; elsif Source (Scan_Ptr + 1) = '=' then Error_Msg_S ("== should be ="); Scan_Ptr := Scan_Ptr + 1; end if; Scan_Ptr := Scan_Ptr + 1; Token := Tok_Equal; return; -- Greater than, which can be a greater than operator, greater than -- or equal operator, or first character of a right label bracket. when '>' => Accumulate_Checksum ('>'); if Double_Char_Token ('=') then Token := Tok_Greater_Equal; return; elsif Double_Char_Token ('>') then Token := Tok_Greater_Greater; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Greater; return; end if; -- Less than, which can be a less than operator, less than or equal -- operator, or the first character of a left label bracket, or the -- first character of a box (<>) compound delimiter. when '<' => Accumulate_Checksum ('<'); if Double_Char_Token ('=') then Token := Tok_Less_Equal; return; elsif Double_Char_Token ('>') then Token := Tok_Box; if Style_Check then Style.Check_Box; end if; return; elsif Double_Char_Token ('<') then Token := Tok_Less_Less; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Less; return; end if; -- Minus, which is either a subtraction operator, or the first -- character of double minus starting a comment when '-' => Minus_Case : begin if Source (Scan_Ptr + 1) = '>' then Error_Msg_S ("invalid token"); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Arrow; return; elsif Source (Scan_Ptr + 1) /= '-' then Accumulate_Checksum ('-'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Minus; return; -- Comment else -- Source (Scan_Ptr + 1) = '-' then if Style_Check then Style.Check_Comment; end if; Scan_Ptr := Scan_Ptr + 2; -- Loop to scan comment (this loop runs more than once only if -- a horizontal tab or other non-graphic character is scanned) loop -- Scan to non graphic character (opened up for speed) loop exit when Source (Scan_Ptr) not in Graphic_Character; Scan_Ptr := Scan_Ptr + 1; exit when Source (Scan_Ptr) not in Graphic_Character; Scan_Ptr := Scan_Ptr + 1; exit when Source (Scan_Ptr) not in Graphic_Character; Scan_Ptr := Scan_Ptr + 1; exit when Source (Scan_Ptr) not in Graphic_Character; Scan_Ptr := Scan_Ptr + 1; exit when Source (Scan_Ptr) not in Graphic_Character; Scan_Ptr := Scan_Ptr + 1; end loop; -- Keep going if horizontal tab if Source (Scan_Ptr) = HT then if Style_Check then Style.Check_HT; end if; Scan_Ptr := Scan_Ptr + 1; -- Terminate scan of comment if line terminator elsif Source (Scan_Ptr) in Line_Terminator then exit; -- Terminate scan of comment if end of file encountered -- (embedded EOF character or real last character in file) elsif Source (Scan_Ptr) = EOF then exit; -- Keep going if character in 80-FF range, or is ESC. These -- characters are allowed in comments by RM-2.1(1), 2.7(2). -- They are allowed even in Ada 83 mode according to the -- approved AI. ESC was added to the AI in June 93. elsif Source (Scan_Ptr) in Upper_Half_Character or else Source (Scan_Ptr) = ESC then Scan_Ptr := Scan_Ptr + 1; -- Otherwise we have an illegal comment character else Error_Illegal_Character; end if; end loop; -- Note that we do NOT execute a return here, instead we fall -- through to reexecute the scan loop to look for a token. end if; end Minus_Case; -- Double quote or percent starting a string literal when '"' | '%' => Slit; return; -- Apostrophe. This can either be the start of a character literal, -- or an isolated apostrophe used in a qualified expression or an -- attribute. We treat it as a character literal if it does not -- follow a right parenthesis, identifier, the keyword ALL or -- a literal. This means that we correctly treat constructs like: -- A := CHARACTER'('A'); -- Note that RM-2.2(7) does not require a separator between -- "CHARACTER" and "'" in the above. when ''' => Char_Literal_Case : declare Code : Char_Code; Err : Boolean; begin Accumulate_Checksum ('''); Scan_Ptr := Scan_Ptr + 1; -- Here is where we make the test to distinguish the cases. Treat -- as apostrophe if previous token is an identifier, right paren -- or the reserved word "all" (latter case as in A.all'Address) -- Also treat it as apostrophe after a literal (this catches -- some legitimate cases, like A."abs"'Address, and also gives -- better error behavior for impossible cases like 123'xxx). if Prev_Token = Tok_Identifier or else Prev_Token = Tok_Right_Paren or else Prev_Token = Tok_All or else Prev_Token in Token_Class_Literal then Token := Tok_Apostrophe; return; -- Otherwise the apostrophe starts a character literal else -- Case of wide character literal with ESC or [ encoding if (Source (Scan_Ptr) = ESC and then Wide_Character_Encoding_Method in WC_ESC_Encoding_Method) or else (Source (Scan_Ptr) in Upper_Half_Character and then Upper_Half_Encoding) or else (Source (Scan_Ptr) = '[' and then Source (Scan_Ptr + 1) = '"') then Scan_Wide (Source, Scan_Ptr, Code, Err); Accumulate_Checksum (Code); if Err then Error_Illegal_Wide_Character; end if; if Source (Scan_Ptr) /= ''' then Error_Msg_S ("missing apostrophe"); else Scan_Ptr := Scan_Ptr + 1; end if; -- If we do not find a closing quote in the expected place then -- assume that we have a misguided attempt at a string literal. -- However, if previous token is RANGE, then we return an -- apostrophe instead since this gives better error recovery elsif Source (Scan_Ptr + 1) /= ''' then if Prev_Token = Tok_Range then Token := Tok_Apostrophe; return; else Scan_Ptr := Scan_Ptr - 1; Error_Msg_S ("strings are delimited by double quote character"); Scn.Slit; return; end if; -- Otherwise we have a (non-wide) character literal else Accumulate_Checksum (Source (Scan_Ptr)); if Source (Scan_Ptr) not in Graphic_Character then if Source (Scan_Ptr) in Upper_Half_Character then if Ada_83 then Error_Illegal_Character; end if; else Error_Illegal_Character; end if; end if; Code := Get_Char_Code (Source (Scan_Ptr)); Scan_Ptr := Scan_Ptr + 2; end if; -- Fall through here with Scan_Ptr updated past the closing -- quote, and Code set to the Char_Code value for the literal Accumulate_Checksum ('''); Token := Tok_Char_Literal; Token_Node := New_Node (N_Character_Literal, Token_Ptr); Set_Char_Literal_Value (Token_Node, Code); Set_Character_Literal_Name (Code); Token_Name := Name_Find; Set_Chars (Token_Node, Token_Name); return; end if; end Char_Literal_Case; -- Right parenthesis when ')' => Accumulate_Checksum (')'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Right_Paren; if Style_Check then Style.Check_Right_Paren; end if; return; -- Right bracket or right brace, treated as right paren when ']' | '}' => Error_Msg_S ("illegal character, replaced by "")"""); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Right_Paren; return; -- Slash (can be division operator or first character of not equal) when '/' => Accumulate_Checksum ('/'); if Double_Char_Token ('=') then Token := Tok_Not_Equal; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Slash; return; end if; -- Semicolon when ';' => Accumulate_Checksum (';'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Semicolon; if Style_Check then Style.Check_Semicolon; end if; return; -- Vertical bar when '|' => Vertical_Bar_Case : begin Accumulate_Checksum ('|'); -- Special check for || to give nice message if Source (Scan_Ptr + 1) = '|' then Error_Msg_S ("""||"" should be `OR ELSE`"); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Or; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Vertical_Bar; if Style_Check then Style.Check_Vertical_Bar; end if; return; end if; end Vertical_Bar_Case; -- Exclamation, replacement character for vertical bar when '!' => Exclamation_Case : begin Accumulate_Checksum ('!'); if Source (Scan_Ptr + 1) = '=' then Error_Msg_S ("'!= should be /="); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Not_Equal; return; else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Vertical_Bar; return; end if; end Exclamation_Case; -- Plus when '+' => Plus_Case : begin Accumulate_Checksum ('+'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Plus; return; end Plus_Case; -- Digits starting a numeric literal when '0' .. '9' => Nlit; if Identifier_Char (Source (Scan_Ptr)) then Error_Msg_S ("delimiter required between literal and identifier"); end if; return; -- Lower case letters when 'a' .. 'z' => Name_Len := 1; Name_Buffer (1) := Source (Scan_Ptr); Accumulate_Checksum (Name_Buffer (1)); Scan_Ptr := Scan_Ptr + 1; goto Scan_Identifier; -- Upper case letters when 'A' .. 'Z' => Name_Len := 1; Name_Buffer (1) := Character'Val (Character'Pos (Source (Scan_Ptr)) + 32); Accumulate_Checksum (Name_Buffer (1)); Scan_Ptr := Scan_Ptr + 1; goto Scan_Identifier; -- Underline character when '_' => Error_Msg_S ("identifier cannot start with underline"); Name_Len := 1; Name_Buffer (1) := '_'; Scan_Ptr := Scan_Ptr + 1; goto Scan_Identifier; -- Space (not possible, because we scanned past blanks) when ' ' => raise Program_Error; -- Characters in top half of ASCII 8-bit chart when Upper_Half_Character => -- Wide character case. Note that Scan_Identifier will issue -- an appropriate message if wide characters are not allowed -- in identifiers. if Upper_Half_Encoding then Name_Len := 0; goto Scan_Identifier; -- Otherwise we have OK Latin-1 character else -- Upper half characters may possibly be identifier letters -- but can never be digits, so Identifier_Character can be -- used to test for a valid start of identifier character. if Identifier_Char (Source (Scan_Ptr)) then Name_Len := 0; goto Scan_Identifier; else Error_Illegal_Character; end if; end if; when ESC => -- ESC character, possible start of identifier if wide characters -- using ESC encoding are allowed in identifiers, which we can -- tell by looking at the Identifier_Char flag for ESC, which is -- only true if these conditions are met. if Identifier_Char (ESC) then Name_Len := 0; goto Scan_Identifier; else Error_Illegal_Wide_Character; end if; -- Invalid control characters when NUL | SOH | STX | ETX | EOT | ENQ | ACK | BEL | BS | SO | SI | DLE | DC1 | DC2 | DC3 | DC4 | NAK | SYN | ETB | CAN | EM | FS | GS | RS | US | DEL => Error_Illegal_Character; -- Invalid graphic characters when '#' | '$' | '?' | '@' | '`' | '\' | '^' | '~' => Error_Illegal_Character; -- End switch on non-blank character end case; -- End loop past format effectors. The exit from this loop is by -- executing a return statement following completion of token scan -- (control never falls out of this loop to the code which follows) end loop; -- Identifier scanning routine. On entry, some initial characters -- of the identifier may have already been stored in Name_Buffer. -- If so, Name_Len has the number of characters stored. otherwise -- Name_Len is set to zero on entry. <<Scan_Identifier>> -- This loop scans as fast as possible past lower half letters -- and digits, which we expect to be the most common characters. loop if Source (Scan_Ptr) in 'a' .. 'z' or else Source (Scan_Ptr) in '0' .. '9' then Name_Buffer (Name_Len + 1) := Source (Scan_Ptr); Accumulate_Checksum (Source (Scan_Ptr)); elsif Source (Scan_Ptr) in 'A' .. 'Z' then Name_Buffer (Name_Len + 1) := Character'Val (Character'Pos (Source (Scan_Ptr)) + 32); Accumulate_Checksum (Name_Buffer (Name_Len + 1)); else exit; end if; -- Open out the loop a couple of times for speed if Source (Scan_Ptr + 1) in 'a' .. 'z' or else Source (Scan_Ptr + 1) in '0' .. '9' then Name_Buffer (Name_Len + 2) := Source (Scan_Ptr + 1); Accumulate_Checksum (Source (Scan_Ptr + 1)); elsif Source (Scan_Ptr + 1) in 'A' .. 'Z' then Name_Buffer (Name_Len + 2) := Character'Val (Character'Pos (Source (Scan_Ptr + 1)) + 32); Accumulate_Checksum (Name_Buffer (Name_Len + 2)); else Scan_Ptr := Scan_Ptr + 1; Name_Len := Name_Len + 1; exit; end if; if Source (Scan_Ptr + 2) in 'a' .. 'z' or else Source (Scan_Ptr + 2) in '0' .. '9' then Name_Buffer (Name_Len + 3) := Source (Scan_Ptr + 2); Accumulate_Checksum (Source (Scan_Ptr + 2)); elsif Source (Scan_Ptr + 2) in 'A' .. 'Z' then Name_Buffer (Name_Len + 3) := Character'Val (Character'Pos (Source (Scan_Ptr + 2)) + 32); Accumulate_Checksum (Name_Buffer (Name_Len + 3)); else Scan_Ptr := Scan_Ptr + 2; Name_Len := Name_Len + 2; exit; end if; if Source (Scan_Ptr + 3) in 'a' .. 'z' or else Source (Scan_Ptr + 3) in '0' .. '9' then Name_Buffer (Name_Len + 4) := Source (Scan_Ptr + 3); Accumulate_Checksum (Source (Scan_Ptr + 3)); elsif Source (Scan_Ptr + 3) in 'A' .. 'Z' then Name_Buffer (Name_Len + 4) := Character'Val (Character'Pos (Source (Scan_Ptr + 3)) + 32); Accumulate_Checksum (Name_Buffer (Name_Len + 4)); else Scan_Ptr := Scan_Ptr + 3; Name_Len := Name_Len + 3; exit; end if; Scan_Ptr := Scan_Ptr + 4; Name_Len := Name_Len + 4; end loop; -- If we fall through, then we have encountered either an underline -- character, or an extended identifier character (i.e. one from the -- upper half), or a wide character, or an identifier terminator. -- The initial test speeds us up in the most common case where we -- have an identifier terminator. Note that ESC is an identifier -- character only if a wide character encoding method that uses -- ESC encoding is active, so if we find an ESC character we know -- that we have a wide character. if Identifier_Char (Source (Scan_Ptr)) then -- Case of underline, check for error cases of double underline, -- and for a trailing underline character if Source (Scan_Ptr) = '_' then Accumulate_Checksum ('_'); Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := '_'; if Identifier_Char (Source (Scan_Ptr + 1)) then Scan_Ptr := Scan_Ptr + 1; if Source (Scan_Ptr) = '_' then Error_No_Double_Underline; end if; else Error_Msg_S ("identifier cannot end with underline"); Scan_Ptr := Scan_Ptr + 1; end if; goto Scan_Identifier; -- Upper half character elsif Source (Scan_Ptr) in Upper_Half_Character and then not Upper_Half_Encoding then Accumulate_Checksum (Source (Scan_Ptr)); Store_Encoded_Character (Get_Char_Code (Fold_Lower (Source (Scan_Ptr)))); Scan_Ptr := Scan_Ptr + 1; goto Scan_Identifier; -- Left bracket not followed by a quote terminates an identifier. -- This is an error, but we don't want to give a junk error msg -- about wide characters in this case! elsif Source (Scan_Ptr) = '[' and then Source (Scan_Ptr + 1) /= '"' then null; -- We know we have a wide character encoding here (the current -- character is either ESC, left bracket, or an upper half -- character depending on the encoding method). else -- Scan out the wide character and insert the appropriate -- encoding into the name table entry for the identifier. declare Sptr : constant Source_Ptr := Scan_Ptr; Code : Char_Code; Err : Boolean; begin Scan_Wide (Source, Scan_Ptr, Code, Err); Accumulate_Checksum (Code); if Err then Error_Illegal_Wide_Character; else Store_Encoded_Character (Code); end if; -- Make sure we are allowing wide characters in identifiers. -- Note that we allow wide character notation for an OK -- identifier character. This in particular allows bracket -- or other notation to be used for upper half letters. if Identifier_Character_Set /= 'w' and then (not In_Character_Range (Code) or else not Identifier_Char (Get_Character (Code))) then Error_Msg ("wide character not allowed in identifier", Sptr); end if; end; goto Scan_Identifier; end if; end if; -- Scan of identifier is complete. The identifier is stored in -- Name_Buffer, and Scan_Ptr points past the last character. Token_Name := Name_Find; -- Here is where we check if it was a keyword if Get_Name_Table_Byte (Token_Name) /= 0 and then (Ada_95 or else Token_Name not in Ada_95_Reserved_Words) then Token := Token_Type'Val (Get_Name_Table_Byte (Token_Name)); -- Deal with possible style check for non-lower case keyword, -- but we don't treat ACCESS, DELTA, DIGITS, RANGE as keywords -- for this purpose if they appear as attribute designators. -- Actually we only check the first character for speed. if Style_Check and then Source (Token_Ptr) <= 'Z' and then (Prev_Token /= Tok_Apostrophe or else (Token /= Tok_Access and then Token /= Tok_Delta and then Token /= Tok_Digits and then Token /= Tok_Range)) then Style.Non_Lower_Case_Keyword; end if; -- We must reset Token_Name since this is not an identifier -- and if we leave Token_Name set, the parser gets confused -- because it thinks it is dealing with an identifier instead -- of the corresponding keyword. Token_Name := No_Name; return; -- It is an identifier after all else Token_Node := New_Node (N_Identifier, Token_Ptr); Set_Chars (Token_Node, Token_Name); Token := Tok_Identifier; return; end if; end Scan; --------------------- -- Scan_First_Char -- --------------------- function Scan_First_Char return Source_Ptr is Ptr : Source_Ptr := Current_Line_Start; begin loop if Source (Ptr) = ' ' then Ptr := Ptr + 1; elsif Source (Ptr) = HT then if Style_Check then Style.Check_HT; end if; Ptr := Ptr + 1; else return Ptr; end if; end loop; end Scan_First_Char; ------------------------------ -- Scan_Reserved_Identifier -- ------------------------------ procedure Scan_Reserved_Identifier (Force_Msg : Boolean) is Token_Chars : constant String := Token_Type'Image (Token); begin -- We have in Token_Chars the image of the Token name, i.e. Tok_xxx. -- This code extracts the xxx and makes an identifier out of it. Name_Len := 0; for J in 5 .. Token_Chars'Length loop Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Fold_Lower (Token_Chars (J)); end loop; Token_Name := Name_Find; if not Used_As_Identifier (Token) or else Force_Msg then Error_Msg_Name_1 := Token_Name; Error_Msg_SC ("reserved word* cannot be used as identifier!"); Used_As_Identifier (Token) := True; end if; Token := Tok_Identifier; Token_Node := New_Node (N_Identifier, Token_Ptr); Set_Chars (Token_Node, Token_Name); end Scan_Reserved_Identifier; ---------------------- -- Set_Start_Column -- ---------------------- -- Note: it seems at first glance a little expensive to compute this value -- for every source line (since it is certainly not used for all source -- lines). On the other hand, it doesn't take much more work to skip past -- the initial white space on the line counting the columns than it would -- to scan past the white space using the standard scanning circuits. function Set_Start_Column return Column_Number is Start_Column : Column_Number := 0; begin -- Outer loop scans past horizontal tab characters Tabs_Loop : loop -- Inner loop scans past blanks as fast as possible, bumping Scan_Ptr -- past the blanks and adjusting Start_Column to account for them. Blanks_Loop : loop if Source (Scan_Ptr) = ' ' then if Source (Scan_Ptr + 1) = ' ' then if Source (Scan_Ptr + 2) = ' ' then if Source (Scan_Ptr + 3) = ' ' then if Source (Scan_Ptr + 4) = ' ' then if Source (Scan_Ptr + 5) = ' ' then if Source (Scan_Ptr + 6) = ' ' then Scan_Ptr := Scan_Ptr + 7; Start_Column := Start_Column + 7; else Scan_Ptr := Scan_Ptr + 6; Start_Column := Start_Column + 6; exit Blanks_Loop; end if; else Scan_Ptr := Scan_Ptr + 5; Start_Column := Start_Column + 5; exit Blanks_Loop; end if; else Scan_Ptr := Scan_Ptr + 4; Start_Column := Start_Column + 4; exit Blanks_Loop; end if; else Scan_Ptr := Scan_Ptr + 3; Start_Column := Start_Column + 3; exit Blanks_Loop; end if; else Scan_Ptr := Scan_Ptr + 2; Start_Column := Start_Column + 2; exit Blanks_Loop; end if; else Scan_Ptr := Scan_Ptr + 1; Start_Column := Start_Column + 1; exit Blanks_Loop; end if; else exit Blanks_Loop; end if; end loop Blanks_Loop; -- Outer loop keeps going only if a horizontal tab follows if Source (Scan_Ptr) = HT then if Style_Check then Style.Check_HT; end if; Scan_Ptr := Scan_Ptr + 1; Start_Column := (Start_Column / 8) * 8 + 8; else exit Tabs_Loop; end if; end loop Tabs_Loop; return Start_Column; end Set_Start_Column; ---------- -- Slit -- ---------- procedure Slit is separate; end Scn;
-- Copyright 2016-2021 Bartek thindil Jasicki -- -- This file is part of Steam Sky. -- -- Steam Sky 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. -- -- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Vectors; use Ada.Containers; with Game; use Game; -- ****h* Messages/Messages -- FUNCTION -- Provides code for manipulate in game messages -- SOURCE package Messages is -- **** -- ****t* Messages/Messages.Message_Type -- FUNCTION -- Types of messages -- SOURCE type Message_Type is (Default, CombatMessage, TradeMessage, OrderMessage, CraftMessage, OtherMessage, MissionMessage) with Default_Value => Default; -- **** -- ****t* Messages/Messages.Message_Color -- FUNCTION -- Colors of messages -- SOURCE type Message_Color is (WHITE, YELLOW, GREEN, RED, BLUE, CYAN) with Default_Value => WHITE; -- **** -- ****s* Messages/Messages.Message_Data -- FUNCTION -- Data structure for messages -- PARAMETERS -- Message - Text of message -- MType - Type of message -- Color - Color used for show message -- SOURCE type Message_Data is record Message: Unbounded_String; MType: Message_Type; Color: Message_Color; end record; -- **** -- ****t* Messages/Messages.Messages_Container -- FUNCTION -- Used to store messages data -- SOURCE package Messages_Container is new Vectors(Positive, Message_Data); -- **** -- ****v* Messages/Messages.Messages_List -- FUNCTION -- List of all messages -- SOURCE Messages_List: Messages_Container.Vector; -- **** -- ****v* Messages/Messages.LastMessageIndex -- FUNCTION -- Index of last message to show -- SOURCE LastMessageIndex: Natural := 0; -- **** -- ****f* Messages/Messages.FormatedTime -- FUNCTION -- Format game time -- PARAMETERS -- Time - Game time to format. Default is current game time -- RESULT -- Formatted in YYYY-MM-DD HH:MM style in game time -- SOURCE function FormatedTime(Time: Date_Record := Game_Date) return String with Post => FormatedTime'Result'Length > 0, Test_Case => (Name => "Test_FormattedTime", Mode => Nominal); -- **** -- ****f* Messages/Messages.AddMessage -- FUNCTION -- Add new message to list -- PARAMETERS -- Message - Text of message to add -- MType - Type of message to add -- Color - Color of message to add -- SOURCE procedure AddMessage (Message: String; MType: Message_Type; Color: Message_Color := WHITE) with Pre => Message'Length > 0, Test_Case => (Name => "Test_AddMessage", Mode => Nominal); -- **** -- ****f* Messages/Messages.GetMessage -- FUNCTION -- Get Nth message of selected type -- PARAMETERS -- MessageIndex - If positive, get Nth message from start of list if -- negative, get Nth message from the end of the messages -- list -- MType - Type of messages to check. Default all messages -- RESULT -- Selected message or empty message if nothing found -- SOURCE function GetMessage (MessageIndex: Integer; MType: Message_Type := Default) return Message_Data with Test_Case => (Name => "Test_GetMessage", Mode => Robustness); -- **** -- ****f* Messages/Messages.ClearMessages -- FUNCTION -- Remove all messages -- SOURCE procedure ClearMessages with Test_Case => (Name => "Test_ClearMessages", Mode => Robustness); -- **** -- ****f* Messages/Messages.MessagesAmount -- FUNCTION -- Get amount of selected type messages -- PARAMETERS -- MType - Type of messages to search. Default is all messages -- RESULT -- Amount of messages of selected type -- SOURCE function MessagesAmount(MType: Message_Type := Default) return Natural with Test_Case => (Name => "Test_MessagesAmount", Mode => Robustness); -- **** -- ****f* Messages/Messages.RestoreMessage -- FUNCTION -- Restore message from save file -- PARAMETERS -- Message - Text of message to restore -- MType - Type of message to restore. Default is no type -- Color - Color of message to restore. Default is white. -- SOURCE procedure RestoreMessage (Message: Unbounded_String; MType: Message_Type := Default; Color: Message_Color := WHITE) with Pre => Message /= Null_Unbounded_String, Test_Case => (Name => "Test_RestoreMessage", Mode => Nominal); -- **** -- ****f* Messages/Messages.GetLastMessageIndex -- FUNCTION -- Get last message index -- RESULT -- List index of the last message -- SOURCE function GetLastMessageIndex return Natural with Test_Case => (Name => "Test_GetLastMessageIndex", Mode => Robustness); -- **** end Messages;
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.S_Expressions.Templates.Dates provides a template interpreter -- -- for dates and times. -- ------------------------------------------------------------------------------ with Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; with Ada.Streams; with Natools.S_Expressions.Lockable; package Natools.S_Expressions.Templates.Dates is type Split_Time is record Source : Ada.Calendar.Time; Time_Zone : Ada.Calendar.Time_Zones.Time_Offset; Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Day_Of_Week : Ada.Calendar.Formatting.Day_Name; Hour : Ada.Calendar.Formatting.Hour_Number; Minute : Ada.Calendar.Formatting.Minute_Number; Second : Ada.Calendar.Formatting.Second_Number; Sub_Second : Ada.Calendar.Formatting.Second_Duration; end record; function Split (Value : Ada.Calendar.Time; Time_Zone : Ada.Calendar.Time_Zones.Time_Offset) return Split_Time; -- Pre process split time component from Value in Time_Zone procedure Render (Output : in out Ada.Streams.Root_Stream_Type'Class; Template : in out Lockable.Descriptor'Class; Value : in Split_Time); -- Render the given time procedure Render (Output : in out Ada.Streams.Root_Stream_Type'Class; Template : in out Lockable.Descriptor'Class; Value : in Ada.Calendar.Time); -- Render the given time considered in local time zone procedure Render (Output : in out Ada.Streams.Root_Stream_Type'Class; Template : in out Lockable.Descriptor'Class; Value : in Ada.Calendar.Time; Time_Zone : Ada.Calendar.Time_Zones.Time_Offset); -- Render the given time end Natools.S_Expressions.Templates.Dates;
-- POK header -- -- The following file is a part of the POK project. Any modification should -- be made according to the POK licence. You CANNOT use this file or a part -- of a file for your own project. -- -- For more information on the POK licence, please see our LICENCE FILE -- -- Please follow the coding guidelines described in doc/CODING_GUIDELINES -- -- Copyright (c) 2007-2020 POK team -- --------------------------------------------------------------------------- -- -- -- PARTITION constant and type definitions and management services -- -- -- -- --------------------------------------------------------------------------- with APEX.Processes; package APEX.Partitions is Max_Number_Of_Partitions : constant := System_Limit_Number_Of_Partitions; type Operating_Mode_Type is (Idle, Cold_Start, Warm_Start, Normal); type Partition_Id_Type is private; Null_Partition_Id : constant Partition_Id_Type; type Start_Condition_Type is (Normal_Start, Partition_Restart, Hm_Module_Restart, Hm_Partition_Restart); type Partition_Status_Type is record Period : System_Time_Type; Duration : System_Time_Type; Identifier : Partition_Id_Type; Lock_Level : APEX.Processes.Lock_Level_Type; Operating_Mode : Operating_Mode_Type; Start_Condition : Start_Condition_Type; end record; procedure Get_Partition_Status (Partition_Status : out Partition_Status_Type; Return_Code : out Return_Code_Type); procedure Set_Partition_Mode (Operating_Mode : in Operating_Mode_Type; Return_Code : out Return_Code_Type); private type Partition_ID_Type is new APEX_Integer; Null_Partition_Id : constant Partition_Id_Type := 0; pragma Convention (C, Operating_Mode_Type); pragma Convention (C, Start_Condition_Type); pragma Convention (C, Partition_Status_Type); -- POK BINDINGS pragma Import (C, Get_Partition_Status, "GET_PARTITION_STATUS"); pragma Import (C, Set_Partition_Mode, "SET_PARTITION_MODE"); -- END OF POK BINDINGS end APEX.Partitions;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . M E M O R Y _ D U M P -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-2020, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- A routine for dumping memory to either standard output or standard error. -- Uses GNAT.IO for actual output (use the controls in GNAT.IO to specify -- the destination of the output, which by default is Standard_Output). with System; package GNAT.Memory_Dump is pragma Preelaborate; type Prefix_Type is (Absolute_Address, Offset, None); procedure Dump (Addr : System.Address; Count : Natural); -- Dumps indicated number (Count) of bytes, starting at the address given -- by Addr. The coding of this routine in its current form assumes the case -- of a byte addressable machine (and is therefore inapplicable to machines -- like the AAMP, where the storage unit is not 8 bits). The output is one -- or more lines in the following format, which is for the case of 32-bit -- addresses (64-bit addresses are handled appropriately): -- -- 0234_3368: 66 67 68 . . . 73 74 75 "fghijklmnopqstuv" -- -- All but the last line have 16 bytes. A question mark is used in the -- string data to indicate a non-printable character. procedure Dump (Addr : System.Address; Count : Natural; Prefix : Prefix_Type); -- Same as above, but allows the selection of different line formats. -- If Prefix is set to Absolute_Address, the output is identical to the -- above version, each line starting with the absolute address of the -- first dumped storage element. -- -- If Prefix is set to Offset, then instead each line starts with the -- indication of the offset relative to Addr: -- -- 00: 66 67 68 . . . 73 74 75 "fghijklmnopqstuv" -- -- Finally if Prefix is set to None, the prefix is suppressed altogether, -- and only the memory contents are displayed: -- -- 66 67 68 . . . 73 74 75 "fghijklmnopqstuv" end GNAT.Memory_Dump;
with BDD.Asserts; use BDD.Asserts; -- with BDD.Tables; use BDD.Tables; with RTCH.Maths.Vectors; use RTCH.Maths.Vectors; with RTCH.Maths.Points; use RTCH.Maths.Points; package body RTCH.Maths.Tuples.Steps is procedure Given_Tuple_A (X, Y, Z, W : Float) is begin A := Tuple'(X, Y, Z, W); end Given_Tuple_A; procedure Then_A_X_Is (Expected : Float) is begin Assert_Equal (A.X, Expected); end Then_A_X_Is; procedure And_A_Y_Is (Expected : Float) is begin Assert_Equal (A.Y, Expected); end And_A_Y_Is; procedure And_A_Z_Is (Expected : Float) is begin Assert_Equal (A.Z, Expected); end And_A_Z_Is; procedure And_A_W_Is (Expected : Float) is begin Assert_Equal (A.W, Expected); end And_A_W_Is; procedure And_A_Is_A_Point is begin Assert (Is_Point (A)); end And_A_Is_A_Point; procedure And_A_Is_Not_A_Vector is begin Assert (not Is_Vector (A)); end And_A_Is_Not_A_Vector; procedure And_A_Is_Not_A_Point is begin Assert (not Is_Point (A)); end And_A_Is_Not_A_Point; procedure And_A_Is_A_Vector is begin Assert (Is_Vector (A)); end And_A_Is_A_Vector; procedure Given_Point_P (X, Y, Z : Float) is begin P := Make_Point (X, Y, Z); end Given_Point_P; procedure Then_P_Is_A_Tuple (X, Y, Z, W : Float) is begin Assert (P = Tuple'(X, Y, Z, W)); end Then_P_Is_A_Tuple; procedure Given_Vector_V (X, Y, Z : Float) is begin V := Make_Vector (X, Y, Z); end Given_Vector_V; procedure Then_V_Is_A_Tuple (X, Y, Z, W : Float) is begin Assert (V = Tuple'(X, Y, Z, W)); end Then_V_Is_A_Tuple; procedure Given_Tuple_A1 (X, Y, Z, W : Float) is begin A1 := Tuple'(X, Y, Z, W); end Given_Tuple_A1; procedure Given_Tuple_A2 (X, Y, Z, W : Float) is begin A2 := Tuple'(X, Y, Z, W); end Given_Tuple_A2; procedure Then_A1_Plus_A2_Is (X, Y, Z, W : Float) is begin Assert (A1 + A2 = Tuple'(X, Y, Z, W)); end Then_A1_Plus_A2_Is; procedure Given_Point_P1 (X, Y, Z : Float) is begin P1 := Make_Point (X, Y, Z); end Given_Point_P1; procedure And_Given_Point_P2 (X, Y, Z : Float) is begin P2 := Make_Point (X, Y, Z); end And_Given_Point_P2; procedure Then_P1_Minus_P2_Is_Vector (X, Y, Z : Float) is begin Assert (P1 - P2 = Make_Vector (X, Y, Z)); end Then_P1_Minus_P2_Is_Vector; procedure Then_P_Minus_V_Is_Point (X, Y, Z : Float) is begin Assert (P - V = Make_Point (X, Y, Z)); end Then_P_Minus_V_Is_Point; procedure Given_Vector_V1 (X, Y, Z : Float) is begin V1 := Make_Vector (X, Y, Z); end Given_Vector_V1; procedure And_Given_Vector_V2 (X, Y, Z : Float) is begin V2 := Make_Vector (X, Y, Z); end And_Given_Vector_V2; procedure Then_V1_Minus_V2_Is_Vector (X, Y, Z : Float) is begin Assert (V1 - V2 = Make_Vector (X, Y, Z)); end Then_V1_Minus_V2_Is_Vector; procedure Given_Zero_Vector (X, Y, Z : Float) is begin Assert (X = Y and Y = Z and Z = 0.0); Assert (Zero = Make_Vector (X, Y, Z)); end Given_Zero_Vector; procedure Then_Zero_Minus_V_Is_Vector (X, Y, Z : Float) is begin Assert (Zero - V = Make_Vector (X, Y, Z)); end Then_Zero_Minus_V_Is_Vector; procedure Then_Tuple_Is_Negative_A (X, Y, Z, W : Float) is begin Assert (-A = Tuple'(X, Y, Z, W)); end Then_Tuple_Is_Negative_A; procedure Then_A_Times_Scalar_Is_Tuple (Scalar, X, Y, Z, W : Float) is begin Assert (A * Scalar = Tuple'(X, Y, Z, W)); end Then_A_Times_Scalar_Is_Tuple; procedure Then_A_Divide_By_Scalar_Is_Tuple (Scalar, X, Y, Z, W : Float) is begin Assert (A / Scalar = Tuple'(X, Y, Z, W)); end Then_A_Divide_By_Scalar_Is_Tuple; procedure Then_Magnitude_Of_V_Is (Result : Float) is begin Assert (Magnitude (V) = Result); end Then_Magnitude_Of_V_Is; procedure Then_Magnitude_Of_V_Is_Sqrt_Of (Result : Float) is begin Assert (Magnitude (V) = Sqrt (Result)); end Then_Magnitude_Of_V_Is_Sqrt_Of; procedure Then_Normalise_V_Is_Vector (X, Y, Z : Float) is begin Assert (Normalise (V) = Make_Vector (X, Y, Z)); end Then_Normalise_V_Is_Vector; procedure Then_Normalise_V_Is_Approximately_Vector (X, Y, Z : Float) is Normalised_V : constant Vector := Normalise (V); begin Assert (Equals (Normalised_V.X, X)); Assert (Equals (Normalised_V.Y, Y)); Assert (Equals (Normalised_V.Z, Z)); end Then_Normalise_V_Is_Approximately_Vector; procedure When_Normalise_V_As_Norm is begin Norm := Normalise (V); end When_Normalise_V_As_Norm; procedure Then_Magnitude_Norm_Is_One is begin -- Have to use Equals here. Assert (Equals (Magnitude (Norm), 1.0)); end Then_Magnitude_Norm_Is_One; procedure Then_Dot_Of_V1_And_V2_Is (Scalar : Float) is begin Assert (Dot (V1, V2) = Scalar); end Then_Dot_Of_V1_And_V2_Is; procedure Then_Cross_Of_V1_And_V2_Is (X, Y, Z : Float) is begin Assert (Cross (V1, V2) = Make_Vector (X, Y, Z)); end Then_Cross_Of_V1_And_V2_Is; procedure And_Cross_Of_V2_And_V1_Is (X, Y, Z : Float) is begin Assert (Cross (V2, V1) = Make_Vector (X, Y, Z)); end And_Cross_Of_V2_And_V1_Is; end RTCH.Maths.Tuples.Steps;
with NPC_PC; use NPC_PC; with ada.text_io; use ada.text_io; with ada.integer_text_io; use ada.integer_text_io; with ada.integer_text_io;use ada.integer_text_io; with w_gen; use w_gen; with Ada.Numerics.Discrete_Random; with enemy_bst; use enemy_bst; package body combat_package is ------------------------------- -- Name: Jon Spohn -- David Rogina -- Combat Package ------------------------------- Procedure Combat(Hero : in out HeroClass; Enemy : in out EnemyClass; ET : in out EnemyTree; Run : in out integer) is answer : character:='a'; --character input to attack difference : integer; --Random roll subtype roll is integer range 0..10; package random_roll is new ada.numerics.discrete_random(roll); use random_roll; your_roll:integer:=0; --Hero roll enemy_roll:roll:=0; --Enemy roll run_roll:roll:=0; --Roll to determine if you can run or not g:generator; --Random number generator file:file_type; --File variable variable begin SetEnemyArmor(GetHeroH(Hero) / 3, Enemy); SetEnemyStrength(getheroS(hero) / 2, Enemy); --Display Monster Screen w_gen.clr_scr; open(file,in_file,"Monster.txt"); draw_enemy(file); close(file); --Display starting health put("HERO HEALTH: "); put(GetHeroH(hero),0); put(" "); put("ENEMY HEALTH: "); put(GetEnemyH(enemy),0); new_line; --Loop while neither character is dead while (GetHeroH(hero) > 0 and GetEnemyH(enemy) > 0) loop put_line("Would you like to:"); put_line("(a)ttack"); put_line("(r)un"); put(": "); get(answer); new_line; if (answer = 'a') then reset(g); your_roll:=random(g)+1; enemy_roll:=random(g); --Enemy won roll if (enemy_roll>your_roll) then setherohealth(enemy_roll,hero); --Hero won roll elsif(enemy_roll<your_roll) then setenemyhealth(your_roll,enemy); end if; --Display combat menu put_line("------------------------------------------"); put_line("---------------!!!COMBAT!!!---------------"); put_line("------------------------------------------"); put_line("-----HEALTH---------------------ROLLS-----"); put_line("-- --------------- --"); put("-- HERO: "); put(GetHeroH(hero),0); if((getheroh(hero)<100)and(getheroh(hero)>=10)) then put(" --------------- HERO: "); elsif((getheroh(hero)>=100)) then put(" --------------- HERO: "); else put(" -------------- HERO: "); end if; put(your_roll,0); if(your_roll<10) then put_line(" --"); else put_line(" --"); end if; put_line("-- --------------- --"); put_line("-- --------------- --"); put("-- ENEMY: "); put(getenemyh(enemy),0); if((getenemyh(enemy)<100)and(getenemyh(enemy)>=10) )then put(" --------------- ENEMY: "); elsif((getenemyh(enemy)>=100)) then put(" --------------- ENEMY: "); else put(" --------------- ENEMY: "); end if; put(enemy_roll,0); if(enemy_roll<10) then put_line(" --"); else put_line(" --"); end if; put_line("-- --------------- --"); put_line("------------------------------------------"); if (enemy_roll>your_roll) then put_line("------------ ENEMY WON ROLL ------------"); put_line("------------------------------------------"); elsif(enemy_roll<your_roll) then put_line("------------ HERO WON ROLL ------------"); put_line("------------------------------------------"); else put_line("------- ROLLS TIED: NO-ONE DAMAGED -------"); put_line("------------------------------------------"); end if; --Run if hero can roll an even number elsif(answer = 'r') then reset(g); run_roll:=random(g); if run_roll rem 2 >0 then put("You could not run!!"); new_line; else put_line("You ran away successfully!!!"); put("Enter any key to continue... "); run := 1; get(answer); exit; end if; end if; end loop; --Hero wins combat if(GetEnemyH(Enemy) <= 0) then Delete(ET,Enemy); put_line("You win! You feel a bit stronger!"); difference := (100 - GetHeroH(hero)) * (-1); SetHeroHealth(difference,hero); SetHeroArmor(3,hero); SetHeroStrength(4,hero); put("Enter any key to continue: "); get(answer); --Enemy wins combat elsif (getheroh(hero) <= 0) then put_line("You Have been SLAIN!!!"); put_line("Thank you for playing The Legend of Zelba"); put("Enter any key to quit: "); get(answer); end if; -- end if; end Combat; --Draw Monster Screen procedure draw_enemy(file:in file_type) is char:character; begin while not end_of_file(file) loop while not end_of_line(file) loop get(file, char); put(char); end loop; if not End_Of_File (file) then Skip_Line (file); new_line; end if; end loop; new_line; end draw_enemy; end combat_package;
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs is free software; you can redistribute it and/or modify it -- -- under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or -- -- (at your option) any later version. -- -- -- -- This program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have received -- -- a copy of the GNU General Public License along with this program; -- -- if not, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- with Libm_Single; use Libm_Single; package body Solar_System is function Get_Body (B : Bodies_Enum_T; Bodies : access Bodies_Array_T) return Body_Access_T is begin return Bodies (B)'Access; end Get_Body; procedure Init_Body (B : Body_Access_T; Radius : Float; Color : RGBA_T; Distance : Float; Angle : Float; Speed : Float; Turns_Around : Body_Access_T; Visible : Boolean := True) is begin B.all := (Distance => Distance, Speed => Speed, Angle => Angle, Turns_Around => Turns_Around, Visible => Visible, Radius => Radius, Color => Color, others => <>); end Init_Body; -- implement a function to compute the X coordinate -- x of the reference + distance * cos(angle) function Compute_X (Body_To_Move : Body_T; Turns_Around : Body_T) return Float; -- implement a function to compute the Y coordinate -- y of the reference + distance * sin(angle) function Compute_Y (Body_To_Move : Body_T; Turns_Around : Body_T) return Float; function Compute_X (Body_To_Move : Body_T; Turns_Around : Body_T) return Float is begin return Turns_Around.X + Body_To_Move.Distance * Cos (Body_To_Move.Angle); end Compute_X; function Compute_Y (Body_To_Move : Body_T; Turns_Around : Body_T) return Float is begin return Turns_Around.Y + Body_To_Move.Distance * Sin (Body_To_Move.Angle); end Compute_Y; procedure Move (Body_To_Move : Body_Access_T) is begin Body_To_Move.X := Compute_X (Body_To_Move.all, Body_To_Move.Turns_Around.all); Body_To_Move.Y := Compute_Y (Body_To_Move.all, Body_To_Move.Turns_Around.all); Body_To_Move.Angle := Body_To_Move.Angle + Body_To_Move.Speed; end Move; procedure Move_All (Bodies : access Bodies_Array_T) is begin -- loop over all bodies and call Move procedure for B in Bodies_Enum_T loop -- call the move procedure for each body Move (Get_Body (B, Bodies)); end loop; end Move_All; end Solar_System;